2013-05-15 06:32
浏览 34

php exec()适用于某些调用,而不是其他类似调用

I have a php script that cuts up video. Here are three exec() commands - two execute properly while one does not:


sudo ffmpeg -i /home/vidserver/videos/$filename.mp4 -ss $ctime -t 00:00:06 -acodec copy -vcodec copy -y /var/vidcache/test$x.mp4


sudo ffmpeg -i /var/vidcache/test$x.mp4 -qscale:v 1 /var/vidcache/i$x.mpg

Does not work:

sudo ffmpeg -i concat:"i0.mpg|i1.mpg" -qscale:v 1 /var/vidcache/output.mpg

/var/vidcache has 777 privs and www-data is in the sudoers file with NOPASSWD (yes, I know - this is just for debug purposes before I lock down security).

When I run the last command from a php script from the command line by itself, it DOES work. (Running as www-data or root.) But when I try to put it in a function called from a web page, it does NOT work.

Any ideas?

图片转代码服务由CSDN问答提供 功能建议

我有一个用于剪切视频的php脚本。 这里有三个exec()命令 - 两个执行正确而一个不执行:


sudo ffmpeg -i / home / vidserver / videos / $ filename.mp4 -ss $ ctime -t 00:00:06 -acodec copy -vcodec copy -y /var/vidcache/test$x.mp4 \ n


sudo ffmpeg -i /var/vidcache/test$x.mp4 -qscale:v 1 / var / vidcache / i $ x.mpg


sudo ffmpeg -i concat: “i0.mpg | i1.mpg” -qscale:v 1 /var/vidcache/output.mpg


/var/vidcache有777个私人和< 代码> www-data 在带有NOPASSWD的sudoers文件中(是​​的,我知道 - 在锁定安全性之前,这仅用于调试目的)。

当我从命令行单独运行php脚本中的最后一个命令时,它就可以工作了。 (以www-data或root身份运行。)但是当我尝试将它放在从网页调用的函数中时,它不起作用。

任何想法? \ n

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douguai4653 2013-05-15 06:41

    Actually, the answer was as stupid as "where does www-data know where to look for files?"

    I was assuming a lot with the i0.mpg. It needs a fully qualified directory, obviously.

    Anyway, changing the code to look like this worked:

    sudo ffmpeg -i concat:"/var/vidcache/i0.mpg|/var/vidcache/i1.mpg" -qscale:v 1 /var/vidcache/output.mpg

    打赏 评论
  • donk68254 2013-05-15 06:38

    This should fix the third exec:

    sudo ffmpeg -i "concat:i0.mpg|i1.mpg" -qscale:v 1 /var/vidcache/output.mpg

    Here is a good wiki page on how to concat media files in ffmpeg.

    打赏 评论

相关推荐 更多相似问题