2012-04-13 10:20:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|