I need to use php-ffmpeg to convert some other formats of video files into mp4 format files, please help!

1. My development environment is ubuntu14.04,php version 7.1
2. I have installed php-ffmpeg, on composer. Here is my test code:

$save_path = DOCROOT . "upload/anquanwuyouwang/professional/resource/learning/";
$path = [
    "ffmpeg.binaries" => "/usr/local/bin/ffmpeg",
    "ffprobe.binaries" => "/usr/local/bin/ffprobe"
];
$ffmpeg = FFMpeg\FFMpeg::create($path);
$video = $ffmpeg->open($save_path . "cz.flv");
$format = new FFMpeg\Format\Video\X264();
$format->on("progress", function ($video, $format, $percentage) {
    echo "$percentage % transcoded";
});
$video->save($format, $save_path . "test.mp4");

when executing, an error is reported:
error message: Encoding failed
File: / home/ljg/workspace/tools.51safety/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/AbstractVideo.php, Line 104

is my local ffmpeg installation. Is there a problem? I searched a lot of information on the Internet, there are all kinds of dependent packages, such as what xh264,libfaac, etc., I installed better, but still reported an error, looking for the correct installation method to meet my need to convert video to mp4 format.
Please give detailed steps, if there is an installation package, please give the download link, thank you!

Nov.24,2021

now the official "libfaac" code has been removed, so the default code cannot be used, and the original code is replaced by "libfdk_aac". Therefore, when you new here, you should use a new code: new FFMpegFormatVideoX264 ('libfdk_aac');
, when you install it at the same time, take this option-- with-fdk-aac

.

refer to this article for details.
https://codeshelper.com/a/11.

Menu