From the following ffmpeg -i
output, how would I get the length (00:35)--
$ ffmpeg -i 1video.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from \'/Users/d
Do you want to do this in a bare shell pipeline, or read the result in a calling program?
/\s+Duration: ((\d\d):(\d\d):(\d\d)\.(\d+))/
… is a PCRE that will split the result up (replace the \.
with [;:.]
if ffmpeg might output the duration in frames rather than fractional seconds). In a Unix pipeline:
| grep Duration: | cut -f2- -d: | cut -f1 -d, | tr -d ' '
There are of course a billion other ways to express this.