Fix video single pass encodings

This commit is contained in:
Romain Neutron 2013-10-10 14:59:38 +02:00
commit 169e63a547
2 changed files with 46 additions and 14 deletions

View file

@ -124,9 +124,10 @@ class Video extends Audio
$pass[] = $i; $pass[] = $i;
$pass[] = '-passlogfile'; $pass[] = '-passlogfile';
$pass[] = $passPrefix; $pass[] = $passPrefix;
$pass[] = $outputPathfile;
} }
$pass[] = $outputPathfile;
$passes[] = $pass; $passes[] = $pass;
} }

View file

@ -194,7 +194,7 @@ class VideoTest extends AbstractStreamableTestCase
$capturedCommands = array(); $capturedCommands = array();
$capturedListeners = null; $capturedListeners = null;
$driver->expects($this->exactly(2)) $driver->expects($this->exactly(count($expectedCommands)))
->method('command') ->method('command')
->with($this->isType('array'), false, $this->anything()) ->with($this->isType('array'), false, $this->anything())
->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands, &$capturedListeners) { ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands, &$capturedListeners) {
@ -207,9 +207,10 @@ class VideoTest extends AbstractStreamableTestCase
$video = new Video(__FILE__, $driver, $ffprobe); $video = new Video(__FILE__, $driver, $ffprobe);
$video->save($format, $outputPathfile); $video->save($format, $outputPathfile);
$prefix = null;
foreach ($capturedCommands as $passKey => $pass) { foreach ($capturedCommands as $passKey => $pass) {
$prefix = null;
if (count($expectedCommands) > 1) {
// look for pass commands only in multipass cases
foreach ($pass as $command) { foreach ($pass as $command) {
$prefix = null; $prefix = null;
if (false !== strpos($command, '/pass-')) { if (false !== strpos($command, '/pass-')) {
@ -221,8 +222,9 @@ class VideoTest extends AbstractStreamableTestCase
if (null === $prefix) { if (null === $prefix) {
$this->fail('Unable to find pass prefix command.'); $this->fail('Unable to find pass prefix command.');
} }
}
$found = false; $found = false || (null === $prefix);
foreach ($pass as $key => $command) { foreach ($pass as $key => $command) {
if ($command === $prefix) { if ($command === $prefix) {
$found = true; $found = true;
@ -277,6 +279,26 @@ class VideoTest extends AbstractStreamableTestCase
->method('getPasses') ->method('getPasses')
->will($this->returnValue(2)); ->will($this->returnValue(2));
$audioVideoFormatSinglePass = $this->getMock('FFMpeg\Format\VideoInterface');
$audioVideoFormatSinglePass->expects($this->any())
->method('getExtraParams')
->will($this->returnValue(array()));
$audioVideoFormatSinglePass->expects($this->any())
->method('getVideoCodec')
->will($this->returnValue('gloubi-boulga-video'));
$audioVideoFormatSinglePass->expects($this->any())
->method('getAudioCodec')
->will($this->returnValue('patati-patata-audio'));
$audioVideoFormatSinglePass->expects($this->any())
->method('getKiloBitrate')
->will($this->returnValue(664));
$audioVideoFormatSinglePass->expects($this->any())
->method('getAudioKiloBitrate')
->will($this->returnValue(92));
$audioVideoFormatSinglePass->expects($this->any())
->method('getPasses')
->will($this->returnValue(1));
$formatExtra = $this->getMock('FFMpeg\Format\VideoInterface'); $formatExtra = $this->getMock('FFMpeg\Format\VideoInterface');
$formatExtra->expects($this->any()) $formatExtra->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
@ -344,6 +366,15 @@ class VideoTest extends AbstractStreamableTestCase
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-pass', '2', '-passlogfile', '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-pass', '2', '-passlogfile',
'/target/file', '/target/file',
)), null, $audioVideoFormat), )), null, $audioVideoFormat),
array(false, array(array(
'-y', '-i', __FILE__,
'-vcodec', 'gloubi-boulga-video',
'-acodec', 'patati-patata-audio', '-b:v', '664k',
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
'-qdiff', '4', '-trellis', '1', '-b:a', '92k',
'/target/file',
)), null, $audioVideoFormatSinglePass),
array(false, array(array( array(false, array(array(
'-y', '-i', __FILE__, '-y', '-i', __FILE__,
'extra', 'param','-b:v', '665k', 'extra', 'param','-b:v', '665k',