The Little Guy Posted January 11, 2009 Share Posted January 11, 2009 I would like to stream web cam video, but I'm not quite sure how I would do this. All I know is: The client computer uses flash to grab the video from the cam Here are things I would like to know: 1. How to send that video to a server 2. How to have the server send that video to another connected client I have already gotten a chat server working, so I would assume that it would/could be fairly similar, or am I wrong? Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/ Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 I have already gotten a chat server working, so I would assume that it would/could be fairly similar, or am I wrong? Yes, except for video data instead of plain text. If you don't want to use flv, you would have to code an applet that can use codecs. Do you plan to code this your self? Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734524 Share on other sites More sharing options...
The Little Guy Posted January 11, 2009 Author Share Posted January 11, 2009 I was planning to code it my self. I don't care what I use, I would just like to do the easier method. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734530 Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 Well, you'll need 3 basic components, which can be broken down farther. 1. A client application. -This will connect to the server and get streamed video data -It will then display it. (FLV would be the file type, most likely.) Now, since it will be streaming live, it won't be as simple as downloading a file. You will have to open a connection to the server and the server will have to continually push the new video data to the client. It might become difficult to handle lag, since you will have to code in the ability to tell the server to skip ahead x seconds, incase the client gets behind, since you want a very small buffer on live video. 2. A server applicaton. -This will handle 2 things: --Getting video data from someone and transmitting it to the correct people (or person). 3. A second client application -This one would read the webcam and transmit it to the server. The server could handle the encoding of the content (IE convert it from something to FLV) or the client side stuff could attempt to do it. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734534 Share on other sites More sharing options...
The Little Guy Posted January 11, 2009 Author Share Posted January 11, 2009 Now, since it will be streaming live, it won't be as simple as downloading a file. You will have to open a connection to the server and the server will have to continually push the new video data to the client. It might become difficult to handle lag, since you will have to code in the ability to tell the server to skip ahead x seconds, in case the client gets behind, since you want a very small buffer on live video. This is the part I am not 100% sure of how it works. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734554 Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 Which part do you not get? Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734582 Share on other sites More sharing options...
The Little Guy Posted January 11, 2009 Author Share Posted January 11, 2009 how the original client (with the cam) sends it to the server, and how the server sends it back to the other client(s). Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734837 Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 Do you not get how it would read data from the webcam and send it back? I have no idea how it would read data from the webcam. You might not be able to use Flash for that. As for sending it back, that would be easy. And as for the server sending the data to everyone, that would be easy too. I'm still wondering what specific part you don't know how to do. If it's the camera reading part, I have no idea x.x. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734847 Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 It seems that flash does have ability to get access to webcam (at least in Windows). You can see it in action in Facebook for example, where you can put a picture from your webcam into your profile. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734861 Share on other sites More sharing options...
The Little Guy Posted January 11, 2009 Author Share Posted January 11, 2009 this gets it from the cam: http://www.newgrounds.com/portal/view/326194 I don't know how to send the data to everyone <- part I don't know how to do Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734876 Share on other sites More sharing options...
corbin Posted January 11, 2009 Share Posted January 11, 2009 Simple. You have to keep track of multiple socket connections. If you plan on writing the server side part in a language I know, I could probably give you a small example. It's really the same thing as a chat server though, just 1 person 'writing' and multiple 'reading'. (It actually would be called writing and reading, but I meant it there as in like typing and reading the chat room.) In pseudo code, it would be this: -listen for new connections -On accept new connection: --See if it's a web cam person, or someone watching something --If it's a web cam person, make a 'room' or something like that (or if its 1-1 chat, make some sort of thing to keep track of people) --If it's a client, put them in the 'room' Then, the rest of the pseudo code would go like this (I would make this a multithreaded application, by the way, especially if you plan on having lots of people using it at the same time. If you didn't make it multithreaded, all it takes is a couple of laggy connections, and suddenly the program is at a crawl since it would be waiting to read or write to those sockets for a long time.) -For each room: --Receive data from the cam ---Send data to all people of the "room" except the cam person. Depending on the language, rooms could be arrays, or vectors. (In a language where array size is dynamic, like PHP, you could use an array, but in a language where arrays are not dynamic, unless you allocate a pointer and keep realloc'ing, you would find it easier to use a vector [since it is, in a lot of ways, a dynamic array].) Hopefully you can see where the multithreaded-ness would be useful. I would highly suggest not writing the server side in PHP. C++/C/Java would be my choices. I would personally probably code it in Java, but that's just because I'm more comfortable in Java with threads than in C/C++. If I weren't going to make it multithreaded, I would probably code it in C++. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-734891 Share on other sites More sharing options...
The Little Guy Posted January 12, 2009 Author Share Posted January 12, 2009 what about Python? Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-735011 Share on other sites More sharing options...
corbin Posted January 12, 2009 Share Posted January 12, 2009 Hrmmm.... I don't know about python. Does it have threading support? I would definitely go with a language that has thread support. If you don't have many people it's not really needed, but in the long run, it would be needed. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-735033 Share on other sites More sharing options...
The Little Guy Posted January 12, 2009 Author Share Posted January 12, 2009 yeah, it does I found this tut: http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/ Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-735034 Share on other sites More sharing options...
corbin Posted January 12, 2009 Share Posted January 12, 2009 Then I guess python would be fine ;p. You'll be the one coding it, so it's really just about your personal preference. Quote Link to comment https://forums.phpfreaks.com/topic/140363-web-cam-chat/#findComment-735041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.