javascriptgoogle-chromeffmpegmediarecorder

How to make mp4 from MediaStream in Chrome browser


MediaRecorder.isTypeSupported('video/mp4') is false in Chrome. So I found MediaStreamRecorder https://github.com/streamproc/MediaStreamRecorder then I did

var recorder = new MediaStreamRecorder(stream, {
  mimeType: 'video/mp4',
});
// also
recorder.mimeType = 'video/mp4';

But the output is webm as I checked with ffmpeg -i

Input #0, matroska,webm, from '/Users/otiai10/Downloads/example.mp4':
  Metadata:
    encoder         : Chrome
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)

The video is playable in Chrome but NOT on QuickTime Player, in evidence.

Here are more details and (not!) working example of this problem.

It was said muaz-khan/Ffmpeg.js can convert webm to mp4, but the file size matters.

Is there any workaround to record and save as mp4?


Solution

  • OK, that was my misunderstanding.

    See https://github.com/streamproc/MediaStreamRecorder/issues/117 for more details.

    MediaStreamRecorder can record audio as WAV and video as either WebM or animated gif on Chrome

    no mp4 possible.