2016-10-19 42 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