PHP ile video süresini almak
arkadaşlar ben siteye video yüklüyorum ama bunların kaç dakika olduğunu alamıyorum
böyle birşey php ile nasıl yapılır
Mesala Facebook a attığımız videda hemen yanında kaç dakika olduğu yazıyor
bunu nasıl yapıyorlar...??
Lütfen acil cevap :(
05-12-2010 16:52
Php
sunucuda ffmpeg isimli bir program yüklenmesi gerekiyor. daha sonra tek komutla süreyi alabilirsin.
http://code.google.com/p/phpvideotoolkit/
ffmep yüklendikten sonra aşağıdaki kodla alabilirsin:
<?php
$videofile="video/test.flv";
ob_start();
passthru("usr/local/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);
$duration = $matches[1][0];
//echo $duration."<BR>";
$timearray = explode(":", $duration);
$min = 60*$timearray[1];
$sec = $timearray[2];
$ttime = $min+$sec;
if($dot = strpos($ttime, ".")){
$ttime = substr($ttime, 0, 3);
}
echo $ttime;
?>
$videofile="video/test.flv";
ob_start();
passthru("usr/local/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);
$duration = $matches[1][0];
//echo $duration."<BR>";
$timearray = explode(":", $duration);
$min = 60*$timearray[1];
$sec = $timearray[2];
$ttime = $min+$sec;
if($dot = strpos($ttime, ".")){
$ttime = substr($ttime, 0, 3);
}
echo $ttime;
?>
Her programcı birgün Php yi tadacaktır
06-12-2010 07:21
www.Phpkodlari.com © 2009 Herkes Php öğrenecek
Web tasarım ve eğitim kaynağınız.