FFMpeg:ffmpeg无法执行命令错误

I am trying to transcode a video file of 1.2mb file uploaded to my website server via php/html upload, but I keep getting the error:

PHP Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/usr/local/bin/ffmpeg' '-y' '-i' '/home/user/public_html/contents/videos/1490719990_MP4_360p_Short_video_clip_nature_mp4.mp4' '-async' '1' '-metadata: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' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '8k' '-ac' '1' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes58dab05a323b6eknk4/pass-58dab05a32465' '/home/user/public_html/contents/videos/1490719990_MP4_360p_Short_video_clip_nature_mp4_22995.mp4'' in /home/user/public_html/app/ffmpeg/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 Stack trace:

0 /home/user/public_html/app/ffmpeg/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alch in /home/user/public_html/app/ffmpeg/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php on line 168

Funny thing is that the same server is extracting frames and getting duration of the same file using ffprobe and ffmpeg.

Here is the code I am using to transcode:

$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);

I have contacted my host to no vital assistance. The only useful information they can provide me is that ffmpeg was compiled on the server with libmp3lame support.

This code works perfect on localhost

Any help as to why I may be getting the error and how to correct it is appreciated.

duan198123
duan198123 你应该补充一下作为答案。这就是我最终做的。这是解决方案。
一年多之前 回复
dongtaihui5131
dongtaihui5131 我很高兴我帮忙
接近 2 年之前 回复
duanqun9740
duanqun9740 “你有没有试过在控制台上启动这个命令”救了我。我的环境是Ubuntu18BionicBeaver。由于许可原因,似乎libfac库不包含在ffmpeg中。终端抛出错误:未知编码器'libfaac',然后我解决了$format=newFFMpeg\Format\Video\X264('libmp3lame','libx264');
接近 2 年之前 回复
dongmu5596
dongmu5596 您的ffmpeg命令看起来像是从2007年开始。使用x264编码预设而不是尝试使用大量随机选项。替换-b_strategy1-bf3-refs6-coder1-sc_threshold40-flags+loop-me_range16-subq7-i_qfactor0.71-qcomp0.6-qdiff4-trellis1with-presetslow。但是,这不会解决您遇到的任何问题,但它会产生更明智的命令。
3 年多之前 回复
dongxi3911
dongxi3911 在没有项目的情况下发现这种错误非常困难。但现在,你知道要开始搜索。找出为什么params是不同的,因为它不应该。一旦找到它,您将解决问题
3 年多之前 回复
dpxw17759
dpxw17759 它们是不同的。本地数据库中有四个项目,但服务器上的项目也是如此。
3 年多之前 回复
dongnei3634
dongnei3634 好。在你的本地去ffmpeg/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php找到第167行并打印传递给$this->driver->command()的args;然后我们的主人也这样做。检查是否存在一些差异
3 年多之前 回复
dongyi7901
dongyi7901 我在共享主机上。我无法访问终端。
3 年多之前 回复
dsdukbc60905239
dsdukbc60905239 您是否尝试在控制台上启动此命令:'/usr/local/bin/ffmpeg''-y''-i''myvideo''-async''1''-cosadata:s:v:0''start_time=0''-r''16''-b_strategy''1''-bf''3''-g''9''-vcodec''libx264''-acodec''libmp3lame''-b:v''128k''-refs''6''-encoder''1''-sc_threshold''40''flags''+loop''-me_range''16''-subq''7''-i_qfactor''0.71''-qcomp''0.6''-qdiff''4''-'trellis''1''-b:a''8k''-ac''1''-pass''1''-passlogfile''/tmp/ffmpeg-passes58dab05a323b6eknk4/pass-58dab05a32465''myvideo'这是获得有关正在发生的事情的反馈的最佳方式。
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐