javascriptcaptionclosed-captionsmediastreamweb-mediarecorder

MediaRecorder, captions, and subtitles


Is it possible to use MediaRecorder to mux a WebVTT track (or any other kind of track for captions and subtitles) into the output stream along with the audio and video tracks?

WebM supports a WebVTT track. There is a W3C doc from 2012 that briefly mentions caption tracks as a possibility.

Is there support for in-band captioning today? If so, how do I use it?


Solution

  • Since the TextTrack is added to the videoElement, your best bet would have been with the videoElement.captureStream() method, but it currently doesn't incorporate the TextTracks.

    Specs about Media Capture from DOM Elements only states that,

    Both MediaStream and HTMLMediaElement expose the concept of a "track". Since there is no common type used for HTMLMediaElement, this document uses the term track to refer to either VideoTrack or AudioTrack.

    So we can just say that it doesn't speak about TextTracks...

    MediaStream.addTrack can only handle MediaStreamTracks so it's a no-go too.

    This unfortunately leads to a nope. (At least currently - specs may add it in the future, and I guess you can open an issue here about it).

    A small playground