I have a video file that I am trying to read. I believe the video format is MPEG-2 and the tool I'm reading it with is MATLAB's VideoReader, which has trouble with the frame indexing: if I use VideoReader to count all the frames in the file, it gives a different answer each time. The problem might occur because the file has a variable frame rate. Can a MPEG-2 file have a variable frame rate? Is there a better command-line tool that will allow me to accurately count frames, extract a frame given the frame index that I specify, and tell me the time stamp of the extracted frame?
I would appear that MPEG2 does support variable framerate, though I would expect any tool supporting MPEG2 to support that too.
For getting the total number of frames This solution may help.