FFmpeg 输入问题

FFmpeg input issue

我正在尝试调整不在 PHP 执行代码同一目录中的视频的大小,这是我的 ffmpeg 代码:

ffmpeg.exe -i ../Gotten Movies/test.mp4 -s hd480 -c:v libx264 -crf 23 -c:a aac -strict -2 ../Gotten Movies/test2o.mp4
我得到的错误是: ../Gotten: Invalid data found when processing input 我认为问题是因为选择了以前的目录 ../ 我试过
cd Gotten Movies; ffmpeg.exe -i ../Gotten Movies/test.mp4 -s hd480 -c:v libx264 -crf 23 -c:a aac -strict -2 ../Gotten Movies/test2o.mp4
但它也不起作用我该怎么办解决问题谢谢。

用引号括起带有特殊字符的路径总是更安全:

ffmpeg.exe -i "../Gotten Movies/test.mp4" -s hd480 -c:v libx264 -crf 23 -c:a aac -strict -2 "../Gotten Movies/test2o.mp4"

仅供参考: Windows 真的 对单引号和双引号很挑剔。 我在 PHP 中这样输入我的文件(这会转义文件名和目录中的单词空格):

$filepath=$file->getPath();
$filepath=str_replace('\',"/",$filepath);
$filename='abc.mpg';

将它们 单独 传递给我的函数 - 然后执行此操作:

$cmd = 'ffmpeg -i "'.$filePath.'"/"'.$fileName.'" 2>&1 | findstr Duration';
$data = exec($cmd, $output);

如果有错误 $output 将包含完整的错误响应 - 否则 $data 给出我想要的项目(持续时间)