1

Here is my scenario:

  • MKV file has 2 audio tracks (fr, eng)
  • File needs the audio tracks switched
  • File needs to make eng the default audio track
  • File also has 2 subtitle tracks (fr-forced, fr)
  • Need to drop fr-forced subtitle track
  • Need to add in eng subtitles and make it the default

I know how to flip audio tracks so it was just a matter of importing a new subtitle track while preserving only one of the existing subtitle tracks.

So, based on this page, this command should do the trick:

ffmpeg -i "in.mkv" -i "captions.srt" -map 0:v:0 -map 0:a:1 -map 0:a:0 \
  -disposition:a:0 default -disposition:a:1 none -map 1 -c:s:0 srt -map 0:s:1 \
  -metadata:s:s:0 language=eng -metadata:s:s:1 language=fr -disposition:s:0 default \
  -disposition:s:1 none -c:v copy -c:a copy "out.mkv"

And when I go to run this command, the output would seem to imply that I have it setup correctly:

Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
  Stream #0:1 -> #0:2 (copy)
  Stream #1:0 -> #0:3 (subrip (srt) -> subrip (srt))
  Stream #0:4 -> #0:4 (subrip (srt) -> ass (ssa))

However, when I load the file in VLC, the audio tracks are as I would expect, the first 2 subtitle tracks are as I would expect, but there is a 3rd subtitle track, a duplicate of the English track I loaded in, unlabeled and the default.

VLC subtitle list

When I open the codec information window:

VLC codec information window

I updated from ffmpeg 4.3.1 to 4.3.2 just to see if this was a bug that was patched and the behavior is the same.

So my question is: is my command correct? I can certainly do this in 2 commands to clean out the third subtitle track, but I prefer to do it in one go.

I was asked for full logs, so here they are:

PS C:\Users\sarah\Videos> ffmpeg -i "OG-S02E01.mkv" -i "S02E01.srt" -map 0:v:0 -map 0:a:1 -map 0:a:0 -disposition:a:0 default -disposition:a:1 none -map 1 -c:s:0 srt -map 0:s:1 -metadata:s:s:0 language=eng -metadata:s:s:1 language=fr -disposition:s:0 default -disposition:s:1 none -c:v copy -c:a copy "S02E01.mkv"
ffmpeg version 4.3.2-2021-02-20-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Guessed Channel Layout for Input Stream #0.2 : 5.1
Input #0, matroska,webm, from 'OG-S02E01.mkv':
  Metadata:
    encoder         : libebml v1.3.7 + libmatroska v1.5.0
    creation_time   : 2019-04-26T14:08:09.000000Z
  Duration: 00:24:08.86, start: 0.000000, bitrate: 5360 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      BPS-eng         : 4078918
      DURATION-eng    : 00:24:08.489000000
      NUMBER_OF_FRAMES-eng: 34729
      NUMBER_OF_BYTES-eng: 738533535
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(fre): Audio: eac3, 48000 Hz, 5.1, fltp (default)
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:24:08.864000000
      NUMBER_OF_FRAMES-eng: 45277
      NUMBER_OF_BYTES-eng: 115909120
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Audio: eac3, 48000 Hz, 5.1, fltp
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:24:08.864000000
      NUMBER_OF_FRAMES-eng: 45277
      NUMBER_OF_BYTES-eng: 115909120
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:3(fre): Subtitle: subrip (default) (forced)
    Metadata:
      title           : Forced
      BPS-eng         : 0
      DURATION-eng    : 00:23:04.049000000
      NUMBER_OF_FRAMES-eng: 2
      NUMBER_OF_BYTES-eng: 58
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:4(fre): Subtitle: subrip
    Metadata:
      BPS-eng         : 53
      DURATION-eng    : 00:23:04.050000000
      NUMBER_OF_FRAMES-eng: 258
      NUMBER_OF_BYTES-eng: 9316
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Input #1, srt, from 'S02E01.srt':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Subtitle: subrip
Output #0, matroska, to 'S02E01.mkv':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      BPS-eng         : 4078918
      DURATION-eng    : 00:24:08.489000000
      NUMBER_OF_FRAMES-eng: 34729
      NUMBER_OF_BYTES-eng: 738533535
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: eac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1, fltp (default)
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:24:08.864000000
      NUMBER_OF_FRAMES-eng: 45277
      NUMBER_OF_BYTES-eng: 115909120
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(fre): Audio: eac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1, fltp
    Metadata:
      BPS-eng         : 640000
      DURATION-eng    : 00:24:08.864000000
      NUMBER_OF_FRAMES-eng: 45277
      NUMBER_OF_BYTES-eng: 115909120
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:3(eng): Subtitle: subrip (srt) (default)
    Metadata:
      encoder         : Lavc58.91.100 srt
    Stream #0:4(fr): Subtitle: ass (ssa)
    Metadata:
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      BPS-eng         : 53
      DURATION-eng    : 00:23:04.050000000
      NUMBER_OF_FRAMES-eng: 258
      NUMBER_OF_BYTES-eng: 9316
      _STATISTICS_WRITING_APP-eng: mkvmerge v33.0.0 ('A Little Bit of Madness') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-04-26 14:08:09
      encoder         : Lavc58.91.100 ssa
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
  Stream #0:1 -> #0:2 (copy)
  Stream #1:0 -> #0:3 (subrip (srt) -> subrip (srt))
  Stream #0:4 -> #0:4 (subrip (srt) -> ass (ssa))
Press [q] to stop, [?] for help
frame=34729 fps=11733 q=-1.0 Lsize=  948552kB time=00:24:08.83 bitrate=5363.3kbits/s speed= 489x
video:721224kB audio:226385kB subtitle:26kB other streams:0kB global headers:1kB muxing overhead: 0.096739%
PS C:\Users\sarah\Videos> 
4
  • Share full logs of command and of ffmpeg -i output
    – Gyan
    Mar 4 '21 at 6:16
  • I edited the post with full logs Mar 4 '21 at 16:57
  • To me it does appear to be a bug. I would try to fix this with mkv-tools
    – v010dya
    Dec 11 '21 at 4:05
  • By mkv-tools, are you referring to MKVToolNix or something else? (I have found MKVToolNix to be quite helpful, but if there are better tools, I'm all ears) Dec 21 '21 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.