I'm trying to count the number of frames in a video but ffmpeg and ffprobe are giving me two different answers.
$ time ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 myvideo.mp4
2858
real 0m2.987s
user 0m2.740s
sys 0m0.172s
When I check the same file with ffmpeg I get 2 more frames...
$ time ffmpeg -y -i myvideo.mp4 -vcodec copy -acodec copy -f null /dev/null 2>&1 | grep 'frame=' | awk '{print $2}'
2860
real 0m0.127s
user 0m0.080s
sys 0m0.032s
I used ffprobe to output all of the frames and count the number of "[FRAME]"s in the resultant output...
ffprobe -i myvideo.mp4 -show_frames -v error | grep -o '\[FRAME\]' | wc -l
2858
Which as you can see shows the number ffprobe thought there were.
Obviously I would prefer to use ffmpeg here because it is significantly faster than ffprobe and I am dealing with thousands of videos that need parsing and indexing. However the failure isn't consistent across multiple videos; sometimes it's 1 out, other times it's 2 or more...
Unfortunately, I have been counting frames for the past two years using the ffmpeg method, so I have a significant library of videos to reprocess now ... he gulps... I guess its a good way to verify the readability of the files on the cluster... even so, its going to take probably a few weeks to recalculate all of the existing video frame sizes.