[FFmpeg-user] How to get audio and video duration in a media file?

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Apr 14 13:49:24 CEST 2015

Wesley Wen <delbin.wen <at> gmail.com> writes:

> We want to check source file to make sure audio 
> duration match video duration within 1 second. 
> So, the first thing we want to know is audio
> duration and video duration individually, and I 
> tried ffprobe cmd below.
> ffprobe -show_streams /tmp/video.ts

It is not possible to know the duration of a 
transport stream without reading the whole file.

One possibility to know the duration of audio 
and video is:
$ ffmpeg -i video.ts -vcodec copy -an -f null -
$ ffmpeg -i video.ts -acodec copy -vn -f null -
The console output of the commands show the 
actual duration.

Carl Eugen

More information about the ffmpeg-user mailing list