3

I am trying to embed subtitles in an MP4 contrainer using ffmpeg.

I am using the following command:

ffmpeg -i input.MOV -i input.srt -map 0 -map 1 -c copy -c:s mov_text output.MOV

I would like the subtitles to be encoded as tx3g as opposed to text for compatibility with my Video Streamer (Wowza).

Is there any way to change the subtitles encoder?

Thanks!

3
  • 1
    To my knowledge standard MOV doesn't support any other subtitle codec. You can of course use any other encoder, but it might not work.
    – slhck
    Feb 11, 2013 at 16:47
  • I am flexible on the output type, it be can a mp4 or m4v if that makes it possible. Does it? Feb 12, 2013 at 14:55
  • 1
    MP4 (m4v is just another extension) is mostly the same as MOV—actually it heavily builds on MOV, and supports the same video/audio/subtitle formats. You might be able to force another subtitle codec with tools other than FFmpeg, e.g. MP4Box, but I'm not sure, as I've never tried that before. I'll look into that a little later.
    – slhck
    Feb 12, 2013 at 14:58

2 Answers 2

4

I have to admit I didn't know what the FourCC tx3g really stood for. The FFmpeg codec mov_text and tx3g are the same thing: MPEG-4 Part 17 (Timed Text).

The only thing that FFmpeg does not support is custom styling for the text it embeds. If you look at the source code you'll find that they apply a default style:

For now, we'll use a fixed default style. When we add styling support, this will be generated from the ASS style.

That being said, the free and cross-platform MP4Box should be able to add these subtitles to MP4 files, as you requested. Even with styling. How you add them to the file depends on how they're encoded in the first place. From its documentation:

There is no official textual representation of a text stream. Moreover, the specification relies on IsoMedia knowledge for most structure descriptions. In order to help authoring text streams, an XML format has been developed in GPAC, called TTXT for timed-text – the extension used being .ttxt.

To create a TTXT file, you can do the following:

Find an SRT or SUB subtitle file, and run MP4Box -ttxt file.srt. This will convert the subtitles in TTXT format.

MP4Box should then be able to add the subtitle stream to an existing MP4 file like so:

MP4Box -add input.mp4 -add subtitles.ttxt output.mp4

It's important that you convert the subtitle files to TTXT before. If they're still SUB or SRT-encoded, MP4Box will simply lay them out with default options:

When importing SRT or SUB files, MP4Box will choose default layout options to make the subtitle appear at the bottom of the video.

4

The pure ffmpeg method of embedding macOS and iOS-compatible subtitles on MP4 videos is:

ffmpeg -i input.MOV -i input.srt -c copy -c:s mov_text -tag:s:s:0 tx3g output.mov

The -tag:s:s:0 tx3g does the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .