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
There is a better, faster and low CPU/HD footprint solution, just with mediainfo without relying into awk:
mediainfo --Inform="General;%Duration%" input.m4v