<p>I think that the issue is the video tag.  The video tag does not support live streaming directly, see <a href="https://stackoverflow.com/questions/5858936/html5-live-streaming.">this question on SO</a>.  Specifically:</p>

<p>A. <a href="https://stackoverflow.com/a/39750043/3935060">This answer</a> for a technical description of what you want to implement</p>

<p>B. <a href="https://stackoverflow.com/a/44987330/3935060">This answer</a> for a code sample</p>

CC BY-SA 4.0
2018-12-10T21:45:19.840Z
2018-12-10T21:45:19.840Z
Gordon
<p>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).</p>

<p>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.</p>

<p>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. </p>

<p>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:</p>

<pre><code>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
</code></pre>

<p>...and a HTML video tag to display this.</p>

<pre><code>&lt;video src="http://localhost:8090"&gt;&lt;/video&gt;
</code></pre>

<p>... which almost works with <code>ffmpeg version 2.8.15-0ubuntu0.16.04.1</code>. 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.</p>

<p>This same command, run with <code>ffmpeg version 4.1</code> gives me errors:</p>

<pre><code>[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
</code></pre>

<p>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?</p>

<p>Notes:</p>

<ul>
<li>I use my webcam as an input, as this seems to be close to what I can
expect to get on production.</li>
<li>this is a Linux (Ubuntu) enviorment</li>
<li>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.</li>
</ul>

<ffmpeg><streaming><live>
ffmpeg - live stream into a browser video tag (localhost only)
user23829
# ffmpeg - live stream into a browser video tag (localhost only)

(Asked by: username_0 on 2018-12-05)

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.


... 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?
Notes:

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.

**Tags:** ffmpeg, streaming, live


---

## 1 answers

### Answer by username_1 on 2018-12-10. Score: 3

I think that the issue is the video tag. The video tag does not support live streaming directly, see [this question on SO](https://stackoverflow.com/questions/5858936/html5-live-streaming.). Specifically:

A. [This answer](https://stackoverflow.com/a/39750043/3935060) for a technical description of what you want to implement

B. [This answer](https://stackoverflow.com/a/44987330/3935060) for a code sample


---

