[FFmpeg-trac] #8109(undetermined:new): Long loading delay for VfW codecs in Matroska
FFmpeg
trac at avcodec.org
Mon Sep 2 19:45:27 EEST 2019
#8109: Long loading delay for VfW codecs in Matroska
-------------------------------------+-------------------------------------
Reporter: Austin | Type: defect
Status: new | Priority: normal
Component: | Version: git-
undetermined | master
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Greetings,
I notice a very long loading/parsing delay (20+ seconds) in what appears
to be the Matroska decoder when referencing MKV video files that are
longer than 30 minutes in length.
'''Steps to reproduce:'''
'''1)''' Create one hour video files for testing using the attached
640x360 image (~8 GB each):
{{{
ffmpeg -loop true -i "MKVTest_640x360.bmp" -t 3600 -c:v utvideo -an -sn
-dn -f avi -y "MKVTest.avi"
}}}
{{{
ffmpeg -loop true -i "MKVTest_640x360.bmp" -t 3600 -c:v utvideo -an -sn
-dn -f mov -y "MKVTest.mov"
}}}
{{{
ffmpeg -loop true -i "MKVTest_640x360.bmp" -t 3600 -c:v utvideo -an -sn
-dn -f matroska -write_crc32 false -y "MKVTest.mkv"
}}}
'''2)''' Stream copy a section of video that is 50 minutes into the test
files:
{{{
ffmpeg -ss 00:50:00.000 -i "MKVTest.avi" -t 1 -c copy -y "LoadAndSeek.avi"
}}}
{{{
ffmpeg -ss 00:50:00.000 -i "MKVTest.mov" -t 1 -c copy -y "LoadAndSeek.mov"
}}}
{{{
ffmpeg -ss 00:50:00.000 -i "MKVTest.mkv" -t 1 -c copy -y "LoadAndSeek.mkv"
}}}
'''Output Observations:'''
The AVI and MOV files are able to stream copy instantly. The MKV file
stalls for 20 seconds before transcoding begins.
'''Other Observations:'''
HuffYUV and MagicYUV are also affected by slow Matroska loading and
playback. FFmpeg appears to be creating a MOV file wrapped by Matroska
when using Video for Windows lossless codecs. If those codecs are written
directly to a MOV file, load and playback are instant. Adding the
Matroska wrapper is what appears to slow things down. My assumption is
that the Matroska decoder in ffmpeg is the problem because non-ffmpeg
media players like MPC-BE are able to instantly play back and seek the MKV
file generated by ffmpeg. This suggests the ffmpeg encoder and Matroska
file format are performing as expected, and the problem is contained to
the ffmpeg decoder.
'''Why this bug is significant:'''
For video editors that are built on top of ffmpeg (like Shotcut and
Kdenlive), the long loading time ripples up to the editor and makes
opening a project take a very long time. Playback and seeking are
extremely slow for videos longer than 30 minutes, meaning the MKV format
is unusable for editing biking videos, wedding event capture, surveillance
video, etc.
Matroska is an important format because it retains color space and color
range metadata for lossless VfW codecs. AVI retains neither, and MOV
doesn't have an official color range flag. I'm not aware of any
alternative containers for VfW codecs that capture all color metadata, so
getting ffmpeg to decode Matroska at the same speed as MPC-BE or a native
MOV file would be of great benefit to the libre video editing world. The
lossless VfW codecs are popular for proxy editing due to their speed and
color accuracy.
Thank you in advance for anything you can find.
-Austin
'''Uncut console output is as follows:'''
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg
developers
built with gcc 9.1.1 (GCC) 20190807
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-
fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-
libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr
--enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2
--enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa
--enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx
--enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-
nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 33.100 / 56. 33.100
libavcodec 58. 55.101 / 58. 55.101
libavformat 58. 31.104 / 58. 31.104
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.101 / 7. 58.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.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 '-ss' ... matched as option 'ss' (set the start time
offset) with argument '00:50:00.000'.
Reading option '-i' ... matched as input url with argument 'MKVTest.mkv'.
Reading option '-t' ... matched as option 't' (record or transcode
"duration" seconds of audio/video) with argument '1'.
Reading option '-c' ... matched as option 'c' (codec name) with argument
'copy'.
Reading option '-y' ... matched as option 'y' (overwrite output files)
with argument '1'.
Reading option 'LoadAndSeek.mkv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url MKVTest.mkv.
Applying option ss (set the start time offset) with argument 00:50:00.000.
Successfully parsed a group of options.
Opening an input file: MKVTest.mkv.
[NULL @ 0000000000460840] Opening 'MKVTest.mkv' for reading
[file @ 0000000000462100] Setting default whitelist 'file,crypto'
Probing matroska,webm score:100 size:2048
Probing mp3 score:1 size:2048
[matroska,webm @ 0000000000460840] Format matroska,webm probed with
size=2048 and score=100
st:0 removing common factor 1000000 from timebase
[matroska,webm @ 0000000000460840] Before avformat_find_stream_info() pos:
697 bytes read:32768 seeks:0 nb_streams:1
[matroska,webm @ 0000000000460840] parser not found for codec utvideo,
packets or times may be invalid.
[utvideo @ 000000000046a4c0] Encoder version 1.0.0.240
[utvideo @ 000000000046a4c0] Original format 118
[utvideo @ 000000000046a4c0] Encoding parameters 02000001
[matroska,webm @ 0000000000460840] parser not found for codec utvideo,
packets or times may be invalid.
[matroska,webm @ 0000000000460840] All info found
[matroska,webm @ 0000000000460840] stream 0: start_time: 0.000 duration:
-9223372036854776.000
[matroska,webm @ 0000000000460840] format: start_time: 0.000 duration:
3600.000 bitrate=18374 kb/s
[matroska,webm @ 0000000000460840] After avformat_find_stream_info() pos:
92543 bytes read:92543 seeks:0 frames:1
Input #0, matroska,webm, from 'MKVTest.mkv':
Metadata:
ENCODER : Lavf58.29.100
Duration: 01:00:00.00, start: 0.000000, bitrate: 18374 kb/s
Stream #0:0, 1, 1/1000: Video: utvideo, 1 reference frame (ULRG /
0x47524C55), gbrp, 640x360, 0/1, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
Metadata:
ENCODER : Lavc58.54.100 utvideo
DURATION : 01:00:00.000000000
Successfully opened the file.
Parsing a group of options: output url LoadAndSeek.mkv.
Applying option t (record or transcode "duration" seconds of audio/video)
with argument 1.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: LoadAndSeek.mkv.
[file @ 000000000301be00] Setting default whitelist 'file,crypto'
Successfully opened the file.
[matroska @ 000000000288b400] get_metadata_duration returned: 3600000000
[matroska @ 000000000288b400] Write early duration from recording time =
1000
Output #0, matroska, to 'LoadAndSeek.mkv':
Metadata:
encoder : Lavf58.31.104
Stream #0:0, 0, 1/1000: Video: utvideo, 1 reference frame (ULRG /
0x47524C55), gbrp, 640x360 (0x0), 0/1, q=2-31, 25 fps, 25 tbr, 1k tbn, 1k
tbc (default)
Metadata:
ENCODER : Lavc58.54.100 utvideo
DURATION : 01:00:00.000000000
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)
[matroska @ 000000000288b400] Writing block of size 91832 with pts 0, dts
0, duration 40 at relative offset 9 in cluster at offset 711. TrackNumber
1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 92567 bytes,
pts 40, dts 40
[matroska @ 000000000288b400] Writing block of size 91832 with pts 40, dts
40, duration 40 at relative offset 9 in cluster at offset 92567.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 184423 bytes,
pts 80, dts 80
[matroska @ 000000000288b400] Writing block of size 91832 with pts 80, dts
80, duration 40 at relative offset 9 in cluster at offset 184423.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 276279 bytes,
pts 120, dts 120
[matroska @ 000000000288b400] Writing block of size 91832 with pts 120,
dts 120, duration 40 at relative offset 9 in cluster at offset 276279.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 368135 bytes,
pts 160, dts 160
[matroska @ 000000000288b400] Writing block of size 91832 with pts 160,
dts 160, duration 40 at relative offset 9 in cluster at offset 368135.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 459991 bytes,
pts 200, dts 200
[matroska @ 000000000288b400] Writing block of size 91832 with pts 200,
dts 200, duration 40 at relative offset 9 in cluster at offset 459991.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 551847 bytes,
pts 240, dts 240
[matroska @ 000000000288b400] Writing block of size 91832 with pts 240,
dts 240, duration 40 at relative offset 9 in cluster at offset 551847.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 643703 bytes,
pts 280, dts 280
[matroska @ 000000000288b400] Writing block of size 91832 with pts 280,
dts 280, duration 40 at relative offset 10 in cluster at offset 643703.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 735560 bytes,
pts 320, dts 320
[matroska @ 000000000288b400] Writing block of size 91832 with pts 320,
dts 320, duration 40 at relative offset 10 in cluster at offset 735560.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 827417 bytes,
pts 360, dts 360
[matroska @ 000000000288b400] Writing block of size 91832 with pts 360,
dts 360, duration 40 at relative offset 10 in cluster at offset 827417.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 919274 bytes,
pts 400, dts 400
[matroska @ 000000000288b400] Writing block of size 91832 with pts 400,
dts 400, duration 40 at relative offset 10 in cluster at offset 919274.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1011131
bytes, pts 440, dts 440
[matroska @ 000000000288b400] Writing block of size 91832 with pts 440,
dts 440, duration 40 at relative offset 10 in cluster at offset 1011131.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1102988
bytes, pts 480, dts 480
[matroska @ 000000000288b400] Writing block of size 91832 with pts 480,
dts 480, duration 40 at relative offset 10 in cluster at offset 1102988.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1194845
bytes, pts 520, dts 520
[matroska @ 000000000288b400] Writing block of size 91832 with pts 520,
dts 520, duration 40 at relative offset 10 in cluster at offset 1194845.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1286702
bytes, pts 560, dts 560
[matroska @ 000000000288b400] Writing block of size 91832 with pts 560,
dts 560, duration 40 at relative offset 10 in cluster at offset 1286702.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1378559
bytes, pts 600, dts 600
[matroska @ 000000000288b400] Writing block of size 91832 with pts 600,
dts 600, duration 40 at relative offset 10 in cluster at offset 1378559.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1470416
bytes, pts 640, dts 640
[matroska @ 000000000288b400] Writing block of size 91832 with pts 640,
dts 640, duration 40 at relative offset 10 in cluster at offset 1470416.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1562273
bytes, pts 680, dts 680
[matroska @ 000000000288b400] Writing block of size 91832 with pts 680,
dts 680, duration 40 at relative offset 10 in cluster at offset 1562273.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1654130
bytes, pts 720, dts 720
[matroska @ 000000000288b400] Writing block of size 91832 with pts 720,
dts 720, duration 40 at relative offset 10 in cluster at offset 1654130.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1745987
bytes, pts 760, dts 760
[matroska @ 000000000288b400] Writing block of size 91832 with pts 760,
dts 760, duration 40 at relative offset 10 in cluster at offset 1745987.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1837844
bytes, pts 800, dts 800
[matroska @ 000000000288b400] Writing block of size 91832 with pts 800,
dts 800, duration 40 at relative offset 10 in cluster at offset 1837844.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 1929701
bytes, pts 840, dts 840
[matroska @ 000000000288b400] Writing block of size 91832 with pts 840,
dts 840, duration 40 at relative offset 10 in cluster at offset 1929701.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 2021558
bytes, pts 880, dts 880
[matroska @ 000000000288b400] Writing block of size 91832 with pts 880,
dts 880, duration 40 at relative offset 10 in cluster at offset 2021558.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 2113415
bytes, pts 920, dts 920
[matroska @ 000000000288b400] Writing block of size 91832 with pts 920,
dts 920, duration 40 at relative offset 10 in cluster at offset 2113415.
TrackNumber 1, keyframe 1
[matroska @ 000000000288b400] Starting new cluster at offset 2205272
bytes, pts 960, dts 960
[matroska @ 000000000288b400] Writing block of size 91832 with pts 960,
dts 960, duration 40 at relative offset 10 in cluster at offset 2205272.
TrackNumber 1, keyframe 1
No more output streams to write to, finishing.
[matroska @ 000000000288b400] end duration = 1000
[matroska @ 000000000288b400] stream 0 end duration = 1000
frame= 25 fps=0.0 q=-1.0 Lsize= 2244kB time=00:00:00.96
bitrate=19126.8kbits/s speed=96.1x
video:2242kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.078753%
Input file #0 (MKVTest.mkv):
Input stream #0:0 (video): 26 packets read (2387632 bytes);
Total: 26 packets (2387632 bytes) demuxed
Output file #0 (LoadAndSeek.mkv):
Output stream #0:0 (video): 25 packets muxed (2295800 bytes);
Total: 25 packets (2295800 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 000000000288f180] Statistics: 8 seeks, 31 writeouts
[AVIOContext @ 000000000046a380] Statistics: 4412112 bytes read, 3 seeks
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8109>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list