I'm going to build an application in c++ that creates stream of photos and then sends them as video stream to another application. any ideas about how can i start? what I mean is, what libraries should i use and what the encoding? I'm thinking about MJPEG, and UDP or RTP as protocol.... any help would be greatly appreciated.
A compressed audio/video file can be downloaded as a text file. The client (browser) can use the services of HTTP and send a GET message to download the file. The Web server can send the compressed file to the browser. The browser can then use a help application, normally called a media player, to play the file.
How does streaming work? Just like other data that's sent over the Internet, audio and video data is broken down into data packets. Each packet contains a small piece of the file, and an audio or video player in the browser on the client device takes the flow of data packets and interprets them as video or audio.
If your input data is just a bunch of random images, not video, you're not going to do "video streaming". You're just going to be sending a bunch of full images. No need to involve video encoding technology, just do the simplest possible transmission of images. Video encoders rely on each frame having various relationships to the previous, as is common in actual video. For inputs of random images, they're not going to be able to compress that much, and single-frame compression (e.g. JPEG/PNG/whatever) is very likely already going to be applied to your input data.
Probably easiest to send the contents of each file, together with the original filename, and have the receiving client re-create the file on disk, and use existing disk-oriented libraries to open and decode the image.
You should probably just use TCP for this, nothing in your requirements that indicate you need to use the more complicated and error-prone UDP/RTP-based solutions.
For the streaming part you can use Live555. It should cover all you need. That still leaves the problem of generating an MJpeg Stream. I can only guess here, FFMpeg might be what you are looking for (as I see it also covers streaming, so you might only need this one). I think that MJpeg is very suited for you application. As for the TCP or UDP, that depends on how you want to use it. UDP makes sense if you want to make your stream Multicast, otherwise I would prefer TCP, because it is more reliable.
Hope these are some useful hints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With