ffmpeg-mappable-media/src/FFMpeg/FFMpegServiceProvider.php

64 lines
1.8 KiB
PHP
Raw Normal View History

2012-09-03 14:52:53 +02:00
<?php
2012-09-03 16:07:56 +02:00
/*
* This file is part of PHP-FFmpeg.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2012-09-03 14:52:53 +02:00
namespace FFMpeg;
use FFMpeg\FFMpeg;
use FFMpeg\FFProbe;
use Monolog\Logger;
use Monolog\Handler\NullHandler;
use Silex\Application;
use Silex\ServiceProviderInterface;
class FFMpegServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
2012-10-08 14:31:21 +02:00
if (isset($app['monolog'])) {
$app['ffmpeg.logger'] = function() use ($app) {
return $app['monolog'];
};
} else {
2012-09-03 14:52:53 +02:00
$app['ffmpeg.logger'] = $app->share(function(Application $app) {
$logger = new Logger('FFMpeg logger');
$logger->pushHandler(new NullHandler());
return $logger;
});
}
$app['ffmpeg.ffmpeg'] = $app->share(function(Application $app) {
if (isset($app['ffmpeg.ffmpeg.binary'])) {
$ffmpeg = new FFMpeg($app['ffmpeg.ffmpeg.binary'], $app['ffmpeg.logger']);
2012-09-03 14:52:53 +02:00
} else {
$ffmpeg = FFMpeg::load($app['ffmpeg.logger']);
2012-09-03 14:52:53 +02:00
}
return $ffmpeg
->setProber($app['ffmpeg.ffprobe'])
->setThreads(isset($app['ffmpeg.threads']) ? $app['ffmpeg.threads'] : 1);
2012-09-03 14:52:53 +02:00
});
$app['ffmpeg.ffprobe'] = $app->share(function(Application $app) {
if (isset($app['ffmpeg.ffprobe.binary'])) {
return new FFProbe($app['ffmpeg.ffprobe.binary'], $app['ffmpeg.logger']);
} else {
return FFProbe::load($app['ffmpeg.logger']);
}
});
}
public function boot(Application $app)
{
}
}