Using command line only, how to I retrieve the exact number of frames in a given video in Linux?
ffmpeg will return the duration in minutes and the framerate but duration*framerate does not give an exact number of frames.
I need to know the exact number of frames.
Tags: Command, Exact, Frames, Given, Line, Linux, Number, Only, Retrieve, Using, video
Write a command-line program to return the number of frames and run it from the command line.
mplayer -identify -fps 1 VIDEOFILE
Then look at
ID_VIDEO_FPS=1. 000
ID_VIDEO_ASPECT=0. 0000
ID_AUDIO_FORMAT=80
ID_AUDIO_BITRATE=224000
ID_AUDIO_RATE=0
ID_AUDIO_NCH=0
ID_LENGTH=41819. 00
Notice how the length, in seconds, is now the exact number of frames. (41819 frames)
If you need it to be interactive-less:
mplayer -msglevel all=0 -identify -fps 1 -vo null -frames 0 VIDEOFILE | grep ID_LENGTH
Or, for a program:
mplayer -identify -fps 1 -vo null -frames 0 -msglevel all=-1 VIDEO > moviedata
then to get the frame info:
grep ID_LENGTH moviedata
should do.
Thanks for that, now I know how to do it too!
~Purr