DEV Community

EJEH
EJEH

Posted on • Updated on

Config ffmjpeg for video manipulation on any Laravel project

Before you start reading post i highly encourage you to checkout this installation part of ffmjpeg on windows below.

https://dev.to/donejeh/ffmjpeg-on-windows-for-video-manipulation-phplaravel-journey-part-1-31ce

before working with ffmjpeg in your project you need to install the binary package on your system or server.

Here are the steps to follow and configure ffmjpeg on new or old laravel project.

Here is the official Github package link for laravel-ffmpeg
https://github.com/protonemedia/laravel-ffmpeg

Here is the official Github package link php-ffmpeg
https://github.com/PHP-FFMpeg/PHP-FFMpeg

You can also follow the above link to setup.

=> open your laravel and require the package
composer require pbmedia/laravel-ffmpeg

=> Add the Service Provider and Facade to your app.php config file if you're not using Package Discovery.

// config/app.php
'providers' => [
...
ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class,
...
];

'aliases' => [
...
'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class
...
];

=> Add the folder path to your ffmjpeg binary to your env like this below

ffmpeg env path

we can test by creating single route file, try to Convert an audio or video file:

Route::get('/', function(){

FFMpeg::fromDisk('songs')
->open('sample.mp4')
->export()
->toDisk('converted_songs')
->inFormat(new \FFMpeg\Format\Audio\Aac)
->save('audio_output.mp4');
});

*make sure you import the class use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;
*

NOTE YOU HAVE TO INSTALL FFMJPEG ON YOUR SYSTEM OR SERVER
check out this post on how to setup one
THANK YOU FOR READING IF YOU HAVE ANY QUESTION OR ISSUES YOU CAN DROP COMMENT BELOW

Top comments (0)