I have a screen recorder web extension that generates the recorded video as a download. Everything's fine in Chrome, but none of the generated videos are playing in Firefox.
I've tried both .webm (via the VP9 codec) and .mp4 (via H264). The pertinent code is:
recorder.addEventListener('stop', evt => {
blob = new Blob(recorder.chunks, {'type': 'video/webm; codecs=vp9'});
blob_url = window.URL.createObjectURL(blob);
//...
Also tried
{'type': 'video/mp4; codecs=H264'}
In Firefox I just see:
What am I doing wrong?
[EDIT]
Following @epistemex's helpful answer I am now specifying webm at the point of creating the MediaRecorder
, and not specifying any codec.
MediaRecorder(master_stream, {mimeType: 'video/webm'});
Then later
blob = new Blob(recorder.chunks); //<-- not setting mime here now
...but still Firefox says it can't play the resultant files, even though
MediaRecorder.isTypeSupported("video/webm") //true
[EDIT 2 - including more code]
if (rec_prefs.rec_vid == 'screen') listen_for_stop_screen_sharing();
recorder = new MediaRecorder(master_stream, {mimeType: 'video/webm'});
recorder.start();
recorder.chunks = [];
recorder.addEventListener('dataavailable', evt => {
recorder.chunks.push(evt.data);
}, false);
rec_stopped_dfd = new Promise((resolve) => {
recorder.addEventListener('stop', evt => {
blob = new Blob(recorder.chunks);
blob_url = window.URL.createObjectURL(blob);
resolve();
}, false);
});
Call to recorder.stop()
is in a callback in response to a button click:
function stop_recording() {
master_stream.getTracks().forEach(track => track.stop());
if (recorder && recorder.state != 'inactive') {
recorder.stop();
Yes I can confirm the array is not empty. Everything works perfectly in Chrome - no errors, console etc.