If we need to get video duration in php if server not support ffmepg function than use following code to get duration.
ob_start();
passthru("ffmpeg -i ".$videoName." 2>&1");
$duration = ob_get_contents();
ob_end_clean();
$search='/Duration: (.*?)[.]/';
$duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE);
$duration = $matches[1][0];
list($hours, $mins, $secs) = split('[:]', $duration);
echo "Hours: ".$hours." Minutes: ".$mins." Seconds: ".$secs;
$duration=$mins.':'.$secs;
No comments:
Post a Comment