[英]php exec() for ffmpeg not working
hai i am using ffmpeg command in php exec() for converting any type of video to flv format the command i'm using i sworking fine in the command prompt but when i run the same commend it returns nothing..actully the output is Array( ) and the the third parameter $result is "1" 我在php exec()中使用ffmpeg命令将任何类型的视频转换为flv格式,我正在使用的命令在命令提示符下运行良好,但是当我运行相同的命令时,它不会返回任何内容。实际上输出是数组(),第三个参数$ result为“ 1”
i've read similar questions like this on stackoverflow but it's not helping 我已经在stackoverflow上读过类似的问题,但这无济于事
most of the time i noticed that the issue is in path and the safe mode of php 大多数时候,我注意到问题出在php的路径和安全模式下
and i have disabled safe mode using .htaccess the syntax is given below and i am using windows 7 os 并且我已经使用.htaccess禁用了安全模式,语法在下面给出,并且我正在使用Windows 7 OS
the directory to the ffmpeg application is c:\\ffmpeg\\bin\\ffmpeg ffmpeg应用程序的目录为c:\\ ffmpeg \\ bin \\ ffmpeg
the full script and output is given below: 完整的脚本和输出如下:
the ffmpeg command: ffmpeg命令:
ffmpeg -i c:\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\xampp\htdocs\video\vids\robot.flv
the php script: php脚本:
echo "starting ffmpeg...<br/>";
echo exec("ffmpeg -i c:\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\xampp\htdocs\video\vids\robot.flv",$out,$r);
var_dump($out);
echo $r."<br/>";
echo "done...<br/>";
?>
the htaccess for switching off the safe mode: htaccess用于关闭安全模式:
php_value safe_mode "0"
the output: 输出:
starting ffmpeg...
array(0) { } 1
done...
Try the below one instead of using exec(ffmpeg -i 'inputfile' 'outputfile'); 请尝试以下方法,而不要使用exec(ffmpeg -i'inputfile''outputfile');
$cmd = "ffmpeg -ic:\\xampp\\htdocs\\video\\original\\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\\xampp\\htdocs\\video\\vids\\robot.flv" $ cmd =“ ffmpeg -ic:\\ xampp \\ htdocs \\ video \\ Original \\ robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\\ xampp \\ htdocs \\ video \\ vids \\ robot.flv”
ob_start(); ob_start();
passthru($cmd); passthru($ cmd);
$cmd_retr = ob_get_contents(); $ cmd_retr = ob_get_contents();
print_r($cmd_retr); print_r($ cmd_retr);
<?php
echo exec("cmd /c ffmpeg -i c:\\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\\xampp\htdocs\video\vids\robot.flv",$out,$r");
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.