Background
W3C MediaRecorder
implementation at browsers output Matroska and WebM files.
What is not currently possible using existing APIs shipped with the browser
MediaRecorder
specification does not provide a means to concatenate MediaStreamTrack
s into a single recording without using WebRTC RTCRtpSender.replaceTrack()
to replace a live MediaStreamTrack
in a live MediaStream
.
In brief, see
- https://github.com/w3c/mediacapture-record/issues/147
- https://github.com/w3c/mediacapture-record/issues/168
- https://github.com/GoogleChromeLabs/webm-wasm/issues/9
Current workarounds
- See branches at https://github.com/guest271314/MediaFragmentRecorder
- https://github.com/guest271314/native-messaging-mkvmerge/blob/master/README.md
Proposed solution
Port mkvmerge
from C++ to JavaScript including all available options.
Define the port as a method of the global object at modern browsers, for example, Window
, Worker
and Worklet
.
mkvmerge
supports reading and concatenating and Matroska and WebM files. Version 36.0.0 supports merging input Matroska or WebM files that potentially include variable width and height (pixel dimensions) into one Matroska or WebM output file (https://mkvtoolnix.download/doc/NEWS.md).
This program takes the input from several media files and joins their streams (all of them or just a selection) into a Matroska™ file; see the Matroska website.
Use mkvmerge…
There is an interesting guide on how to fix audio/video sync on this forum