16

I tried to add 2 .srt subtitles to a video, but the resulting file has only the first subtitle. This is the command I used:

ffmpeg -i $movie.mov -i $sub_en.srt -i $sub_de.srt \
-c:v copy -c:a copy \
-c:s:0 srt -metadata:s:s:0 language=eng \
-c:s:1 srt -metadata:s:s:1 language=ger \
$output.mkv

The full output below also shows it only encodes 1 subtitle (I replaced the long file names with the variables used above for clarity):

ffmpeg version 3.3.2-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-11) 20170519
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '$movie.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2017-08-23T15:33:19.000000Z
  Duration: 00:56:34.92, start: 0.000000, bitrate: 20807 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 20546 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2017-08-23T15:33:20.000000Z
      handler_name    : Core Media Data Handler
      encoder         : H.264
      timecode        : 01:00:00:00
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      creation_time   : 2017-08-23T15:33:20.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:2(und): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2017-08-23T15:33:20.000000Z
      handler_name    : Core Media Data Handler
      timecode        : 01:00:00:00
Input #1, srt, from '$sub_en.srt':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Subtitle: subrip
Input #2, srt, from '$sub_de.srt':
  Duration: N/A, bitrate: N/A
    Stream #2:0: Subtitle: subrip
Output #0, matroska, to '$output.mkv':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    encoder         : Lavf57.71.100
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 20546 kb/s, 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2017-08-23T15:33:20.000000Z
      timecode        : 01:00:00:00
      handler_name    : Core Media Data Handler
      encoder         : H.264
    Stream #0:1(ger): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      creation_time   : 2017-08-23T15:33:20.000000Z
      handler_name    : Core Media Data Handler
    Stream #0:2: Subtitle: subrip (srt)
    Metadata:
      encoder         : Lavc57.89.100 srt
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #1:0 -> #0:2 (subrip (srt) -> subrip (srt))
Press [q] to stop, [?] for help
frame=20372 fps=236 q=-1.0 Lsize= 2091417kB time=00:13:35.78 bitrate=21001.7kbits/s speed=9.45x    
video:2065455kB audio:25494kB subtitle:8kB other streams:0kB global headers:0kB muxing overhead: 0.022014%
Exiting normally, received signal 2.

I know that in this particular case I can use mkvmerge, but it wouldn't work for .mp4 mov_text (.ttxt) subtitles, and anyway I would like to understand what is wrong with my ffmpeg command.

1 Answer 1

29

Whenever's there's multiple inputs fed to ffmpeg, and you need one more than video/audio/subtitle stream sent to the output, -map statements are needed.

ffmpeg -i $movie.mov -i $sub_en.srt -i $sub_de.srt \
-map 0:v -map 0:a -map 1 -map 2 \
-c:v copy -c:a copy -c:s srt \
-metadata:s:s:0 language=eng -metadata:s:s:1 language=ger \
$output.mkv

Since the subtitles are SRT, you can just do -c:s copy.

1
  • 1
    If I need to add 20 languages subtitles to all my videos, I'll have to -map number 20 times. Do you have another solution ?
    – SebMa
    Commented Apr 6, 2019 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.