2016-10-19 107 views
1

這是主要的index.php文件,我運行我的代碼生成與ffmpeg的視頻縮略圖,但它根本沒有lucks我一直在網上搜索了很多的解決方案,但沒有出現,如果你們能幫助我,我將非常感激。該了shell_exec()不斷給我錯誤php shell_exec()命令彈出錯誤和權限被拒絕ffmpeg

<html> 
<head> 
</head> 
<body> 
<form action="index.php" method="POST" enctype="multipart/form-data"> 
<input type="file" name="file"><input type="submit" name="submit" value="upload"> 

</form> 

<?php 

if(isset($_POST['submit'])){ 


$ffmpeg = "/Users/mac/Documents/ffmpeg/3.1.4/bin/ffmpeg"; 
$videoFile = $_FILES["file"]["tmp_name"]; 
$imageFile = "1.jpg"; 
$size = "320x240"; 
$getFromSecond = 5; 
$cmd = "$ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile 2>&1"; 

    echo shell_exec($cmd); 


echo shell_exec('whoami'); 
if(!shell_exec($cmd)){ 


    echo "thumbnail created"; 
}else{ 
    echo "error creating thumbnail"; 
} 






} 

?> 

</body> 
</html> 
+3

是不是很明顯,它說**權限被拒絕**? –

+0

是的,它一直說權限被拒絕,我不知道最新錯誤我跟着abell.com教程,最終出現錯誤,但視頻教程的工作https://www.youtube.com/watch?v=qT4hN5o57hI&index=3&list=PLf1QYWO6pRZiBa_7JlpR -ejHaIHzFblMq – user3711175

+0

當我將其更改爲exec()後,它沒有提示出任何錯誤,但沒有在我的文件夾中創建圖像 – user3711175

回答

0

這是嘗試運行此文件不正確的權限(通常爲www-data)用戶。爲了驗證這一理論,嘗試用sudo運行:

shell_exec('sudo -u user -p pass -s $ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile 2>&1'); 

你也可以配置Apache來運行你的虛擬主機比www-data或更改權限的文件以外的其他用戶,你想www-data訪問:

https://unix.stackexchange.com/questions/30879/what-user-should-apache-and-php-be-running-as-what-permissions-should-var-www

+0

** sudo:未知用戶**它給了我這個,並且沒有創建圖像 – user3711175

+0

@ user3711175您需要更改用戶'mac'的'user'&'pass'的位置以及'mac'的密碼帳戶 – Kitson88

+0

** sudo:沒有tty禮物,沒有askpass program指定**,現在它給了我這個 – user3711175