我正在尝试通过php / html上传将上传到我网站服务器的1.2mb文件的视频文件转码,但我一直收到错误:
PHP致命错误:未捕获的异常' Alchemy \ BinaryDriver \ Exception \ ExecutionFailureException'消息&fffmpeg无法执行命令' / usr / local / bin / ffmpeg' ' -y' ' -i' ' /home/user/public_html/contents/videos/1490719990_MP4_360p_Short_video_clip_nature_mp4.mp4' ' -async' ' 1' ' - 元数据:S:V:0' ' START_TIME = 0' ' -r' ' 16' ' -b_strategy' ' 1' ' -bf' ' 3' ' -g' ' 9' ' -vcodec' ' libx264' ' -acodec' '了libmp3lame' ' -b:V' ' 128K' ' -refs' ' 6' ' -coder' ' 1' ' -sc_threshold' ' 40' ' -flags' ' +环路' ' -me_range' ' 16' ' -subq' ' 7' ' -i_qfactor' ' 0.71' ' -qcomp' ' 0.6' ' -qdiff' ' 4' ' -trellis' ' 1' ' -b:一个' ' 8K' ' -ac' ' 1' ' -pass' ' 1' ' -passlogfile' ' / TMP / ffmpeg的-passes58dab05a323b6eknk4 /传递58dab05a32465' ' /home/user/public_html/contents/videos/1490719990_MP4_360p_Short_video_clip_nature_mp4_22995.mp4''在/home/user/public_html/app/ffmpeg/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 堆栈跟踪:
有趣的是,同一台服务器使用ffprobe和ffmpeg提取帧并获取同一文件的持续时间。
以下是我用于转码的代码:
$ffmpeg = $ffmpeg = FFMpeg\FFMpeg::create(['timeout'=>3600, 'ffmpeg.thread'=>12, 'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/ffprobe']);
$ffprobe_prep = FFMpeg\FFProbe::create(['ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/ffprobe']);
$ffprobe = $ffprobe_prep->format($video_file);
$video = $ffmpeg->open($video_file);
// Get video duration to ensure our videos are never longer than our video limit.
$duration = $ffprobe->get('duration');
// Use mp4 format and set the audio bitrate to 56Kbit and Mono channel.
// TODO: Try stereo later...
$format = new FFMpeg\Format\Video\X264('libmp3lame', 'libx264');
$format
-> setKiloBitrate(128)
-> setAudioChannels(1)
-> setAudioKiloBitrate(8);
$first = $ffprobe_prep
->streams($video_file)
->videos()
->first();
$width = $first->get('width');
if($width > VIDEO_WIDTH){
// Resize to 558 x 314 and resize to fit width.
$video
->filters()
->resize(new FFMpeg\Coordinate\Dimension(VIDEO_WIDTH, ceil(VIDEO_WIDTH / 16 * 9)));
}
// Trim to videos longer than three minutes to 3 minutes.
if($duration > MAX_VIDEO_PLAYTIME){
$video
->filters()
->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(0), FFMpeg\Coordinate\TimeCode::fromSeconds(MAX_VIDEO_PLAYTIME));
}
// Change the framerate to 16fps and GOP as 9.
$video
->filters()
->framerate(new FFMpeg\Coordinate\FrameRate(16), 9);
// Synchronize audio and video
$video->filters()->synchronize();
$video->save($format, $video_file_new_2);
我已联系我的主人,没有重要帮助。他们可以为我提供的唯一有用信息是ffmpeg是在服务器上编译的,支持libmp3lame。
此代码适用于localhost
对于我为什么会收到错误以及如何纠正错误的任何帮助表示赞赏。