How do I get the number of frames in a video on the linux command line?
Problem
I have a video file and I want to get the number of video frames that are in it. I can use to get the length of the video and the FPS. However I can't see anything obvious for the total number of frames. In theory one should be able to multiply the length (in seconds) by the FPS to get the number of frames, but in this case the length (34.43 seconds) and the framerate (29.97 fps) give a non-integer, which makes me think I'm doing something wrong. I need to be able to do this on the command line in a totally automated and non-graphical manner. I also need this to be pretty exact, and not an estimate (if that's even possible with video files) I tried using on some files. For some AVI files it works, but for some VOB files, the tcprobe output doesn't have the number of frames. I get this output:
Error Output
[tcprobe] MPEG program stream (PS)
[tcprobe] summary for myfile.vob, (*) = not default, 0 = not detected
import frame size: -g 720x480 [720x576] (*)
aspect ratio: 4:3 (*)
frame rate: -f 29.970 [25.000] frc=4 (*)
PTS=2199.3972, frame_time=33ms bitrate=7000 kbps
a…Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How do I get the number of frames in a video on the linux command line?
can be used to get info about a media file: You will get details about the stream: Look for with : That works for avi, mp4 and etc For some containers, it does not show valid value e.g. mpeg. In that case, this works
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix