2017 © Pedro Peláez
 

library ffmpeg

A laravel audio and video conversion, thumbnail generator and metadata editor package powered by ffmpeg

image

linkthrow/ffmpeg

A laravel audio and video conversion, thumbnail generator and metadata editor package powered by ffmpeg

  • Wednesday, January 25, 2017
  • by linkthrow
  • Repository
  • 3 Watchers
  • 26 Stars
  • 8,671 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 40 Forks
  • 1 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

FFMPEG (Laravel 5 Package)

Latest Stable Version, (*1)

**** NOTE **** This is a duplicate of https://github.com/closca/FFMPEG. I have duplicated because the original package was not working with the latest Laravel psr-4 loaders and hasn't been updated for a while!, (*2)

FFMPEG is a tool designed to leverage the power of Laravel 5 and (C library FFMPEG) to perform tasks such as:, (*3)

  • Audio/Video conversion
  • Video thumbnail generation
  • Metadata manipulation

Quick Start

Setup

Update your composer.json file and add the following under the require key, (*4)

"linkthrow/ffmpeg": "dev-master"

Run the composer update command:, (*5)

$ composer update

In your config/app.php add 'LinkThrow\Ffmpeg\Provider\FfmpegServiceProvider' to the end of the $providers array, (*6)

'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'LinkThrow\Ffmpeg\Provider\FfmpegServiceProvider',

),

Still under config/app.php add 'FFMPEG' => 'LinkThrow\Ffmpeg\Facade\FfmpegFacade' to the $aliases array, (*7)

'aliases' => array(

    'App'             => 'Illuminate\Support\Facades\App',
    'Artisan'         => 'Illuminate\Support\Facades\Artisan',
    ...
    'FFMPEG'           => 'LinkThrow\Ffmpeg\Facade\FfmpegFacade',

),

Run the artisan command below to publish the configuration file, (*8)

$ php artisan vendor:publish

Navigate to app/config/ffmpeg.php and update all four parameters, (*9)

Examples

Here is a simple example of a file being converted from FLAC to AAC:, (*10)

FFMPEG::convert()->input('foo.flac')->bitrate(128)->output('bar.aac')->go();

FFMPEG can also convert video files:, (*11)

FFMPEG::convert()->input('foo.avi')->bitrate(300, 'video')->output('bar.flv')->go();

FFMPEG can also return media information as an array or json, (*12)

FFMPEG::getMediaInfo('foo.mov');

FFMPEG can also easily generate smart movie thumbnails like this, (*13)

FFMPEG::getThumbnails('foo.mp4', 'foo-thumb', 5); // Yields 5 thumbnails

FFMPEG can also thumbnify your movie (create thumbs for a short preview), (*14)

FFMPEG::thumbnify('foo.mp4', 'foo-thumb', 40, '400'); // Yields 40 thumbnails (every 10 seconds) and video has 400 secs

Although FFMPEG contains several preset parameters, you can also pass your own, (*15)

FFMPEG::convert()->input('foo.flac')->output('bar.mp3')->go('-b:a 64k -ac 1');

Tracking progress

Make sure the progress and tmp_dir options are set correctly in the config.php file, (*16)

'progress'      => true,
...
'tmp_dir'      => '/Applications/ffmpeg/tmp/'

Pass the progress method when initiating a conversion, (*17)

FFMPEG::convert()->input('foo.avi')->output('bar.mp3')->progress('uniqueid')->go();

Now you can write a controller action to return the progress for the job id you passed and call it using any flavor of JavaScript you like, (*18)

public function getJobProgress($id)
{
    return FFMPEG::getProgress('uniqueid');
}

Security and Compatibility

FFMPEG uses PHP's shell_exec function to perform ffmpeg and ffprobe commands. This command is disabled if you are running PHP 5.3 or below and safe mode is enabled., (*19)

Please make sure that ffmpeg and ffprobe are at least the following versions:, (*20)

  • ffmpeg: 2.1.*
  • ffprobe: 2.0.*

Also, remember that filepaths must be relative to the location of FFMPEG on your system. To ensure compatibility, it is good practice to pass the full path of the input and output files. Here's an example working in Laravel:, (*21)

$file_in  = Input::file('audio')->getRealPath();
$file_out = '\path\to\my\file.mp3'; 
FFMPEG::convert()->input($file_in)->output($file_out)->go();

Lastly, FFMPEG will only convert to formats which ffmpeg supports. To check if your version of ffmpeg is configured to encode or decode a specific format you can run the following commands using php artisan tinker, (*22)

var_dump(FFMPEG::canEncode('mp3'));
var_dump(FFMPEG::canDecode('mp3'));

To get a list of all supported formats you can run, (*23)

var_dump(FFMPEG::getSupportedFormats());

Troubleshooting

Please make sure the following statements are true before opening an issue:, (*24)

1) I am able to access FFMPEG on terminal using the same path I defined in the FFMPEG configuration file, (*25)

2) I have checked the error logs for the webserver and found no FFMPEG output messages, (*26)

Usually all concerns are taken care of by following these two steps. If you still find yourself having issues you can always open a trouble ticket., (*27)

License

FFMPEG is free software distributed under the terms of the MIT license., (*28)

Aditional information

Any questions, feel free to contact me., (*29)

Any issues, please report here, (*30)

The Versions

25/01 2017

dev-master

9999999-dev

A laravel audio and video conversion, thumbnail generator and metadata editor package powered by ffmpeg

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Rafael Sampaio
by Closca Costel

laravel converter ffmpeg ffprobe

09/04 2016

dev-development

dev-development

A laravel audio and video conversion, thumbnail generator and metadata editor package powered by ffmpeg

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Rafael Sampaio
by Closca Costel

laravel converter ffmpeg ffprobe