| 
									
										
										
										
											2012-04-13 10:20:54 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-13 14:34:53 +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-04-13 10:20:54 +02:00
										 |  |  | namespace FFMpeg; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FFProbe extends Binary | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function probeFormat($pathfile) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ( ! is_file($pathfile)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2012-04-13 11:01:53 +02:00
										 |  |  |             throw new \InvalidArgumentException($pathfile); | 
					
						
							| 
									
										
										
										
											2012-04-13 10:20:54 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $cmd = $this->binary . ' ' . $pathfile . ' -show_format'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->executeProbe($cmd); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function probeStreams($pathfile) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ( ! is_file($pathfile)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2012-04-13 11:01:53 +02:00
										 |  |  |             throw new \InvalidArgumentException($pathfile); | 
					
						
							| 
									
										
										
										
											2012-04-13 10:20:54 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $cmd = $this->binary . ' ' . $pathfile . ' -show_streams'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->executeProbe($cmd); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected function executeProbe($command) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $process = new \Symfony\Component\Process\Process($command); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $process->run(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ( ! $process->isSuccessful()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2012-04-13 11:01:53 +02:00
										 |  |  |             throw new \RuntimeException(sprintf('Failed to probe %s', $command)); | 
					
						
							| 
									
										
										
										
											2012-04-13 10:20:54 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $process->getOutput(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected static function getBinaryName() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return 'ffprobe'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |