How to get video or audio duration of a file using ffmpeg?


Today we will learn How to get the duration of a file using ffmpeg

1. Format Container Duration - [This works for both Video and Audio Files - better to report numbers using this command]

ffprobe -v error -show_entries format=duration \
  -of default=noprint_wrappers=1:nokey=1 input.mp4
 
 
2. Video Stream Duration - [This works only for Videos]
 
ffprobe -v error -select_streams v:0 -show_entries stream=duration \
  -of default=noprint_wrappers=1:nokey=1 input.mp4
 
 
Content author - https://superuser.com/questions/650291/how-to-get-video-duration-in-seconds