Getting video duration using ffmpeg, php function
I have FFMpeg installed and I know it is functional, but I am trying to get duration time from FLV video via PHP, but when I use this code:
MbmGetFLVDuration ($ file) {
/*
* Determine video duration with ffmpeg
* ffmpeg should be installed on your server.
*/
//$time = 00:00:00.000 format
$ffmpeg = "../ffmpeg/ffmpeg";
$time = exec("$ffmpeg -i $file 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//");
$duration = explode(":",$time);
$duration_in_seconds = $duration[0]*3600 + $duration[1]*60+ round($duration[2]);
return $duration_in_seconds;
}
and
$ duration = mbmGetFLVDuration (' http://www.videoaddsite.com/videos/intro.flv '); echo $ duration;
I get output 220. This video is 3:40. Can anyone help me on what I am doing wrong, or if there is something else I can use?
+3
source to share
2 answers