[FFmpeg-user] Help please using FFprobe to find duration in minutes (rounded up).

batguano999 batguano999 at zoho.com
Wed Aug 3 22:35:01 EEST 2016



Hi
Please can somebody suggest a way how to extract the duration of a file using FFprobe, in minutes, rounded up.

I found this with a web search but it's old and looks clumsy. 

ffmpeg -i foo.ts 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,// | sed 's@\..*@@g' | awk '{ split($1, A, ":"); split(A[3], B, "."); print 3600*A[1] + 60*A[2] + B[1] }'

With my test file foo.ts the duration is... Duration: 00:15:14.90
I would like the answer to read 16.
(Then I can use this answer to determine what to do with the file. eg short files converted to flac, long files converted to ogg)


~$ cat /etc/issue
Ubuntu 14.04.5 LTS \n \l

$ ffmpeg -v
ffmpeg version git-2016-08-02-e9659d1



More information about the ffmpeg-user mailing list