This listener will convert your .mov
, .avi
and a lot of others video files to .mp4
after adding media with https://github.com/spatie/laravel-medialibrary
Feel free ask anything what you want.
- Laravel 5.*
- https://github.com/PHP-FFMpeg/PHP-FFMpeg
- Installed FFMpeg on your server
In EventServiceProvider
add your event listener for spatie/laravel-medialibrary
protected $listen = [
'Spatie\MediaLibrary\Events\MediaHasBeenAdded' => [
'App\Listeners\MediaVideoConverterListener'
],
Want use other audio codec? Rewrite it by yourself in the code or just add this in the medialibrary.php
config file with your codec.
'audio_codec' => 'libvo_aacenc',
Configure supervisord with following instructions:
[program:laravel_queue]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /home/vagrant/Code/laravel/artisan queue:work --timeout=0 --memory=512 --tries=3
autostart=true
autorestart=true
user=vagrant
numprocs=3
redirect_stderr=true
stdout_logfile=/home/vagrant/Code/laravel/storage/logs/default_queue.log
numprocs
<- How many queues will be work on your server. Depends on your memory, CPU, etc.
This is how many files will processing in one time. By default 3 video files will be in processing.
--memory=512
<- by default it's 128 Mb
Thank you for your quick reply @Nks. Actually I'm using Amazon S3 as the file driver of spatie media library package. I think as you said, I should use your event listener, before triggering the upload to S3 process.