How to get video or audio duration of a file?

Ankit Shah
Nov 12, 2021

--

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

--

--

Ankit Shah
Ankit Shah

Written by Ankit Shah

LLM Architecture Associate Director at Accenture.

No responses yet