Search code examples
ffmpegmov

Multiple subtitle tracks are not encoded into mov file


I am trying to compile a mov file with multiple audio tracks and subtitle tracks to match. Unfortunately only the first subtitle track appears in Quicktime (Intended for Apple Devices). Looking at it compile- it appears that the second subtitle track is not being encoded using the tx3g format

Command

ffmpeg \
-i input1.mp3 \
-i input2.mp3 \
-loop 1 \
-i black.png \
-i eng.srt -i zh.srt \
-map 0 -map 1 -map 2 -map 3 -map 4 \
-c:a aac \
-c:v libx264 -pix_fmt yuv420p -shortest \
-c:s:0 mov_text \
-tag:s:s:0 tx3g \
-c:s:1 mov_text \
-tag:s:s:1 tx3g \
-metadata:s:s:0 language=eng -metadata:s:s:1 language=chi \
-metadata:s:a:0 language=eng -metadata:s:a:1 language=chi \
output.mov

Partial output

    Stream #0:3(eng): Subtitle: mov_text (tx3g / 0x67337874)
Metadata:
  encoder         : Lavc57.89.100 mov_text
Stream #0:4(chi): Subtitle: mov_text
Metadata:
  encoder         : Lavc57.89.100 mov_text

Solution

  • Both subtitles have been encoded, but the tag syntax is wrong. Since codec tags apply to streams only, the initial s shouldn't be present. Also, since it's the same encoder, you can apply a global subtitle encoder.

    So,

    -c:s:0 mov_text \
    -tag:s:s:0 tx3g \
    -c:s:1 mov_text \
    -tag:s:s:1 tx3g \
    

    becomes

    -c:s mov_text \
    -tag:s:0 tx3g \
    -tag:s:1 tx3g \
    

    which can be further simplified to

    -c:s mov_text \
    -tag:s tx3g \
    

    Of course, not sure that QT is failing because of this.