5

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?

Brad
  • 159,648
  • 54
  • 349
  • 530
  • _"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?"_ Yes. It is possible. – guest271314 Sep 22 '16 at 03:31
  • @guest271314 Alright, then how? – Brad Sep 22 '16 at 03:32

2 Answers2

4

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

Kaiido
  • 123,334
  • 13
  • 219
  • 285
  • 1
    Correct, there is no such thing as a `text` [MediaStreamTrack.kind](https://www.w3.org/TR/mediacapture-streams/#widl-MediaStreamTrack-kind), only `video` and `audio`. – miguelao Sep 27 '16 at 22:44
0

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.

Goose
  • 4,764
  • 5
  • 45
  • 84
  • Thanks Goose. Yes, that W3C link was before MediaRecorder as well, so it's a bit unrelated. I linked to it to show that there was at least some discussion of captioning among the media folks. I'm hoping that the situation has changed in the last few years, but I haven't found anything official for caption track support. Let me know what you find! Thanks. – Brad Sep 19 '16 at 20:30
  • 1
    Any news about this? To date I don't see anything related to text track into. Webrtc stream . – Aramil Apr 24 '20 at 02:30