[FFmpeg-user] Bug in I-Frame Retrieval?
Zbigniew Zdziarski
zdziarze at cs.tcd.ie
Wed Jul 16 15:16:03 CEST 2014
On 14-07-2014 18:40, Zbigniew Zdziarski wrote:
> On 14-07-2014 14:29, Zbigniew Zdziarski wrote:
>> Hello,
>>
>> I'm trying to extract I frames from mpeg files but I've noticed
>> something weird happening. The frames that are saved in my folder by
>> ffmpeg do not match the frames marked as I frames either by ffprobe
>> or
>> ffmpeg with parameter "-loglevel debug".
>>
>> The command I'm using is the following:
>>
>> ffmpeg -i C:\vid1.mp4 -vf select='eq(pict_type\,I)' -vsync 0
>> C:\%03d.jpg -loglevel debug 2> vid1.txt
>>
>> For some videos, the first few frames saved are correct. For some
>> videos, all but the first frame are incorrectly saved.
>>
>> Is my command incorrect or is there a bug???
>>
>> Cheers,
>> Zig
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
>
>
> I did some more digging around and found that this problem doesn't
> occur for all videos. E.g. the last 2 frames
> saved by the command above for the following video are different to
> those marked as being I-frames:
> https://www.scss.tcd.ie/~zdziarze/vid1.mp4
>
> But all works fine for this video:
> https://www.scss.tcd.ie/~zdziarze/vid6.mp4
>
>
> Cheers,
> Zig
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Ok, so I've done so more digging around and I've found the root of the
problem. When you run the following command:
ffmpeg -i vid3.mp4 -vf showinfo -f null - 2> vid3_info.txt
you can see that there are TWO frame rates for a video: input frame
rate and output frame rate. When you view the frame rate of a video
while it's playing via, say, VLC, the frame rate displayed is the input
one. But when you try to extract the frames, ffmpeg uses the output
frame rate so you get a different amount of frames being extracted.
That's some weird stuff! But thankfully I've worked it out. Phew.
Here's the command to use if you want to keep the frame rate the same
as the input frame rate:
ffmpeg -i vid3.mp4 -vf select='1',setpts='N/([OUTPUT_FRAME_RATE]*TB)'
%04d.png
(replace [OUTPUT_FRAME_RATE] with the output frame rate displayed in
the info given with "showinfo" (from command above)).
Zig
More information about the ffmpeg-user
mailing list