【发布时间】:2015-03-17 22:36:18
【问题描述】:
我正在尝试在 exec 上运行以下命令:
ffmpeg -y -i video.mp4 \
-ss 1067 -i video.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts -t 32 tmp/cuts/6.ts \
-ss 1215 -i video.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts -t 32 tmp/cuts/7.ts
如果我复制这个命令并在 shell 上运行它,一切都很好,视频被剪掉了,完美。
但是通过 php exec 运行,ffmpeg 返回以下错误:
[NULL @ 052a0060] Unable to find a suitable output format for '\'
\: Invalid argument
即使我像这样复制粘贴命令:
<?php
$command = 'ffmpeg -y -i video.mp4 \
-ss 1067 -i video.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts -t 32 tmp/cuts/6.ts \
-ss 1215 -i video.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts -t 32 tmp/cuts/7.ts';
echo $command.chr(10);
$return = 0;
$output = array();
exec($command, $output, $return);
?>
我错过了什么吗?我试过escapeshellcmd、escapeshellarg,甚至用双反斜杠来转义反斜杠,什么都没有。
Windows 和 Unix 都会出现这种情况,错误完全相同。
你知道这是怎么回事吗?
【问题讨论】:
-
去掉\'s,全部变成一行
-
@Dagon,谢谢你它完美地工作......但由于解释,接受的答案是 Diego。谢谢