On Fri, 2008-06-27 at 03:05 -0400, inf200528@xxxxxxxxxx wrote: > > SORRY, IN THE LAST EMAIL I DONT SAY WHAT TYPE OF VIDEO I WAS WORKING, > I AM WORKING WITH VIDEO .MOV > THANKS. > > I am working with videos and I need to Know how I can obtain the > duration of the videos > I had a formula that did not need any function of php, but i lost de > page, please i need any help with this. > > Sorry for my english, i am from Cuba. Here's how I do it. I make a file with the output of ffmpeg and then just parse the file for duration. After looking at a lot of options, this proved to be the easiest and most reliable. Here's my code that also finds the mid-time and grabs an image of the middle frame for a thumbnail: //tmpname is the temp name of the video //First we get some info about the video with ffmpeg $cmd="/usr/local/bin/ffmpeg -i $tmpname 2> $tmpname.info"; system($cmd,$ok); if (!$ok) { return false; } $ffinfo=file_get_contents($tmpname.".info"); $ffinfo=substr($ffinfo,strpos($ffinfo,"Duration:")+10,strlen($ffinfo)); //Now that we got the duration we parse the string so that we get hours, mins and seconds $ffinfo=substr($ffinfo,0,strpos($ffinfo,".")); $runningtimeparts=explode(":",$ffinfo); foreach($runningtimeparts as $rt) { $newparts[]=floor((($rt/60)*0.5)*60); } //Get the mid point $midtime=($newparts[0]*3600)+($newparts[1]*60)+$newparts[2]; $midtimestr=implode(":",$newparts); //$jpegname is the name of where you want to save the thumbnail $cmd="/usr/local/bin/ffmpeg -i $tmpname -ss $midtimestr -y -r 1 -vframes 1 -f mjpeg $jpegname"; system($cmd); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php