Click here to Skip to main content
15,861,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm currently developing an application which will enable visualizing images from different sources (mostly IP cameras) in browser (in a HTML5 video element). The UI will allow for matrix view so, normally 16 or more cameras will be displayed at the same time.
From cameras I get MJPEG streams or JPEG images (which I "convert" to MJPEG streams). So, for a camera, I have an MJPEG stream which I set as input for ffmpeg. I instruct ffmpeg to convert this to MP4 & H.264, and expose the output as a tcp stream, like this:

ffmpeg -f mjpeg -i "http://localhost/video.mjpg" -f mp4 -vcodec libx264 <other x264="" encoding="" params="" ...=""> "tcp://127.0.0.1:5001?listen"

This works just fine on localhost, I get the stream displayed in the web page, at best quality.

But this has to work in various network conditions. I played a bit with chrome throttling settings, and noticed that if the network speed is just a bit below the required speed (given by the current compression settings I use in ffmpeg), the things start to go wrong: from stream start being delayed (so, no longer a live stream), up to complete freeze of 'live' image in browser.

What I need is an "adaptive" way to do the compression, in relation with current network speed.

My questions are:
- is ffmpeg able to handle this, to adapt to network conditions - automatically reduce compression quality when speed is low; so the image in browser will be lower quality, but live (which is most important in my case)
- if not, is there a way to workaround this?
- is there a way to detect the network bottleneck? (and then restart ffmpeg with lower compression parameters; this is not a dynamic adaptive streaming, but better than nothing)

Thank you in advance!
Posted
Comments
Jochen Arndt 26-Jan-16 9:49am    
See https://trac.ffmpeg.org/wiki/EncodingForStreamingSites.
There seems to be no adaptive mode but the above contains useful information (use slow preset, use VBV).

Because the bottlenecks are usually on the client site, you may offer an option to select the speed and pass that to your server before starting the streaming. The max. offered speed is then defined by the connection bandwidth of your server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900