1

According to Matroska options , the muxer writes the index at the end of file by default. However, if I save incomplete mkv file while encoding and compare it with the final clip, I can see more than 2 differences in 2 files:

incomplete vs complete

This is not wanted. How to prevent it? I know ffmpeg won't be able to rewrite the file, if the output file is a pipe, but what if I cannot use pipes? (when I need to split the output and using -f segment)

To reproduce using ffmpeg's testsrc:

$ >after.mkv; tail -c +1 -F after.mkv >before.mkv & ffmpeg -y -f lavfi -i testsrc=s=720x576:r=12.5:d=120 after.mkv; sleep 3 ; kill $!

Full output:

[1] 6148
ffmpeg version N-72058-g3ecc063 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 38.100 / 56. 38.100
  libavformat    56. 33.100 / 56. 33.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, lavfi, from 'testsrc=s=720x576:r=12.5:d=120':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 720x576 [SAR 1:1 DAR 5:4], 12.50 tbr, 12.50 tbn, 12.50 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 00000000006bdce0] using SAR=1/1
[libx264 @ 00000000006bdce0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 00000000006bdce0] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
[libx264 @ 00000000006bdce0] 264 - core 146 r2538 121396c - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=12 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'after.mkv':
  Metadata:
    encoder         : Lavf56.33.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 720x576 [SAR 1:1 DAR 5:4], q=-1--1, 12.50 fps, 1k tbn, 12.50 tbc
    Metadata:
      encoder         : Lavc56.38.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 1500 fps=231 q=-1.0 Lsize=     575kB time=00:01:59.84 bitrate=  39.3kbits/s
video:564kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.994470%
[libx264 @ 00000000006bdce0] frame I:6     Avg QP:13.21  size:  8126
[libx264 @ 00000000006bdce0] frame P:750   Avg QP:10.61  size:   570
[libx264 @ 00000000006bdce0] frame B:744   Avg QP:11.90  size:   136
[libx264 @ 00000000006bdce0] consecutive B-frames:  0.8% 99.2%  0.0%  0.0%
[libx264 @ 00000000006bdce0] mb I  I16..4: 52.0% 37.3% 10.7%
[libx264 @ 00000000006bdce0] mb P  I16..4:  1.6%  1.3%  0.1%  P16..4:  3.7%  0.9%  0.6%  0.0%  0.0%    skip:91.7%
[libx264 @ 00000000006bdce0] mb B  I16..4:  0.2%  0.8%  0.0%  B16..8:  3.0%  0.2%  0.0%  direct: 0.0%  skip:95.8%  L0:49.5% L1:48.3% BI: 2.2%
[libx264 @ 00000000006bdce0] 8x8 transform intra:49.4% inter:82.8%
[libx264 @ 00000000006bdce0] coded y,u,v intra: 2.6% 1.6% 1.9% inter: 0.2% 0.2% 0.2%
[libx264 @ 00000000006bdce0] i16 v,h,dc,p: 68% 24%  2%  7%
[libx264 @ 00000000006bdce0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 79%  2% 19%  0%  0%  0%  0%  0%  0%
[libx264 @ 00000000006bdce0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46% 35% 15%  1%  1%  1%  0%  1%  0%
[libx264 @ 00000000006bdce0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000006bdce0] ref P L0: 68.2%  2.4% 17.6% 11.8%
[libx264 @ 00000000006bdce0] ref B L0: 59.1% 40.9%
[libx264 @ 00000000006bdce0] kb/s:38.46
[1]+  Terminated              tail -c +1 -F after.mkv > before.mkv
2
  • How can this be duplicated? What is your ffmpeg command and complete console output?
    – llogan
    Commented Oct 2, 2015 at 4:26
  • @LordNeckbeard updated the question
    – basin
    Commented Oct 2, 2015 at 8:35

0

Your Answer

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

Browse other questions tagged or ask your own question.