Skip to main content

Topic: Concat MKVs; great differences in size with ffmpeg and MKVToolNIX (Read 2104 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
Concat MKVs; great differences in size with ffmpeg and MKVToolNIX
Hello,

sorry if this subforum is not the right place...
I have concatenated 3 MKVs with ffmpeg as well as with MKVToolNIX and the sizes of the resulting concatenated files differ greatly, though the content is identical.
Where does this difference come from, does MKV have so much overhead?

The three MKVs have these sizes: 36MB, 31MB and 56MB
Concatenation with ffmpeg:
Code: [Select]
ffmpeg -f concat -safe 0 -i <(for i in ./title0[678].mkv; do echo "file '${PWD}/${i}'"; done) -map 0  -c:v copy -c:a copy titleall.mkv
The resulting file size is 123MB

Concatenation with MKVToolNIX (GUI):
Version 11.0, all settings application default.
The resulting file size is 79MB

I've converted both concatenated MKV files to MP4 (H264, AAC) and they are bit-identical.

All three source MKVs have the following two streams:
Code: [Select]
Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 4500 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
  • Last Edit: 17 June, 2017, 05:30:54 PM by SludgeVohaul

  • dutch109
  • [*][*][*]
Re: Concat MKVs; great differences in size with ffmpeg and MKVToolNIX
Reply #1
Anything noteworthy in FFmpeg's output?

I'd suggest opening a ticket in FFmpeg's bug tracker since MKVToolNix can make a smaller file without altering the streams.
Opus 96 kb/s (Android) / Vorbis -q5 (PC) / WavPack -hhx6m (Archive)
Developer of r128gain, SACAD and https://playnoise.com/

  • probedb
  • [*][*][*][*][*]
Re: Concat MKVs; great differences in size with ffmpeg and MKVToolNIX
Reply #2
Intriguing. Looking at the original filesizes then ffmpeg file is approx correct, I'm not sure how mkvtoolnix can remove 44MB?

Re: Concat MKVs; great differences in size with ffmpeg and MKVToolNIX
Reply #3
Nope. Everything looks normal (at least to me).
ffmpeg output:
Code: [Select]
$ ffmpeg -f concat -safe 0 -i <(for i in ./title0[678].mkv; do echo "file '${PWD}/${i}'"; done) -map 0  -c:v copy -c:a copy titleall.mkv
ffmpeg version N-46247-g017a68e8f Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-017a68e --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-indev=qtkit --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libavresample   3.  6.  0 /  3.  6.  0
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, concat, from '/dev/fd/63':
  Duration: N/A, start: 0.000000, bitrate: 4692 kb/s
    Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 4500 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Metadata:
      BPS-eng         : 4500000
      DURATION-eng    : 00:01:03.920000000
      NUMBER_OF_FRAMES-eng: 1598
      NUMBER_OF_BYTES-eng: 35955000
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.5 darwin(x86-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-06-16 21:12:55
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 00:01:03.904000000
      NUMBER_OF_FRAMES-eng: 1997
      NUMBER_OF_BYTES-eng: 1533696
      SOURCE_ID-eng   : 0180BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.5 darwin(x86-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-06-16 21:12:55
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Output #0, matroska, to 'titleall.mkv':
  Metadata:
    encoder         : Lavf57.72.101
    Stream #0:0(eng): Video: mpeg2video (Main) (mpg2 / 0x3267706D), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], q=2-31, 4500 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Metadata:
      BPS-eng         : 4500000
      DURATION-eng    : 00:01:03.920000000
      NUMBER_OF_FRAMES-eng: 1598
      NUMBER_OF_BYTES-eng: 35955000
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.5 darwin(x86-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-06-16 21:12:55
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 00:01:03.904000000
      NUMBER_OF_FRAMES-eng: 1997
      NUMBER_OF_BYTES-eng: 1533696
      SOURCE_ID-eng   : 0180BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.10.5 darwin(x86-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-06-16 21:12:55
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 5500 fps=0.0 q=-1.0 Lsize=  126132kB time=00:03:39.98 bitrate=4697.0kbits/s speed= 229x   
video:120868kB audio:5156kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.085203%


MKVToolNix output:
Code: [Select]
--- Output of job 'Multiplexing to file "title06 (1).mkv" in directory "/Users/mn/work"' started on 2017-06-19 22:22:14 ---
mkvmerge v11.0.0 ('Alive') 64bit
'/Users/mn/work/title06.mkv': Using the demultiplexer for the format 'Matroska'.
'/Users/mn/work/title07.mkv': Using the demultiplexer for the format 'Matroska'.
'/Users/mn/work/title08.mkv': Using the demultiplexer for the format 'Matroska'.
'/Users/mn/work/title06.mkv' track 0: Using the output module for the format 'MPEG-1/2'.
'/Users/mn/work/title06.mkv' track 1: Using the output module for the format 'AC-3'.
'/Users/mn/work/title07.mkv' track 0: Using the output module for the format 'MPEG-1/2'.
'/Users/mn/work/title07.mkv' track 1: Using the output module for the format 'AC-3'.
'/Users/mn/work/title08.mkv' track 0: Using the output module for the format 'MPEG-1/2'.
'/Users/mn/work/title08.mkv' track 1: Using the output module for the format 'AC-3'.
The file '/Users/mn/work/title06 (1).mkv' has been opened for writing.
Appending track 1 from file no. 1 ('/Users/mn/work/title07.mkv') to track 1 from file no. 0 ('/Users/mn/work/title06.mkv').
Appending track 0 from file no. 1 ('/Users/mn/work/title07.mkv') to track 0 from file no. 0 ('/Users/mn/work/title06.mkv').
Appending track 0 from file no. 2 ('/Users/mn/work/title08.mkv') to track 0 from file no. 1 ('/Users/mn/work/title07.mkv').
Appending track 1 from file no. 2 ('/Users/mn/work/title08.mkv') to track 1 from file no. 1 ('/Users/mn/work/title07.mkv').
The cue entries (the index) are being written...
Multiplexing took 1 second.

ffprobe output of the MKVToolNIX concatenated file (with metadata removed):
Code: [Select]
$ ffprobe titleall_no_meta.mkv 
ffprobe version N-46247-g017a68e8f Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-017a68e --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-indev=qtkit --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libavresample   3.  6.  0 /  3.  6.  0
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, matroska,webm, from 'titleall_no_meta.mkv':
  Metadata:
    ENCODER         : Lavf57.72.101
  Duration: 00:03:40.02, start: 0.000000, bitrate: 3021 kb/s
    Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 4500 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
    Metadata:
      DURATION        : 00:03:40.000000000
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      DURATION        : 00:03:40.016000000

ffprobe output of the ffmpeg concatenated file (with metadata removed):
Code: [Select]
$ ffprobe titleall_no_meta.mkv 
ffprobe version N-46247-g017a68e8f Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-017a68e --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-indev=qtkit --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libavresample   3.  6.  0 /  3.  6.  0
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, matroska,webm, from 'titleall_no_meta.mkv':
  Metadata:
    ENCODER         : Lavf57.72.101
  Duration: 00:03:40.02, start: 0.000000, bitrate: 4696 kb/s
    Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 4500 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      DURATION        : 00:03:40.000000000
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      DURATION        : 00:03:40.016000000

There is a difference in the two ffprobe outputs:
For the MKVToolNIX concatenated file ffprobe says "bitrate: 3021 kb/s" and for the ffmpeg concatenated file "bitrate: 4696 kb/s".
I haven't noticed this earlier, and to be honest I have no idea what it means (what is this value compared to the "4500 kb/s" in the stream?)
Regarding the duration of the concatenation (1s), I doubt that the video streams were reencoded on my Macbook Pro Late 2011...
  • Last Edit: 19 June, 2017, 05:07:22 PM by SludgeVohaul