Symfony Process - Command not found

核能气质少年 提交于 2021-02-17 07:14:07

问题


I'm trying to execute ffmpeg commands using Symfony Process Component but command is not being processed. What am I doing wrong? I get the error

The command "'ffmpeg -i [...........]' failed. Exit Code: 127(Command not found)"

<?php 
$info = pathinfo($file);
$dir = "{$info['dirname']}/{$info['filename']}";
File::makeDirectory($dir, 0755, true)
$process = new Process(["ffmpeg -i {$info['basename']} -codec copy -map 0 -f segment -segment_list {$dir}/playlist.m3u8 -segment_list_flags +live -segment_time 10 {$dir}/{$info['filename']}_%02d.ts"]);
$process->setWorkingDirectory($info['dirname']);
$process->start();
if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
}
echo $process->getOutput();
?>

回答1:


You have to put each argument in a separate element of the array, for example:

$process = new Process([
    "ffmpeg",
    "-i",
    "{$info['basename']}",
    "-codec",
    "copy",
    "-map",
    "0",
    "-f",
    "segment",
    "-segment_list",
    "{$dir}/playlist.m3u8",
    "-segment_list_flags",
    "+live",
    "-segment_time",
    "10",
    "{$dir}/{$info['filename']}_%02d.ts",
]);

And I think you should either:

  • use $process->run() instead of $process->start()
  • or read in more detail how to run a process asynchronously with $process->start()


来源:https://stackoverflow.com/questions/65290904/symfony-process-command-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!