[FFmpeg-user] How to get video duration in a script using ffmpeg?

Bo Berglund bo.berglund at gmail.com
Wed Jan 19 14:56:41 EET 2022


On Wed, 19 Jan 2022 12:59:45 +0100, Bo Berglund <bo.berglund at gmail.com> wrote:

>Thanks, this returns the following output:
>0:43:26.384000
>
>Can the duration be limited to only seconds resolution (no decimals)?
>

Turns out I found a simple way:

CMD="ffprobe -v 0 -of compact=p=0:nk=1 -sexagesimal -show_entries
format=duration $INPUTFILE"
DURATION=$($CMD)
echo ${DURATION%.*}

Results in this output:
0:43:26

Exactly what is needed...


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list