【问题标题】:FFmpeg input issueFFmpeg 输入问题
【发布时间】:2016-04-04 14:38:31
【问题描述】:

我正在尝试调整不在 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
但它没有我也不能解决这个问题,谢谢。

【问题讨论】:

  • 使用 \ 代替 /
  • 同样的问题现在显示..\Gotten: Invalid data found when processing input :(
  • 谢谢你现在的工作让它成为答案:)

标签: ffmpeg exec shell-exec


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    仅供参考: 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 给出我想要的项目(持续时间)

    【讨论】:

      猜你喜欢
      • 2017-11-23
      • 1970-01-01
      • 2015-06-27
      • 2021-01-12
      • 2019-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      相关资源
      最近更新 更多