User Tools

Site Tools


ffprobe:duration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ffprobe:duration [2025/05/27 08:11] – created peterffprobe:duration [2025/05/27 08:45] (current) peter
Line 1: Line 1:
 ====== ffprobe - Duration ====== ====== ffprobe - Duration ======
 +
 +===== Container Format Duration =====
  
 <code bash> <code bash>
-ffprobe -i <file> -show_entries format=duration -v quiet -of csv="p=0"+ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
 </code> </code>
  
Line 8: Line 10:
  
 <code> <code>
-3392.12+30.024000
 </code> </code>
  
 <WRAP info> <WRAP info>
 **NOTE:**  The output duration is in seconds. **NOTE:**  The output duration is in seconds.
 +
 +Adding the **-sexagesimal** option will use the HOURS:MM:SS.MICROSECONDS time unit format:
 +
 +<code>
 +0:00:30.024000
 +</code>
 +
 </WRAP> </WRAP>
 +
 +----
 +
 +===== Stream duration =====
 +
 +Duration of the first video stream:
 +
 +<code bash>
 +ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
 +</code>
 +
 +returns:
 +
 +<code>
 +30.000000
 +</code>
 +
 +<WRAP info>
 +**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.
 +
 +</WRAP>
 +
 +----
 +
 +===== Get duration by decoding =====
 +
 +Get the duration by fully decoding the file.
 +
 +  * The null muxer is used so no output file is created.
 +
 +<code bash>
 +ffmpeg -i input.mkv -f null -
 +</code>
 +
 +returns:
 +
 +<code>
 +...
 +frame=206723 fps=1390 q=-0.0 Lsize=N/A time=00:57:28.87 bitrate=N/A speed=23.2x
 +</code>
 +
 +<WRAP info>
 +**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.
 +
 +
 +</WRAP>
 +
 +----
  
  
ffprobe/duration.1748333509.txt.gz · Last modified: 2025/05/27 08:11 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki