| 
									
										
										
										
											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; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | use Doctrine\Common\Cache\ArrayCache; | 
					
						
							| 
									
										
										
										
											2012-09-03 14:52:53 +02:00
										 |  |  | use Silex\Application; | 
					
						
							|  |  |  | use Silex\ServiceProviderInterface; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FFMpegServiceProvider implements ServiceProviderInterface | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public function register(Application $app) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |         $app['ffmpeg.configuration'] = array(); | 
					
						
							|  |  |  |         $app['ffmpeg.default.configuration'] = array( | 
					
						
							|  |  |  |             'ffmpeg.threads'   => 4, | 
					
						
							|  |  |  |             'ffmpeg.timeout'   => 300, | 
					
						
							|  |  |  |             'ffmpeg.binaries'  => array('avconv', 'ffmpeg'), | 
					
						
							|  |  |  |             'ffprobe.timeout'  => 30, | 
					
						
							|  |  |  |             'ffprobe.binaries' => array('avprobe', 'ffprobe'), | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |         $app['ffmpeg.logger'] = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $app['ffmpeg.configuration.build'] = $app->share(function (Application $app) { | 
					
						
							|  |  |  |             return array_replace($app['ffmpeg.default.configuration'], $app['ffmpeg.configuration']); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 17:39:24 +01:00
										 |  |  |         $app['ffmpeg'] = $app['ffmpeg.ffmpeg'] = $app->share(function (Application $app) { | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |             $configuration = $app['ffmpeg.configuration.build']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (isset($configuration['ffmpeg.timeout'])) { | 
					
						
							|  |  |  |                 $configuration['timeout'] = $configuration['ffmpeg.timeout']; | 
					
						
							| 
									
										
										
										
											2012-09-03 14:52:53 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2012-09-03 15:20:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |             return FFMpeg::create($configuration, $app['ffmpeg.logger'], $app['ffmpeg.ffprobe']); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $app['ffprobe.cache'] = $app->share(function () { | 
					
						
							|  |  |  |             return new ArrayCache(); | 
					
						
							| 
									
										
										
										
											2012-09-03 14:52:53 +02:00
										 |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 17:39:24 +01:00
										 |  |  |         $app['ffmpeg.ffprobe'] = $app->share(function (Application $app) { | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |             $configuration = $app['ffmpeg.configuration.build']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (isset($configuration['ffmpeg.timeout'])) { | 
					
						
							|  |  |  |                 $configuration['timeout'] = $configuration['ffprobe.timeout']; | 
					
						
							| 
									
										
										
										
											2012-09-03 14:52:53 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             return FFProbe::create($configuration, $app['ffmpeg.logger'], $app['ffprobe.cache']); | 
					
						
							| 
									
										
										
										
											2012-09-03 14:52:53 +02:00
										 |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function boot(Application $app) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |