Here is my code:
$format = new X264('aac', 'libx264');
$format->setKiloBitrate(500);
but when videos transcode with pascalbaljetmedia/laravel-ffmpeg
, this package sets audio codec to mp3
by default instead aac
.
How solve this problem?
Here is my code:
$format = new X264('aac', 'libx264');
$format->setKiloBitrate(500);
but when videos transcode with pascalbaljetmedia/laravel-ffmpeg
, this package sets audio codec to mp3
by default instead aac
.
How solve this problem?
I told you about the libfaac
encoder. But I figured out this one was deprecated in 2016. Because there are other better encoders out there such as aac
, libfdk_aac
, aac_at
etc. Check out more here.
You should first check those encoders out on your command line tool to make sure your ffmpeg was compiled with those encoders. Let's use aac
encoder because it is included by default in all ffmpeg versions.
ffmpeg -i real_audio.mp3 -c:a aac converted_audio.aac
I used the laravel-ffmpeg
with aac
encoder to convert mp3
to aac
. It worked like a charm. See the following code:
<?php
namespace App\Http\Controllers;
use FFMpeg\Format\Video\X264;
use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;
class TestController extends Controller
{
public function index()
{
echo "<p>Converting...</p>";
FFMpeg::fromDisk('public')
->open('audio.mp3')
->export()
->toDisk('public')
->inFormat(new X264('aac'))
->save('converted_audio.aac');
}
}
To know more about aac
encoder use the following command:
ffmpeg -h encoder=aac
My laravel-ffmpeg
package version is
"pbmedia/laravel-ffmpeg": "^7.0"
and ffmpeg version is
ffmpeg version 3.4.6
Hope this helps you!