Opened 7 years ago
Last modified 6 years ago
#6386 new defect
Timebase is written as frame duration for mkv if framerate is unkown
Reported by: | fthiery | Owned by: | |
---|---|---|---|
Priority: | minor | Component: | avformat |
Version: | git-master | Keywords: | webm mkv |
Cc: | gajjanag@alum.mit.edu | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug: chromium and firefox browsers can create WebM media using MediaStreamRecorder; being live-generated, these media have no framerate in the webm header (as per specified in the spec: https://bugs.chromium.org/p/chromium/issues/detail?id=589561) nor correct duration information, making these media unseekable, but when remuxing the media (official chromium recommendation https://bugs.chromium.org/p/chromium/issues/detail?id=642012) ffmpeg falsely detects that the content is 1000 fps, then leading any subsequent transcodings to be effectively at 1000 fps.
How to reproduce:
# create a content with chromium (see attached test html -- needs to run over http, e.g. http://localhost/test_simple_record.html), download the video fragment
# remux using ffmpeg -i test.webm -c copy out.webm
# ffprobe out.webm reports 1000 fps
Firefox produced media do not have the issue, and the main difference seems to be that the EBML header from firefox has a zero duration instead of -1e-09
$ ffprobe -loglevel 56 test.webm ffprobe version 3.3 Copyright (c) 2007-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20170306 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-netcdf --enable-shared --enable-version3 libavutil 55. 58.100 / 55. 58.100 libavcodec 57. 89.100 / 57. 89.100 libavformat 57. 71.100 / 57. 71.100 libavdevice 57. 6.100 / 57. 6.100 libavfilter 6. 82.100 / 6. 82.100 libavresample 3. 5. 0 / 3. 5. 0 libswscale 4. 6.100 / 4. 6.100 libswresample 2. 7.100 / 2. 7.100 libpostproc 54. 5.100 / 54. 5.100 [file @ 0x562e987a1560] Setting default whitelist 'file,crypto' Probing matroska,webm score:100 size:2048 Probing mp3 score:1 size:2048 [matroska,webm @ 0x562e987a0d00] Format matroska,webm probed with size=2048 and score=100 st:0 removing common factor 1000000 from timebase st:1 removing common factor 1000000 from timebase [matroska,webm @ 0x562e987a0d00] Before avformat_find_stream_info() pos: 181 bytes read:32768 seeks:0 nb_streams:2 [matroska,webm @ 0x562e987a0d00] All info found [matroska,webm @ 0x562e987a0d00] stream 0: start_time: 0.060 duration: -9223372036854776.000 [matroska,webm @ 0x562e987a0d00] stream 1: start_time: 0.000 duration: -9223372036854776.000 [matroska,webm @ 0x562e987a0d00] format: start_time: 0.000 duration: -9223372036854.775 bitrate=0 kb/s [matroska,webm @ 0x562e987a0d00] After avformat_find_stream_info() pos: 217397 bytes read:229376 seeks:0 frames:68 Input #0, matroska,webm, from 'test.webm': Metadata: encoder : Chrome Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0(eng), 27, 1/1000: Audio: opus, 48000 Hz, mono, fltp (default) Stream #0:1(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default) [AVIOContext @ 0x562e987a98a0] Statistics: 229376 bytes read, 0 seeks $ ffmpeg -i test.webm -c copy out.webm ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20170306 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-netcdf --enable-shared --enable-version3 libavutil 55. 58.100 / 55. 58.100 libavcodec 57. 89.100 / 57. 89.100 libavformat 57. 71.100 / 57. 71.100 libavdevice 57. 6.100 / 57. 6.100 libavfilter 6. 82.100 / 6. 82.100 libavresample 3. 5. 0 / 3. 5. 0 libswscale 4. 6.100 / 4. 6.100 libswresample 2. 7.100 / 2. 7.100 libpostproc 54. 5.100 / 54. 5.100 Input #0, matroska,webm, from 'test.webm': Metadata: encoder : Chrome Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default) Stream #0:1(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default) File 'out.webm' already exists. Overwrite ? [y/N] y Output #0, webm, to 'out.webm': Metadata: encoder : Lavf57.71.100 Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 1k tbr, 1k tbn, 1k tbc (default) Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default) Stream mapping: Stream #0:1 -> #0:0 (copy) Stream #0:0 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 128 fps=0.0 q=-1.0 Lsize= 646kB time=00:00:04.92 bitrate=1075.0kbits/s speed= 914x video:643kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.300635% $ ffprobe -loglevel 56 out.webm ffprobe version 3.3 Copyright (c) 2007-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20170306 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-netcdf --enable-shared --enable-version3 libavutil 55. 58.100 / 55. 58.100 libavcodec 57. 89.100 / 57. 89.100 libavformat 57. 71.100 / 57. 71.100 libavdevice 57. 6.100 / 57. 6.100 libavfilter 6. 82.100 / 6. 82.100 libavresample 3. 5. 0 / 3. 5. 0 libswscale 4. 6.100 / 4. 6.100 libswresample 2. 7.100 / 2. 7.100 libpostproc 54. 5.100 / 54. 5.100 [file @ 0x5601fb87f560] Setting default whitelist 'file,crypto' Probing matroska,webm score:100 size:2048 Probing mp3 score:1 size:2048 [matroska,webm @ 0x5601fb87ed00] Format matroska,webm probed with size=2048 and score=100 st:0 removing common factor 1000000 from timebase st:1 removing common factor 1000000 from timebase [matroska,webm @ 0x5601fb87ed00] Before avformat_find_stream_info() pos: 517 bytes read:32768 seeks:0 nb_streams:2 [matroska,webm @ 0x5601fb87ed00] All info found [matroska,webm @ 0x5601fb87ed00] stream 0: start_time: 0.000 duration: -9223372036854776.000 [matroska,webm @ 0x5601fb87ed00] stream 1: start_time: 0.061 duration: -9223372036854776.000 [matroska,webm @ 0x5601fb87ed00] format: start_time: 0.000 duration: 4.980 bitrate=1062 kb/s [matroska,webm @ 0x5601fb87ed00] After avformat_find_stream_info() pos: 197613 bytes read:229376 seeks:0 frames:64 Input #0, matroska,webm, from 'out.webm': Metadata: encoder : Lavf57.71.100 Duration: 00:00:04.98, start: 0.000000, bitrate: 1062 kb/s Stream #0:0(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 1k fps, 1k tbr, 1k tbn, 1k tbc (default) Stream #0:1(eng), 23, 1/1000: Audio: opus, 48000 Hz, mono, fltp (default) [AVIOContext @ 0x5601fb8878a0] Statistics: 229376 bytes read, 0 seeks $ ./libwebm/webm_info -i test.webm EBML Header: EBMLVersion : 1 EBMLReadVersion : 1 EBMLMaxIDLength : 4 EBMLMaxSizeLength : 8 Doc Type : webm DocTypeVersion : 4 DocTypeReadVersion: 2 Segment: SegmentInfo: TimecodeScale : 1000000 Duration(secs): -1e-09 MuxingApp : Chrome WritingApp : Chrome Tracks: Track: TrackType : 2 TrackNumber : 1 CodecID : A_OPUS PrivateData(size): 19 Channels : 1 SamplingFrequency: 48000 Track: TrackType : 1 TrackNumber : 2 CodecID : V_VP8 PixelWidth : 640 PixelHeight : 480 $ ffprobe -loglevel 56 test_firefox.webm ffprobe version 3.3 Copyright (c) 2007-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20170306 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-netcdf --enable-shared --enable-version3 libavutil 55. 58.100 / 55. 58.100 libavcodec 57. 89.100 / 57. 89.100 libavformat 57. 71.100 / 57. 71.100 libavdevice 57. 6.100 / 57. 6.100 libavfilter 6. 82.100 / 6. 82.100 libavresample 3. 5. 0 / 3. 5. 0 libswscale 4. 6.100 / 4. 6.100 libswresample 2. 7.100 / 2. 7.100 libpostproc 54. 5.100 / 54. 5.100 [file @ 0x558fe2164560] Setting default whitelist 'file,crypto' Probing matroska,webm score:100 size:2048 Probing mp3 score:1 size:2048 [matroska,webm @ 0x558fe2163d00] Format matroska,webm probed with size=2048 and score=100 st:0 removing common factor 1000000 from timebase st:1 removing common factor 1000000 from timebase [matroska,webm @ 0x558fe2163d00] Before avformat_find_stream_info() pos: 317 bytes read:32768 seeks:0 nb_streams:2 [matroska,webm @ 0x558fe2163d00] All info found [matroska,webm @ 0x558fe2163d00] rfps: 24.666667 0.012426 [matroska,webm @ 0x558fe2163d00] rfps: 24.750000 0.005794 Last message repeated 1 times [matroska,webm @ 0x558fe2163d00] rfps: 24.833333 0.002149 Last message repeated 1 times [matroska,webm @ 0x558fe2163d00] rfps: 24.916667 0.001491 Last message repeated 1 times [matroska,webm @ 0x558fe2163d00] rfps: 25.000000 0.003819 [matroska,webm @ 0x558fe2163d00] rfps: 25.083333 0.009133 [matroska,webm @ 0x558fe2163d00] rfps: 25.166667 0.017434 [matroska,webm @ 0x558fe2163d00] rfps: 50.000000 0.015275 [matroska,webm @ 0x558fe2163d00] Setting avg frame rate based on r frame rate [matroska,webm @ 0x558fe2163d00] stream 0: start_time: 0.000 duration: -9223372036854776.000 [matroska,webm @ 0x558fe2163d00] stream 1: start_time: -0.001 duration: -9223372036854776.000 [matroska,webm @ 0x558fe2163d00] format: start_time: -0.001 duration: -9223372036854.775 bitrate=0 kb/s [matroska,webm @ 0x558fe2163d00] After avformat_find_stream_info() pos: 482653 bytes read:491520 seeks:0 frames:123 Input #0, matroska,webm, from 'test_firefox.webm': Metadata: encoder : QTmuxingAppLibWebM-0.0.1 Duration: N/A, start: -0.001000, bitrate: N/A Stream #0:0(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 24.92 fps, 24.92 tbr, 1k tbn, 1k tbc (default) Stream #0:1(eng), 82, 1/1000: Audio: opus, 48000 Hz, mono, fltp, delay 312 (default) [AVIOContext @ 0x558fe216c860] Statistics: 491520 bytes read, 0 seeks $ ./libwebm/webm_info -i test_firefox.webm EBML Header: EBMLVersion : 1 EBMLReadVersion : 1 EBMLMaxIDLength : 4 EBMLMaxSizeLength : 8 Doc Type : webm DocTypeVersion : 2 DocTypeReadVersion: 2 Segment: SegmentInfo: TimecodeScale : 1000000 Duration(secs): 0 MuxingApp : QTmuxingAppLibWebM-0.0.1 WritingApp : QTwritingAppLibWebM-0.0.1 Tracks: Track: TrackType : 1 TrackNumber : 1 CodecID : V_VP8 CodecName : VP8 PixelWidth : 640 PixelHeight : 480 Track: TrackType : 2 TrackNumber : 2 CodecID : A_OPUS CodecName : OPUS PrivateData(size): 19 Channels : 1 SamplingFrequency: 44100 CodecDelay : 6500000 SeekPreRoll : 80000000
Attachments (3)
Change History (13)
by , 7 years ago
Attachment: | test_simple_record.html added |
---|
comment:2 by , 7 years ago
Component: | undetermined → avformat |
---|---|
Keywords: | mkv added; framerate removed |
Priority: | normal → minor |
Version: | unspecified → git-master |
Feel free to test attached patch.
by , 7 years ago
Attachment: | 0001-lavf-matroskaenc-Never-write-timebase-as-default-fra.patch added |
---|
comment:3 by , 7 years ago
Summary: | WebM/VP8 created by chromium are incorrectly detected as 1000 fps by ffmpeg → Timebase is written as frame duration for mkv if framerate is unkown |
---|
comment:5 by , 7 years ago
Hi there; applied the patch; now when i ffprobe on the sample, the detected framerate seems to be 0 fps
$ ffprobe -loglevel 56 test_chrome.webm
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:1(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)
Unfortunately, when remuxing with ffmpeg -i test_chrome.webm -c copy out.webm, the duration is now correct, but transcoding (ffmpeg -i out.webm out.mp4) still results in a 1000 fps output.
$ ffprobe -loglevel 56 out.webm
Duration: 00:00:04.98, start: 0.000000, bitrate: 1037 kb/s
Stream #0:0(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)
$ ffmpeg -i out.webm test.mp4
Metadata:
encoder : Lavf57.71.100
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 1k fps, 16k tbn, 1k tbc (default)
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, mono, fltp, 69 kb/s (default)
Metadata:
encoder : Lavc57.89.100 aac
More than 1000 frames duplicated 227kB time=00:00:01.08 bitrate=1716.0kbits/s dup=783 drop=0 speed=0.961x
comment:8 by , 7 years ago
Not sure if commenting like this helps but I'm running into this same issue in the same exact situation (MediaRecorder on Chrome/Webm). Adding -fflags +genpts
before the offending webm input solves it for me.
comment:9 by , 7 years ago
-fflags +genpts not working for me, ffmpeg still duplicating frames by the thousands.
$ ffmpeg -fflags +genpts -i input.webm output.mp4 ... Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2049 kb/s, 1k fps, 1k tbr, 16k tbn, 2k tbc (default)
@kicco what am i doing wrong ?
comment:10 by , 6 years ago
Cc: | added |
---|
html test recorder