How does ffprobe determine duration? How does ffprobe determine duration? linux linux

How does ffprobe determine duration?


One simple solution is to use -show_packets option

ffprobe -i input.mp4 -show_packets > a.txt

Now open a.txt and go to the last packet and see dts_time value that would be the accurate duration of file. If dts_time is not defined check for the pts_time value.


Metadata may not be correct. The most correct way is decoding the whole file:

$ ffmpeg -i input.webm -f null -...frame=206723 fps=1390 q=-0.0 Lsize=N/A time=00:57:28.87 bitrate=N/A speed=23.2x

Source: https://trac.ffmpeg.org/wiki/FFprobeTips#Getdurationbydecoding