Opened 3 years ago

Closed 3 years ago

#9436 closed defect (invalid)

Strange subtitles "Chapter 01" added when input has chapters and output is mp4

Reported by: Andre Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Andre Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I am trying to remux from MKV to MP4.

A tx3g stream containing subtitles keeps appearing out of nowhere.

Same bug is described here: https://www.reddit.com/r/ffmpeg/comments/o0ve8e/when_changing_from_mkv_to_mp4_a_subtitle_tx3g/

Summary of the bug:

When an input video has chapters and the output format is mp4, an undesired subtitles stream is added, containing the texts "Chapter 01", "Chapter 02" etc.

How to reproduce:

ffmpeg -v 9 -loglevel 99 -i /t/chap.mkv -c copy /t/sub.mp4
ffmpeg version 2021-09-22-git-447cf53774-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.3.0 (Rev5, 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-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --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-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  6.100 / 57.  6.100
  libavcodec     59.  9.100 / 59.  9.100
  libavformat    59.  5.100 / 59.  5.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8.  9.100 /  8.  9.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input url with argument 'T:/chap.mkv'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'T:/sub.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input url T:/chap.mkv.
Successfully parsed a group of options.
Opening an input file: T:/chap.mkv.
[NULL @ 0000020f5076f000] Opening 'T:/chap.mkv' for reading
[file @ 0000020f5076f5c0] Setting default whitelist 'file,crypto,data'
Probing matroska,webm score:100 size:2048
[matroska,webm @ 0000020f5076f000] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
[matroska,webm @ 0000020f5076f000] Before avformat_find_stream_info() pos: 2198 bytes read:32768 seeks:0 nb_streams:1
[mpeg2video @ 0000020f50773500] Format yuv420p chosen by get_format().
[matroska,webm @ 0000020f5076f000] All info found
[matroska,webm @ 0000020f5076f000] stream 0: start_time: 0.509 duration: NOPTS
[matroska,webm @ 0000020f5076f000] format: start_time: 0.509 duration: 2.443 (estimate from stream) bitrate=5429 kb/s
[matroska,webm @ 0000020f5076f000] After avformat_find_stream_info() pos: 140585 bytes read:147318 seeks:0 frames:2
Input #0, matroska,webm, from 'T:/chap.mkv':
  Metadata:
    title           : TROPA_DE_ELITE_II
    ENCODER         : Lavf59.4.102
  Duration: 00:00:02.44, start: 0.509000, bitrate: 5429 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 134.241500
      Metadata:
        title           : Chapter 02
    Chapter #0:1: start 134.241500, end 519.626500
      Metadata:
        title           : Chapter 03
    Chapter #0:2: start 519.626500, end 1015.121500
      Metadata:
        title           : Chapter 04
    Chapter #0:3: start 1015.121500, end 1428.034000
      Metadata:
        title           : Chapter 05
    Chapter #0:4: start 1428.034000, end 1773.379000
      Metadata:
        title           : Chapter 06
    Chapter #0:5: start 1773.379000, end 2151.256500
      Metadata:
        title           : Chapter 07
    Chapter #0:6: start 2151.256500, end 2989.093500
      Metadata:
        title           : Chapter 08
    Chapter #0:7: start 2989.093500, end 3444.048000
      Metadata:
        title           : Chapter 09
    Chapter #0:8: start 3444.048000, end 3865.969500
      Metadata:
        title           : Chapter 10
    Chapter #0:9: start 3865.969500, end 4014.117500
      Metadata:
        title           : Chapter 11
    Chapter #0:10: start 4014.117500, end 4422.025000
      Metadata:
        title           : Chapter 12
    Chapter #0:11: start 4422.025000, end 4832.435000
      Metadata:
        title           : Chapter 13
    Chapter #0:12: start 4832.435000, end 5077.179500
      Metadata:
        title           : Chapter 14
    Chapter #0:13: start 5077.179500, end 5429.531500
      Metadata:
        title           : Chapter 15
    Chapter #0:14: start 5429.531500, end 5512.114000
      Metadata:
        title           : Chapter 16
    Chapter #0:15: start 5512.114000, end 5961.563000
      Metadata:
        title           : Chapter 17
    Chapter #0:16: start 5961.563000, end 6280.214667
      Metadata:
        title           : Chapter 18
  Stream #0:0(eng), 2, 1/1000: Video: mpeg2video (Main), 1 reference frame, yuv420p(tv, smpte170m, progressive, left), 720x480 [SAR 32:27 DAR 16:9], 0/1, 7000 kb/s, SAR 186:157 DAR 279:157, 29.97 fps, 29.97 tbr, 1k tbn
    Metadata:
      BPS-eng         : 6998906
      DURATION-eng    : 01:54:48.214666666
      NUMBER_OF_FRAMES-eng: 206440
      NUMBER_OF_BYTES-eng: 6026245570
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.4 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-09-20 00:45:38
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:02.443000000
    Side data:
      cpb: bitrate max/min/avg: 7000000/0/0 buffer size: 1835008 vbv_delay: N/A
Successfully opened the file.
Parsing a group of options: output url T:/sub.mp4.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: T:/sub.mp4.
[file @ 0000020f50777740] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Output #0, mp4, to 'T:/sub.mp4':
  Metadata:
    title           : TROPA_DE_ELITE_II
    encoder         : Lavf59.5.100
  Chapters:
    Chapter #0:0: start 0.000000, end 133.732500
      Metadata:
        title           : Chapter 02
    Chapter #0:1: start 133.732500, end 519.117500
      Metadata:
        title           : Chapter 03
    Chapter #0:2: start 519.117500, end 1014.612500
      Metadata:
        title           : Chapter 04
    Chapter #0:3: start 1014.612500, end 1427.525000
      Metadata:
        title           : Chapter 05
    Chapter #0:4: start 1427.525000, end 1772.870000
      Metadata:
        title           : Chapter 06
    Chapter #0:5: start 1772.870000, end 2150.747500
      Metadata:
        title           : Chapter 07
    Chapter #0:6: start 2150.747500, end 2988.584500
      Metadata:
        title           : Chapter 08
    Chapter #0:7: start 2988.584500, end 3443.539000
      Metadata:
        title           : Chapter 09
    Chapter #0:8: start 3443.539000, end 3865.460500
      Metadata:
        title           : Chapter 10
    Chapter #0:9: start 3865.460500, end 4013.608500
      Metadata:
        title           : Chapter 11
    Chapter #0:10: start 4013.608500, end 4421.516000
      Metadata:
        title           : Chapter 12
    Chapter #0:11: start 4421.516000, end 4831.926000
      Metadata:
        title           : Chapter 13
    Chapter #0:12: start 4831.926000, end 5076.670500
      Metadata:
        title           : Chapter 14
    Chapter #0:13: start 5076.670500, end 5429.022500
      Metadata:
        title           : Chapter 15
    Chapter #0:14: start 5429.022500, end 5511.605000
      Metadata:
        title           : Chapter 16
    Chapter #0:15: start 5511.605000, end 5961.054000
      Metadata:
        title           : Chapter 17
    Chapter #0:16: start 5961.054000, end 6279.705667
      Metadata:
        title           : Chapter 18
  Stream #0:0(eng), 0, 1/16000: Video: mpeg2video (Main), 1 reference frame (mp4v / 0x7634706D), yuv420p(tv, smpte170m, progressive, left), 720x480 (0x0) [SAR 186:157 DAR 279:157], 0/1, q=2-31, 7000 kb/s, 29.97 fps, 29.97 tbr, 16k tbn
    Metadata:
      BPS-eng         : 6998906
      DURATION-eng    : 01:54:48.214666666
      NUMBER_OF_FRAMES-eng: 206440
      NUMBER_OF_BYTES-eng: 6026245570
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.4 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-09-20 00:45:38
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:02.443000000
    Side data:
      cpb: bitrate max/min/avg: 7000000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
No more output streams to write to, finishing.e=-00:00:00.03 bitrate=N/A speed=N/A
frame=   58 fps=0.0 q=-1.0 Lsize=    1620kB time=00:00:01.86 bitrate=7102.9kbits/s speed= 588x
video:1616kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.203237%
Input file #0 (T:/chap.mkv):
  Input stream #0:0 (video): 58 packets read (1655211 bytes);
  Total: 58 packets (1655211 bytes) demuxed
Output file #0 (T:/sub.mp4):
  Output stream #0:0 (video): 58 packets muxed (1655211 bytes);
  Total: 58 packets (1655211 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0000020f507992c0] Statistics: 2 seeks, 10 writeouts
[AVIOContext @ 0000020f50777a80] Statistics: 1657989 bytes read, 0 seeks

Checking the extra subtitle stream:

ffprobe /t/sub.mp4
ffprobe version 2021-09-22-git-447cf53774-full_build-www.gyan.dev Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10.3.0 (Rev5, 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-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --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-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  6.100 / 57.  6.100
  libavcodec     59.  9.100 / 59.  9.100
  libavformat    59.  5.100 / 59.  5.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8.  9.100 /  8.  9.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'T:/sub.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : TROPA_DE_ELITE_II
    encoder         : Lavf59.5.100
  Duration: 01:44:39.71, start: 0.000000, bitrate: 2 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 133.733000
      Metadata:
        title           : Chapter 02
    Chapter #0:1: start 133.733000, end 519.118000
      Metadata:
        title           : Chapter 03
    Chapter #0:2: start 519.118000, end 1014.613000
      Metadata:
        title           : Chapter 04
    Chapter #0:3: start 1014.613000, end 1427.525000
      Metadata:
        title           : Chapter 05
    Chapter #0:4: start 1427.525000, end 1772.870000
      Metadata:
        title           : Chapter 06
    Chapter #0:5: start 1772.870000, end 2150.748000
      Metadata:
        title           : Chapter 07
    Chapter #0:6: start 2150.748000, end 2988.585000
      Metadata:
        title           : Chapter 08
    Chapter #0:7: start 2988.585000, end 3443.539000
      Metadata:
        title           : Chapter 09
    Chapter #0:8: start 3443.539000, end 3865.461000
      Metadata:
        title           : Chapter 10
    Chapter #0:9: start 3865.461000, end 4013.609000
      Metadata:
        title           : Chapter 11
    Chapter #0:10: start 4013.609000, end 4421.516000
      Metadata:
        title           : Chapter 12
    Chapter #0:11: start 4421.516000, end 4831.926000
      Metadata:
        title           : Chapter 13
    Chapter #0:12: start 4831.926000, end 5076.671000
      Metadata:
        title           : Chapter 14
    Chapter #0:13: start 5076.671000, end 5429.023000
      Metadata:
        title           : Chapter 15
    Chapter #0:14: start 5429.023000, end 5511.605000
      Metadata:
        title           : Chapter 16
    Chapter #0:15: start 5511.605000, end 5961.054000
      Metadata:
        title           : Chapter 17
    Chapter #0:16: start 5961.054000, end 6279.706000
      Metadata:
        title           : Chapter 18
  Stream #0:0[0x1](eng): Video: mpeg2video (Main) (mp4v / 0x7634706D), yuv420p(tv, smpte170m, progressive), 720x480 [SAR 32:27 DAR 16:9], 6846 kb/s, SAR 186:157 DAR 279:157, 29.99 fps, 29.97 tbr, 16k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
    Side data:
      cpb: bitrate max/min/avg: 7000000/0/0 buffer size: 1835008 vbv_delay: N/A
  Stream #0:1[0x2](eng): Data: bin_data (text / 0x74786574)
    Metadata:
      handler_name    : SubtitleHandler
Unsupported codec with id 98314 for input stream 1

Attachments (1)

chap.mkv (1.6 MB ) - added by Andre 3 years ago.
sample video file with chapters

Download all attachments as: .zip

Change History (2)

by Andre, 3 years ago

Attachment: chap.mkv added

sample video file with chapters

comment:1 by mkver, 3 years ago

Resolution: invalid
Status: newclosed

It does not appear "out of nowhere", it appears because the source file contained chapters and ffmpeg by default tries to preserve them. That it appears as a subtitle stream is an oddity of mp4, where chapters and subtitles are muxed similarly. But a proper player can distinguish between them, as ffmpeg/ffprobe do: They show it as data stream (notice the "Data:"), not as subtitle.
If your mp4 player got confused by this, you can disable copying of chapters with -map_chapters -1.

Note: See TracTickets for help on using tickets.