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
Technically this is easy to implement with a separated service:
gsutil -q -m -o Credentials:gs_service_key_file=/var/www/storage/gcs/your-file.json -o GSUtil:parallel_process_count=8 cp /path/to/hls/files/ gs://storage/path/
. For AWS you can use your command tools like described here. If s3 supports upload files with parallel processing it should give you the fastest solution instead of upload a lot of files one by one.