Why different frame count on ffprobe?

1

Question

I use ffmpeg. Why are the frame counts different between A_COMAND and B_COMAND?

sample_gif

A_COMAND:

$ ffmpeg -i ./for_sample.gif -vf mpdecimate,setpts=N/FRAME_RATE/TB ./tmp/%1d.png

can see 80 frames on folder by extracting

B_COMMAND:

$ ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 ./for_sample.gif
[gif @ 0x7fbb87020a00] Invalid image height.
    Last message repeated 2 times
[gif @ 0x7fbb87020a00] Invalid image width.
85  Last message repeated 54 times

can see 85 frames on output

Actually, this gif sample has 143 frame count. But I want to output without duplicates so I can see that it won’t be 143 count.

version

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2)

macOS High Sierra 10.13.6

Thanks.

IkShibata

Posted 2019-08-30T06:09:58.703

Reputation: 11

Answers

2

The input does have 143 frames, but 58 frames have invalid metadata in the packet header, so the decoder discards these. That leaves 85 frames. These too have invalid metadata, but they're not fatal to the decoding operation.

If you run ffmpeg -i in.gif -f null -, you'll see the errors in the log like

[gif @ 00000000006af400] Invalid top position: 286.
Error while decoding stream #0:0: Invalid data found when processing input
[gif @ 00000000006af400] Invalid top position: 208.
Error while decoding stream #0:0: Invalid data found when processing input
...

and the non-fatal errors look like

[gif @ 00000000006af400] Image too wide by 116, truncating.
[gif @ 00000000006af400] Image too high by 131, truncating.

Gyan

Posted 2019-08-30T06:09:58.703

Reputation: 21 016