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
Hi @Nks,
Thanks for this gist, it looks very promising. It appears that you also use a custom media class, could you also share that? In the current form the gist fails because the statics like
Media::MEDIA_STATUS_TO_CONVERT
are not available in the default media class.Thanks!