Pages

Thursday, July 11, 2013

How to detect video file duration in minutes with PHP?



ob_start();
 passthru("D:/wamp/www/ffmpeg/ffmpeg.exe -i D:/wamp/www/video5.mp4  2>&1");
 $duration = ob_get_contents();
 $full = ob_get_contents();
 ob_end_clean();
 $search = "/Duration.*?([0-9]{1,}):([0-9]{1,}):([0-9]{1,})/";
 print_r($duration);
 $duration = preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);

 print_r($matches);
 print_r($matches[1][0]);

No comments: