Opened 11 months ago

Last modified 7 weeks ago

#6037 open defect

mkv muxing broken

Reported by: q3cpma Owned by:
Priority: important Component: avformat
Version: git-master Keywords: mkv regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
Muxing two working files (AC3 stream + DVD sub stream and a freshly encoded ffv1 stream) into a mkv produces a broken file: seeking around can break (mute) audio.
Reproducible with both mpv and ffplay (example: seek to around 5.5s).

It seem like http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2713 is related.

On the longer sample, I also get:
-Audio being muted without having to seek
-"Starting new cluster due to timestamp" matroska warnings during mux
-"[mkv] Too many packets in the demuxer packet queues" errors in mpv

How to reproduce:

ffmpeg -y -i 20s.mkv -i ffv1.mkv -map 0:a:1 -map 0:s -map 1:v -c copy out.mkv >ffmpeg.log 2>&1
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.3 (Gentoo 4.9.3 p1.5, pie-0.6.4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-3.2.2/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -march=native -mprefer-avx128 -mvzeroupper -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --disable-gnutls --disable-gmp --enable-gpl --enable-hardcoded-tables --enable-iconv --disable-lzma --enable-network --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --disable-vaapi --disable-vdpau --enable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --disable-libv4l2 --disable-libpulse --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libfdk-aac --disable-libopenjpeg --enable-libbluray --disable-libcelt --disable-libgme --disable-libgsm --disable-mmal --disable-libmodplug --enable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libschroedinger --disable-libspeex --enable-libvorbis --enable-libvpx --disable-libzvbi --disable-libbs2b --disable-chromaprint --disable-libebur128 --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --enable-libass --disable-libfreetype --disable-librubberband --enable-libzimg --disable-libsoxr --enable-pthreads --disable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --disable-nvenc --disable-libopenh264 --disable-libsnappy --disable-libtheora --disable-libtwolame --disable-libwavpack --disable-libwebp --enable-libx264 --enable-libx265 --disable-libxvid --enable-x11grab --disable-amd3dnow --disable-amd3dnowext --disable-avx2 --cpu=host --disable-doc --disable-htmlpages --enable-manpages
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, matroska,webm, from '20s.mkv':
  Metadata:
    title           : Gunsmith Cats
    ENCODER         : Lavf57.56.100
  Duration: 00:00:20.16, start: 0.016000, bitrate: 7009 kb/s
    Chapter #0:0: start 0.064000, end 20.000000
    Metadata:
      title           : 0 1
    Stream #0:0(eng): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s (default)
    Metadata:
      title           : Stereo
      BPS-eng         : 224000
      DURATION-eng    : 00:29:17.152000000
      NUMBER_OF_FRAMES-eng: 54911
      NUMBER_OF_BYTES-eng: 49200256
      SOURCE_ID-eng   : 0180BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.3 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-12-21 10:56:43
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:20.016000000
    Stream #0:1(jpn): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
    Metadata:
      title           : Stereo
      BPS-eng         : 224000
      DURATION-eng    : 00:29:13.728000000
      NUMBER_OF_FRAMES-eng: 54804
      NUMBER_OF_BYTES-eng: 49104384
      SOURCE_ID-eng   : 0181BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.3 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-12-21 10:56:43
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:20.027000000
    Stream #0:2(eng): Video: mpeg2video (Main), yuv420p(tv, top first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc
    Metadata:
      BPS-eng         : 6522010
      DURATION-eng    : 00:29:17.200000000
      NUMBER_OF_FRAMES-eng: 43930
      NUMBER_OF_BYTES-eng: 1432559524
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.3 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-12-21 10:56:43
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:20.160000000
    Stream #0:3(eng): Subtitle: dvd_subtitle, 720x576 (default)
    Metadata:
      BPS-eng         : 5142
      DURATION-eng    : 00:28:42.315200000
      NUMBER_OF_FRAMES-eng: 371
      NUMBER_OF_BYTES-eng: 1107152
      SOURCE_ID-eng   : 0120BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.3 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-12-21 10:56:43
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:00.000000000
Input #1, matroska,webm, from 'ffv1.mkv':
  Metadata:
    ENCODER         : Lavf57.56.100
  Duration: 00:00:20.00, start: 0.000000, bitrate: 57823 kb/s
    Stream #1:0: Video: ffv1 (FFV1 / 0x31564646), yuv420p(progressive), 744x568, 50 fps, 50 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc57.64.101 ffv1
      DURATION        : 00:00:20.000000000
Output #0, matroska, to 'out.mkv':
  Metadata:
    title           : Gunsmith Cats
    encoder         : Lavf57.56.100
    Chapter #0:0: start 0.048000, end 19.984000
    Metadata:
      title           : 0 1
    Stream #0:0(jpn): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 224 kb/s
    Metadata:
      title           : Stereo
      BPS-eng         : 224000
      DURATION-eng    : 00:29:13.728000000
      NUMBER_OF_FRAMES-eng: 54804
      NUMBER_OF_BYTES-eng: 49104384
      SOURCE_ID-eng   : 0181BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.3 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-12-21 10:56:43
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:20.027000000
    Stream #0:1(eng): Subtitle: dvd_subtitle, 720x576 (default)
    Metadata:
      BPS-eng         : 5142
      DURATION-eng    : 00:28:42.315200000
      NUMBER_OF_FRAMES-eng: 371
      NUMBER_OF_BYTES-eng: 1107152
      SOURCE_ID-eng   : 0120BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.3 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-12-21 10:56:43
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      DURATION        : 00:00:00.000000000
    Stream #0:2: Video: ffv1 (FFV1 / 0x31564646), yuv420p(progressive), 744x568, q=2-31, 50 fps, 50 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc57.64.101 ffv1
      DURATION        : 00:00:20.000000000
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:3 -> #0:1 (copy)
  Stream #1:0 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame= 1000 fps=0.0 q=-1.0 Lsize=  141718kB time=00:00:19.98 bitrate=58102.8kbits/s speed=37.7x    
video:141160kB audio:540kB subtitle:0kB other streams:0kB global headers:1kB muxing overhead: 0.012737%

Files
20s.mkv: https://files.catbox.moe/4bdv0o.mkv
ffv1.mkv: https://files.catbox.moe/zp0brx.mkv (or you can convert 20s.mkv to ffv1.mkv)
out.mkv: ask if you can't reproduce

Change History (8)

comment:1 Changed 11 months ago by cehoyos

Do you think this is a regression?
Is the issue reproducible with current FFmpeg?

Last edited 11 months ago by cehoyos (previous) (diff)

comment:2 Changed 11 months ago by cehoyos

  • Priority changed from important to normal

comment:3 Changed 11 months ago by q3cpma

Yes, I tried with the Van Sickle git build. Also, mkvtoolnix (9.6.0) produces a valid result.

comment:4 Changed 11 months ago by cehoyos

Could you explain how I can reproduce the issue?
I downloaded the two samples, used your exact command line and played the output file with ffplay: No matter how often I seek, sound always plays fine.

comment:5 Changed 11 months ago by q3cpma

I gave an example because of size of the sample. Seek around 5.5s and there's no sound.

comment:6 Changed 11 months ago by q3cpma

This is actually exactly like the link said.

ffmpeg -i 20s.mkv -map 0:v:0 -c:v ffv1 ffv1.mkv
ffmpeg -i 20s.mkv -i ffv1.mkv -map 0:a -map 0:s -map 1:v -c copy out.mkv

ffmpeg -i 20s.mkv -c:a copy -c:s copy -c:v ffv1 out2.mkv

out.mkv fails while out2.mkv works; when the operation is fundamentally the same.

comment:7 Changed 11 months ago by cehoyos

  • Keywords regression added
  • Priority changed from normal to important
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

Regression since 3adb5f8d / d9ae1031
Note that ticket #429 to which this is related was not reproducible with 6a4cc509.

comment:8 Changed 7 weeks ago by q3cpma

Hello, is there any progress on this? Maybe the title or something should be
changed since the problem isn't mkv muxing by itself, but using multiple sources
instead of one. The URL I gave in the OP is clearer than me.

Note: See TracTickets for help on using tickets.