Brad
Brad

Reputation: 163282

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?

Upvotes: 5

Views: 930

Answers (2)

Kaiido
Kaiido

Reputation: 136755

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

Upvotes: 4

Goose
Goose

Reputation: 4821

Your link to the W3C Working Draft 06 March 2012 has the following.

While not directly applicable to local media stream scenarios (caption support is generally done out-of-band from the original capture), it could be something worth adding in order to integrate with HTML5 videos when the source is a PeerConnection where real-time captioning is being performed and needs to be displayed.

https://www.w3.org/TR/capture-scenarios/#caption-tracks

This does mention it as a possibility, but that implies it was not implemented and as far as I'm aware it hasn't been since.

It's difficult to prove a negative. That said, please give this a few days before accepting this as an answer, in case I am mistaken.

Upvotes: 0

Related Questions