#472 closed defect (fixed)
Initial gray frames when first frame is no keyframe
Reported by: | DonMoir | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | git-master | Keywords: | roundup flv |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
I think maybe this has been discussed before, but if there is no initial keyframe then gray frames are produced. This happens often enough that it needs a solution. What I currently do in my application is I don't display anything until I get one initial keyframe and this seems to fix it well and easy.
A couple possible solutions for ffmpeg might be:
o - Assume the first keyframe is all black if there is no initial keyframe
o - In avcodec_decode_video2 maybe got_picture_ptr should not be set until a first keyframe is received.
I believe a related discussion is here:
https://roundup.libav.org/issue2019
This file is pretty bad and probably a worst case. I have a few others where is its much cleaner but still initially gray.
Attachments (2)
Change History (10)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
I don't know what the best solution is but clearly you do not want garbage to be displayed. This is not specific to H264. Now you have me wondering if my approach will fail on some clean videos with no keyframe.
I consider this to be a bug and not a feature request. If you want another sample where the video is fine but initially gray I will upload it. A bug in the video file ? Probably. But as I said it tends to happen more often then it should so at least need some descent work around and it seems the only way is what I have already. This seems to happen only with ffmpeg based apps. If for example I use some other means like DShow and installed codecs, the gray frames do not appear and I assume this problem is worked around in the various codecs.
comment:3 by , 13 years ago
This FLV file is much cleaner but still has an initial gray frame when played with ffplay since there is no first keyframe. Flash plays it without the initial gray frame.
http://sms.pangolin.com/temp/trains.flv (14 MB)
In all cases that I have tried where this is a problem, my current workaround works but not sure if its going to handle all cases.
by , 13 years ago
Attachment: | trains_cut.flv added |
---|
comment:4 by , 13 years ago
Reproduced by developer: | set |
---|---|
Status: | new → open |
Version: | unspecified → git-master |
mplayer trains_cut.flv shows no initial gray frames.
$ ffmpeg -i trains_cut.flv -qscale 2 out.avi ffmpeg version N-32617-ge78d1a5, Copyright (c) 2000-2011 the FFmpeg developers built on Sep 15 2011 23:18:20 with gcc 4.5.3 configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc --enable-gpl --enable-version2 libavutil 51. 16. 0 / 51. 16. 0 libavcodec 53. 15. 0 / 53. 15. 0 libavformat 53. 12. 0 / 53. 12. 0 libavdevice 53. 3. 0 / 53. 3. 0 libavfilter 2. 40. 0 / 2. 40. 0 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 [flv @ 0x1301760] warning: first frame is no keyframe Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1) Input #0, flv, from 'trains_cut.flv': Metadata: audiodatarate : 64 framerate : 25 datasize : 14613960 lasttimestamp : 212960 audiosize : 1802309 videosize : 12811397 metadatacreator : inlet media - FLVTool2 height : 480 filesize : 14667897 videodatarate : 479 duration : 213 encoder : Riva FLV Encoder width : 640 Duration: 00:03:33.00, start: 0.000000, bitrate: 78 kb/s Stream #0.0: Video: flv1, yuv420p, 640x480, 490 kb/s, 25 tbr, 1k tbn, 1k tbc Stream #0.1: Audio: mp3, 44100 Hz, mono, s16, 64 kb/s [buffer @ 0x1306ec0] w:640 h:480 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param: Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt' Output #0, avi, to 'out.avi': Metadata: audiodatarate : 64 framerate : 25 datasize : 14613960 lasttimestamp : 212960 audiosize : 1802309 videosize : 12811397 metadatacreator : inlet media - FLVTool2 height : 480 filesize : 14667897 videodatarate : 479 duration : 213 width : 640 ISFT : Lavf53.12.0 Stream #0.0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480, q=2-31, 200 kb/s, 25 tbn, 25 tbc Stream #0.1: Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, mono, flt, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 (flv -> mpeg4) Stream #0.1 -> #0.1 (mp3 -> ac3) Press [q] to stop, [?] for help [flv @ 0x1301760] warning: first frame is no keyframe [flv @ 0x1301760] Error at MB: 567 3912kB time=00:00:24.31 bitrate=1318.1kbits/s [flv @ 0x1301760] concealing 698 DC, 698 AC, 698 MV errors frame= 646 fps=396 q=2.0 Lsize= 4404kB time=00:00:25.87 bitrate=1394.1kbits/s video:3957kB audio:404kB global headers:0kB muxing overhead 0.975746%
by , 13 years ago
Attachment: | PIR-short.mkv added |
---|
22 second periodic intra refresh sample that has non-zero recovery_frame_cnt's.
comment:5 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
I cannot reproduce any issues after the last commits so i think this is fixed
comment:6 by , 13 years ago
I still get an initial gray frame with trains_cut.flv.
In my app using ffmpeg-HEAD-9be937d still occurs.
Using ffplay with the following details:
C:\ffmpeg-dev\bin>ffplay c:\flashfiles\trains_cut.flv
ffplay version N-33698-g6bca574, Copyright (c) 2003-2011 the FFmpeg developers
built on Oct 16 2011 13:35:21 with gcc 4.6.1
configuration: --disable-static --enable-shared --enable-gpl --enable-version3
--enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --e
nable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable
-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libsc
hroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-l
ibvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxa
vs --enable-libxvid --enable-zlib
libavutil 51. 21. 0 / 51. 21. 0
libavcodec 53. 20. 1 / 53. 20. 1
libavformat 53. 16. 0 / 53. 16. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 43. 6 / 2. 43. 6
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
[flv @ 011308E0] warning: first frame is no keyframe
Input #0, flv, from 'c:\flashfiles\trains_cut.flv':
Metadata:
datasize : 14613960
lasttimestamp : 212960
audiosize : 1802309
videosize : 12811397
metadatacreator : inlet media - FLVTool2
encoder : Riva FLV Encoder
Duration: 00:03:33.00, start: 0.000000, bitrate: 78 kb/s
Stream #0:0: Video: flv1, yuv420p, 640x480, 490 kb/s, 25 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: mp3, 44100 Hz, mono, s16, 64 kb/s
[flv @ 011308E0] warning: first frame is no keyframe5KB sq= 0B f=0/0
16.59 A-V: 0.099 s:0.0 aq= 99KB vq= 611KB sq= 0B f=0/0 f=0/0
comment:8 by , 12 years ago
Keywords: | roundup flv added |
---|
Invalid as-is.
Complete, uncut output missing.
And please be more specific about what you want to change. Since H264 streams do not have to contain keyframes to be valid, I would at least prefer not to change ffmpeg - the application - to always wait for keyframes.
(But perhaps this is not about H264?)
If this is a feature request for more complete H.264 Sequence Parameter Set parsing, please say so.