User Tools

Site Tools


ffprobe:duration

ffprobe - Duration

Container Format Duration

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4

returns:

30.024000

NOTE: The output duration is in seconds.

Adding the -sexagesimal option will use the HOURS:MM:SS.MICROSECONDS time unit format:

0:00:30.024000

Stream duration

Duration of the first video stream:

ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 input.mp4

returns:

30.000000

NOTE: Not all formats, such as Matroska and WebM, store duration at the stream level resulting in duration=N/A.

  • Refer to Format (container) duration instead.

Get duration by decoding

Get the duration by fully decoding the file.

  • The null muxer is used so no output file is created.
ffmpeg -i input.mkv -f null -

returns:

...
frame=206723 fps=1390 q=-0.0 Lsize=N/A time=00:57:28.87 bitrate=N/A speed=23.2x

NOTE: This will report the correct duration in case the methods shown above using ffprobe are incorrect or missing due to corrupt, truncated, or damaged files.

  • time= - in the next-to-last line of the console output has the duration.
    • In this example the input has a duration of 00:57:28.87.
  • The command may take some time depending on the input file duration and decoding complexity.

ffprobe/duration.txt · Last modified: 2025/05/27 08:45 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki