0
我使用EXEC在PHP執行命令,它會創建一個臨時文件夾.png文件..
創造我想要打開該文件並讀取內容後並對其進行處理,,
但我最終文件無法讀取錯誤..
我認爲執行並創建一個文件由exec所花費的時間是這一問題的原因..
但我不知道如何fi x它?我想睡覺(),但它使我的腳本運行緩慢
<?php
error_reporting(E_ALL);
extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
//db connection codes
$max_width = 120;
$max_height = 72;
$path ="/path/";
$qry="select id, input_file, output_file from videos where thumbnail='' or thumbnail is null;";
$res=mysql_query($qry);
$cnt = 1;
while($row = mysql_fetch_array($res,MYSQL_ASSOC))
{
$outfile = $row[output_file];
$imgname = $cnt.".png";
$srcfile = "/path/".$outfile;
echo "####$srcfile####";
exec("ffmpeg -i ".$srcfile." -r 1 -ss 00:00:05 -f image2 -s 120x72 ".$path.$imgname);
$nname = "./temp/".$imgname;
echo "nname===== $nname";
$fileo = fopen($nname,"rb");
if($fileo)
{
$imgData = addslashes(file_get_contents($nname));
..
...
....
}
else
echo "Could not open<br><br>"; // this stmt is printed while executing
$cnt = $cnt + 1:
}
?>
我在發佈時用名稱'路徑'替換了原來的路徑,就這些了。我確定路徑是正確的,文件是用適當的權限創建的,我使用filezilla進行了檢查。 – Vijay 2010-05-17 05:28:04
爲什麼不用'echo $ path。$ imgfile。「==。/ temp /".$ imgname;'看看它們是否真的是一樣的? – 2010-05-17 05:36:55
我檢查過它和文件是一樣的... – Vijay 2010-05-17 06:10:24