2015-02-06 152 views
0

当我运行ffmpeg命令时,它正在从命令行工作。但是当我尝试从PHP exec()。它返回127错误。ffmpeg没有从php exec()函数运行,从命令行工作

我的ffmpeg

[email protected] [/]# which ffmpeg 
/root/bin/ffmpeg 

,这是我的代码

ffmpeg-y -i /home/castbox/public_html/IGVideo/upload/tamil/videos/testing/test_ig.mp4 -acodec libfdk_aac -ab 24k -ar 44100 -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 31 -b:v 200k -g 72 -f hls -hls_time 3 -hls_list_size 999 -s 426x240 /home/castbox/public_html/IGVideo/upload/tamil/videos/testing/test_ig-240-index.m3u8 

when i run this code in from command line it work fine. but when try to run from php exec i am getting failed, it returns 127. 

我曾试图这样也

/path/to/ffmpeg-y -i /home/castbox/public_html/IGVideo/upload/tamil/videos/testing/test_ig.mp4 -acodec libfdk_aac -ab 24k -ar 44100 -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 31 -b:v 200k -g 72 -f hls -hls_time 3 -hls_list_size 999 -s 426x240 /home/castbox/public_html/IGVideo/upload/tamil/videos/testing/test_ig-240-index.m3u8 

哪里是我的错?

+0

莫非是权限有关? – DarkUrse 2015-02-06 11:16:13

+0

你的二进制文件位于'/ root /'目录中。网络服务器以不同的用户运行,并且很可能无法访问它。 – 2015-02-06 11:21:57

+0

可能的重复:http://stackoverflow.com/questions/14403013/ffmpeg-works-in-command-line-but-not-in-exec-it-returns-127 (不知道如何添加重复的问题好的方法) – DarkUrse 2015-02-06 11:24:23

回答

0

使用system()代替exec()

试试下面的代码:

use system("ffmpeg -i input.wmv -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -preset slow -crf 22 -movflags +faststart output.mp4") 
+0

好,但如果解释更多,或者可能在你的答案中放置了一部分代码,那更有用。 – 2015-02-16 10:32:43

+0

use system(“ffmpeg -i input.wmv -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -preset slow -crf 22 -movflags + faststart output.mp4”) – 2015-02-16 10:42:18

相关问题