According to the presented code sample, there is only one audio and one video track in your recorder stream.
If your input file has both audio and video, you need to specify the output codec for both tracks here as follows.
worker.postMessage({ type: 'command', arguments: [ '-i', 'audiovideo.webm', '-c:v', 'mpeg4', '-c:a', 'aac', // or vorbis '-b:v', '6400k', // video bitrate '-b:a', '4800k', // audio bitrate '-strict', 'experimental', 'audiovideo.mp4' ], files: [ { data: new Uint8Array(fileReaderData), name: 'audiovideo.webm' } ] });
Transcoding video inside the browser is not recommended, as it will consume more processor time and memory. And ffmpeg_asm.js is hard. May be good for POC :)
What is your use case? webm (vp8 / vp9) is widely used these days.
Chrome will support the following mime types:
"video/webm" "video/webm;codecs=vp8" "video/webm;codecs=vp9" "video/webm;codecs=h264" "video/x-matroska;codecs=avc1"
So you can get mp4 record directly from chrome MediaRecorder with the following hack
var options = {mimeType: 'video/webm;codecs=h264'}; mediaRecorder = new MediaRecorder(stream, options); ..... //Before merging blobs change output mime var blob = new Blob(recordedBlobs, {type: 'video/mp4'}); // And name your file as video.mp4