tags:

views:

52

answers:

2

Hi I need to save video file duration. when it is uploaded. How can I do that in PHP.

A: 

If the information is available in the extended information (such as id3 tags) you can use the id3 library to get the information...

http://getid3.sourceforge.net/

It also enables you to get the height and width of the video.

Sohnee
+6  A: 

Copy/Paste from a script I wrote a while ago:

$videofile="/var/video/user_video.avi";
ob_start();
passthru("/usr/bin/ffmpeg -i \"{$videofile}\" 2>&1");
$duration = ob_get_contents();
ob_end_clean();

$search='/Duration: (.*?),/';
$duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);

echo $matches[1][0];
halfdan
Don't use output buffering and passthru() to retrieve the result of a command, use backticks, exec or proc_open instead.
Sjoerd
Sjoerd, indeed I should've reread that script prior to posting it.
halfdan