Laravel package for encoding video files using FFMpeg
An OOP Laravel package user for encoding video files with FFMPEG, (*1)
Package is currently in Alpha stage, with small amount of functions, and it will be constanly upgrade with a lot different features, (*2)
This library requires a working FFMpeg install., (*3)
The recommended way to install Encoder is through Composer., (*4)
{ "require": { "vasictech/encoder": "~1.0" } }
Register package as service in config/app.php, (*5)
return [ VasicTech\Encoder\EncoderServiceProvider::class, ]
Execute config publish, (*6)
return [ 'encoder' => 'ffmpeg', 'ffmpeg' => [ 'path' => '/usr/bin/ffmpeg', 'codecs' => [ 'video' => 'libx264', 'audio' => 'aac', ], 'options' => [ 'strict' => true, 'replace' => true, 'fork' => true, 'log' => storage_path(), ] ] ];
Configure config file, (*7)
return [ VasicTech\Encoder\EncoderServiceProvider::class, ]
$encoder = VasicTech\Encoder\Encoder\FFMpeg(); $jobId = $encoder ->input(storage_path('app/public/trailer.mp4')) ->output(storage_path('app/public/trailer_enc.mp4')) ->execute();
Script returns jobID which can be recorded in database to be connected with files. Output log file will be named as jobID, (*8)
You can provide both, or just one parameter, first is video codec, second is audio codec, (*9)
$encoder->codecs('libx264', 'libfaac');
You can provide both, or just one parameter, first is video bitrate, second is audio bitrate, (*10)
$encoder->bitrate('1200k', '128k');
You can provide both, or just one parameter, first is video width, second is video height, if one is not provided, video will scale to provided size, (*11)
$encoder->size(1280, 720);
If ffmpeg should replace already existing file, (*12)
$encoder->replace(true);
If '-strict -2' parameter should be added, (*13)
$encoder->strict(true);
If process should be forked, (*14)
$encoder->fork(true);
If ffmpeg should write to log file, (*15)
$encoder->log('/path/to/file.log');
Force output format, (*16)
$encoder->format('mp4');
This project is licensed under the MIT license., (*17)