I'm building an application, that is basically a video chat, where a user connects using WebRTC with another users (operator) browser, and should be able to talk to a third person. The WebRTC part is already done, and works properly. The other part - the problematic one - is that the third person, will be recorded by some video equipment, and a stream will be handled to me using ffmpeg. So I need to, somehow stream this into a browser (and then stream it using WebRTC - that part I've got covered).

Since the stream will be handled to me using ffmpeg, it would be best to use ffmpeg, to stream into a browser, but this is the part where it gets tricky. From what I understand, the only protocol I can use is HTTP (as browsers don't support udp or pretty much anything and using flash player is not an option), but it is not clear how.

One way was to use ffserver, but it got deprecated earlier this year, and I'd rather avoid using obsolete software. Another option is to use some other media streaming server, but I'd rather avoid installing anything.

From what I've read ffmpeg should support what I need out of the box, but I'm not sure how to configure it. For now I've got this:

ffmpeg -f video4linux2 -s 640x480 -r 30 -i /dev/video0 -thread_queue_size 512 -ac 1 -f alsa -i pulse -f webm -listen 1 -seekable 0 -multiple_requests 1 http://localhost:8090

...and a HTML video tag to display this.

<video src="http://localhost:8090"></video>

... which almost works with ffmpeg version 2.8.15-0ubuntu0.16.04.1. I get the browser to play my video, but only after recording stops. It seems, that the browser sees my ffmpeg output as a file and tries to download it, before it starts playing.

This same command, run with ffmpeg version 4.1 gives me errors:

[vp8_v4l2m2m @ 0x3dede80] driver 'uvcvideo' on card 'ASUS USB2.0 WebCam'
[vp8_v4l2m2m @ 0x3dede80] Could not find a valid device
[vp8_v4l2m2m @ 0x3dede80] can't configure encoder
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

How do I live stream from ffmpeg to a browser using http? If I need some sort of segment muxer, then how do I use it?


  • I use my webcam as an input, as this seems to be close to what I can expect to get on production.
  • this is a Linux (Ubuntu) enviorment
  • this whole setup will be installed on our clients hardware and after that I will no longer have access to it. Therefore I want to avoid using anything other then ffmpeg (which they already use), as I'm not sure if they will be able to manage this long term.

1 Answer 1


I think that the issue is the video tag. The video tag does not support live streaming directly, see this question on SO. Specifically:

A. This answer for a technical description of what you want to implement

B. This answer for a code sample

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.