我想用這個腳本來創建視頻的縮略圖,使用ffmpeg。起初我使用phpinfo();
,我發現ffmpeg安裝在我的服務器上。ffmpeg-php創建視頻縮略圖
然後我複製的ffmpeg的PHP到我的服務器和運行測試文件
我才知道,很多功能都在我的服務器
我得到的輸出喜歡這個
上工作輸出: -
Functions available in /usr/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so extension:
Methods available in class ffmpeg_movie:
__construct
getduration
getframecount
getframerate
getfilename
getcomment
gettitle
getauthor
getartist
getcopyright
getalbum
getgenre
getyear
gettracknumber
getframewidth
getframeheight
getframenumber
getpixelformat
getbitrate
hasaudio
hasvideo
getnextkeyframe
getframe
getvideocodec
getaudiocodec
getvideostreamid
getaudiostreamid
getaudiochannels
getaudiosamplerate
getaudiobitrate
getvideobitrate
getpixelaspectratio
getpixelaspectratio
getvideobitrate
getaudiobitrate
getaudiosamplerate
getaudiochannels
getaudiostreamid
getvideostreamid
getaudiocodec
getvideocodec
getframe
getnextkeyframe
hasvideo
hasaudio
getbitrate
getpixelformat
getframenumber
getframeheight
getframewidth
gettracknumber
getyear
getgenre
getalbum
getcopyright
getartist
getauthor
gettitle
getcomment
getfilename
getframerate
getframecount
getduration
__construct
我寫了這段代碼和trie d任何可能的路徑分配$ffmpeg;
<?php
$thumb_stdout;
$retval=0;
$ffmpeg = '/home/lib/ffmpeg';
// change "demo.mpg" to your mpg file name!
$video = dirname(__FILE__) . 'demo.mpg';
// change "demo.jpg" to whichever name you like or don't
// for this example, the name of the output jpg file does not matter
$image = dirname(__FILE__) . 'demo.jpg';
$second = 1;
$cmd = "$ffmpeg -i $video 2>&1";
if (preg_match('/Duration: ((\d+):(\d+):(\d+))/s', '$cmd', $time)) {
$total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
$second = rand(1, ($total - 1));
}
//$cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
$cmd = "$ffmpeg -i $video -r 1 -ss 00:00:05 -t 00:00:01 -s 250x250 -f image2 $image";
echo $cmd;
exec($cmd);
//$return = '$cmd';
echo '<br>done!';
?>
嗯...有什麼問題嗎? – deceze 2010-10-12 05:00:23
問題是腳本不能正常工作。 – Wazzzy 2010-10-12 05:05:46
然後請提供更多信息,兄弟。任何錯誤消息?命令是否從命令行工作? – deceze 2010-10-12 05:10:51