私は次のことを試しました:
$ffmpeg = "/path/to/ffmpeg";
$source = "/path/to/video/source.mp4";
$dest = "/path/to/video/dest.mp4";
$format = "%s > %s 2>&1 & echo $! >> %s";
$a_rate = "44100";
$a_bitrate = "96k";
$v_bitrate = "3000k";
$resolution = "1280x720";
$outputfile = "/path/to/output.txt";
$pidfile = "/path/to/pid.txt";
exec(sprintf($format, $ffmpeg . " -i " . $source . " -vcodec libx264 -s " . $resolution . " -b " . $v_bitrate . " -pass 1 /dev/null && \ " . $ffmpeg . " -i " . $source . " -acodec libfaac -ar " . $a_rate . " -ab " . $a_bitrate . " -vcodec libx264 -s " . $resolution . " -b " . $v_bitrate . " -pass 2 " . $dest, $outputfile, $pidfile));
1 回のパスを実行するとすべてが完全に機能しますが、そのように 2 回のパスを実行しようとするとうまくいきません。それを行う適切な方法は何ですか?
アップデート:
exec(sprintf($format, $ffmpeg . " -i " . $source . " -pass 1 -vcodec libx264 -s " . $resolution . " -b " . $v_bitrate . " -passlogfile " . $pass . " -f rawvideo -y /dev/null", $outputfile, $pidfile));
exec(sprintf($format, $ffmpeg . " -y -i " . $source . " -pass 2 -acodec libfaac -ar " . $a_rate . " -ab " . $a_bitrate . " -vcodec libx264 -s " . $resolution . " -b " . $v_bitrate . " -passlogfile " . $pass . " " . $dest, $outputfile, $pidfile));