[FFmpeg-user] How to get video duration in a script using ffmpeg?

Carl Zwanzig cpz at tuunq.com
Wed Jan 19 20:07:46 EET 2022


On 1/19/2022 3:23 AM, Bo Berglund wrote:
> I have tried in various ways to limit the output of ffmpeg/ffprobe to the line
> holding the duration but it seems impossible...

Beware!

Depending on the source of a recording, I've found that various methods will 
report different values* for the duration, occasionally I've found some to 
be just plane wrong (below). It also appears that some formats tend to have 
more accurate durations than others, this is not a format problem per se, 
it's how people encode to that.

*from container metadata and from each stream, or calculated from a frame 
count and rate, for example-
Input #0, mpeg, from 'DonovansReef/DonovansReef.vob':
   Duration: 00:06:30.42, start: 0.187978, bitrate: 87549 kb/s

and MediaInfo reporting-
General/Duration                               : 6 min 30 s
Video/Duration                                 : 346 ms
Audio/Duration                                 : 6 min 30 s
(should be about 1:49:xx)

vob files, especially those with 3:2 pulldown, seem bad for this.


This may not be an issue for Bo, but could be for someone else finding this 
thread.

Later,

z!


More information about the ffmpeg-user mailing list