I am trying to stream live video from a camera using ffmpeg to a browser. I have found several questions about this on StackOverflow and here, but they all pertain to creating a video file from a camera. Fortunately, I am able to make a video file from my camera input without too much issue. But I need help making a video stream from the camera, ideally as a .mpd file for a browser to play.
Issue
Chromium-based browsers play the streaming audio and video, but Firefox only plays the audio and does not show video.
Background
An excellent Udemy tutorial provided me this command:
ffmpeg -f dshow -i video="HD Pro Webcam C920":audio="Microphone (HD Pro Webcam C920)" -rtbufsize 256M -hls_master_name stream.m3u8 -hls_playlist 1 -seg_duration 2 stream.mpd
Notice I am working on Windows right now, but I'm hoping things will work the same on Linux, my ultimate target.
I have tried different cameras with the same result, so I don't think the camera itself matters.
This command creates the .mpd file and various chunk files as I would expect. I'm using the dashjs player to play the streaming video. In summary, the code looks like this:
JS
import dashjs from 'dashjs'
import { ref, onMounted } from 'vue'
const thevideo = ref(null)
onMounted(() => {
const player = dashjs.MediaPlayer().create();
player.initialize(thevideo.value!, '/stream/stream.m3u8', true);
}
HTML
<video width=600 height=300 ref="thevideo" controls></video>
I am using Vue right now, but you can set this up anyway you'd like, as I'm just trying to test this.
As I mentioned, this setup works great in browsers like Chrome and Edge. I use ffmpeg to create the stream.mpd directly in the public folder and the dash.js player is able to play the video and audio.
However, this same page in Firefox results in only the audio loading. I am not finding errors that appear to pertain to the video downloading or being processed by the browser. It just won't load video.
Might anyone know what's going on here?
By the way, when I try a command like this to make an HLS stream:
ffmpeg -f dshow -i video="HD Pro Webcam C920":audio="Microphone (HD Pro Webcam C920)" -rtbufsize 265M -fflags flush_packets -max_delay 5 -flags -global_header -hls_time 5 -hls_list_size 3 -y stream.m3u8
no browser is able to play the .m3u8 file. I see no errors in Chrome, but Firefox is saying it cannot parse stream.m3u8 as an XML file. I don't know why it's trying to because it's not an XML file and I never said to treat it as such. However, when I use this command with an actual video file as input instead of camera input, it works well.
I'm okay just working with mpeg-dash, but if someone could help me make a m3u8 from camera input, I'd appreciate that as well. But at the very least I would love help making the MPEG-DASH stream work in Firefox. Thank you very much.