ffprobe
can be used to get info about a media file:
ffprobe -select_streams v -show_streams input.avi
You will get details about the stream:
nb_frames=159697
Look for nb_frames
with grep
:
ffprobe -select_streams v -show_streams input.avi 2>/dev/null | grep nb_frames | sed -e 's/nb_frames=//'
That works for avi, mp4 and etc For some containers, it does not show valid value e.g. mpeg.
In that case, this works ffprobe -show_packets a.mpg 2>/dev/null | grep video | wc -l