[FFmpeg-user] How can I get a duration and fps of any video that corresponds with the number of frames that can be read?
Carl Zwanzig
cpz at tuunq.com
Wed Aug 5 21:02:18 EEST 2020
On 8/5/2020 9:52 AM, Tom Burrows via ffmpeg-user wrote:
> I need to get the duration of any video file such that when multiplied
> with the media's fps value (in this case, either ’tbr’ or ‘fps'), it
> equals the number of frames in the video.
That works until you find a variable frame-rate video. I have found that to
get a truly accurate duration or frame-count, you have to effectively render
the entire file, even if to /dev/null. It does take (much) longer, but it's
not really a re-encode, just a copy.
A prime example of this is an mp2 pulled out of a dvd vob- I've seen a lot
of cases where the metadata info is wildly wrong* or that parts of the video
change between 24 fps and 29.97, there's also the 3:2 pulldown flag....
*duration 00:46:13 on a 90 minute movie? I think not.
AFAICT, no video tool has solved this without running the entire stream. You
might take one approach for fixed-rate containers/encodings and another for
variable-rate.
Later,
z!
More information about the ffmpeg-user
mailing list