954,184 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Get video file total time of playing using php

hai friends
I have uploaded the video file to server .we need to get the total time of playing file duration and store the values to database. how can i get the total time for uploaded video file?

Please any one send me any idea.

Thanks
__________________
Thanks
Vssp

vssp
Junior Poster
199 posts since Jul 2006
Reputation Points: 5
Solved Threads: 5
 

Any one replay my issue

vssp
Junior Poster
199 posts since Jul 2006
Reputation Points: 5
Solved Threads: 5
 

You can't do that with php alone without any external software, for example ffmpeg.

php_daemon
Junior Poster
140 posts since Aug 2006
Reputation Points: 13
Solved Threads: 2
 

Hello VSSP.
I have solution to your problem.
Get ffmpeg
Now Extract it to your folder.
The Following Code will show you how you can get duration of Video file.
That one worked for me.

$file= "127808825101 Track 1.wma";
ob_start();

passthru("ffmpeg.exe -i \"{$file}\" 2>&1");  //path to your ffmpeg.exe
$duration = ob_get_contents();
ob_end_clean();

//the full output:
//echo $duration."<br/>";

$search='/Duration: (.*?)[.]/';
$duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE);
$duration = $matches[1][0];

//i suppose that our video hasn't duration of a day+ :
list($hours, $mins, $secs) = split('[:]', $duration);

echo "Hours: ".$hours." Minutes: ".$mins." Seconds: ".$secs;
chintan@dani
Light Poster
39 posts since Jul 2010
Reputation Points: 11
Solved Threads: 4
 

hai friends I have uploaded the video file to server .we need to get the total time of playing file duration and store the values to database. how can i get the total time for uploaded video file?

Please any one send me any idea.

Thanks __________________ Thanks Vssp


View your answer to your post.

chintan@dani
Light Poster
39 posts since Jul 2010
Reputation Points: 11
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You