How can I get video duration in seconds?
What I've tried:
ffmpeg -i file.flv 2>&1 | grep "Duration"
Duration: 00:39:43.08, start: 0.040000, bitrate: 386 kb/s
mediainfo file.flv | grep Duration
Duration : 39mn 43s
This what close, but it's not so accurate, 2383 is 39.71 minutes
ffmpeg -i file.flv 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] }'
2383
Answer
To get minutes, you have to divide 2383 seconds by 60.
39.7167
and then multiply the fractional part .7167 by 60 to get the remaining seconds.
43.002
So it's 39 minutes, 43 seconds. The application appears to be giving you an accurate value.
Comments
Post a Comment