Merge pull request #29 from alchemy-fr/CodecQuality

Codec quality
This commit is contained in:
Romain Neutron 2013-02-07 04:05:53 -08:00
commit b8b42c7160
2 changed files with 23 additions and 17 deletions

View file

@ -361,31 +361,38 @@ class FFMpeg extends Binary
$builder->add('-vcodec')->add($format->getVideoCodec()); $builder->add('-vcodec')->add($format->getVideoCodec());
} }
$builder->add('-b')->add($format->getKiloBitrate() . 'k') $builder->add('-b:v')->add($format->getKiloBitrate() . 'k')
->add('-threads')->add($this->threads) ->add('-threads')->add($this->threads)
->add('-refs')->add('6')->add('-coder')->add('1')->add('-qmin') ->add('-refs')->add('6')
->add('10')->add('-qmax')->add('51') ->add('-coder')->add('1')
->add('-sc_threshold')->add('40')->add('-flags')->add('+loop') ->add('-sc_threshold')->add('40')
->add('-me_range')->add('16')->add('-subq')->add('7') ->add('-flags')->add('+loop')
->add('-i_qfactor')->add('0.71')->add('-qcomp')->add('0.6') ->add('-me_range')->add('16')
->add('-subq')->add('7')
->add('-i_qfactor')->add('0.71')
->add('-qcomp')->add('0.6')
->add('-qdiff')->add('4') ->add('-qdiff')->add('4')
->add('-trellis')->add('1')->add('-qscale')->add('1') ->add('-trellis')->add('1')
->add('-ab')->add('92k'); ->add('-b:a')->add('92k');
if ($format instanceof AudioTranscodable) { if ($format instanceof AudioTranscodable) {
$builder->add('-acodec')->add($format->getAudioCodec()); $builder->add('-acodec')->add($format->getAudioCodec());
} }
$tmpFile = new \SplFileInfo(tempnam(sys_get_temp_dir(), 'temp') . '.' . pathinfo($outputPathfile, PATHINFO_EXTENSION)); $passPrefix = uniqid('pass-');
$pass1 = $builder; $pass1 = $builder;
$pass2 = clone $builder; $pass2 = clone $builder;
$passes[] = $pass1 $passes[] = $pass1
->add('-pass')->add('1')->add('-an')->add($tmpFile->getPathname()) ->add('-pass')->add('1')
->add('-passlogfile')->add($passPrefix)
->add('-an')->add($outputPathfile)
->getProcess(); ->getProcess();
$passes[] = $pass2 $passes[] = $pass2
->add('-pass')->add('2')->add('-ac')->add('2') ->add('-pass')->add('2')
->add('-passlogfile')->add($passPrefix)
->add('-ac')->add('2')
->add('-ar')->add('44100')->add($outputPathfile) ->add('-ar')->add('44100')->add($outputPathfile)
->getProcess(); ->getProcess();
@ -400,10 +407,9 @@ class FFMpeg extends Binary
} }
} }
$this->cleanupTemporaryFile($tmpFile->getPathname()); $this->cleanupTemporaryFile(getcwd() . '/' . $passPrefix . '-0.log');
$this->cleanupTemporaryFile(getcwd() . '/ffmpeg2pass-0.log'); $this->cleanupTemporaryFile(getcwd() . '/' . $passPrefix . '-0.log');
$this->cleanupTemporaryFile(getcwd() . '/av2pass-0.log'); $this->cleanupTemporaryFile(getcwd() . '/' . $passPrefix . '-0.log.mbtree');
$this->cleanupTemporaryFile(getcwd() . '/ffmpeg2pass-0.log.mbtree');
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
$this->logger->addInfo(sprintf('FFmpeg command failed')); $this->logger->addInfo(sprintf('FFmpeg command failed'));

View file

@ -203,7 +203,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase
$format = new Format\Video\X264(); $format = new Format\Video\X264();
$format-> setDimensions(32, 32); $format-> setDimensions(32, 32);
$this->object->open(__DIR__ . '/../../files/Test.ogv'); $this->object->open(__DIR__ . '/../../files/EmpireStateofMind-Jay-Z.mov');
$this->object->encode($format, $dest); $this->object->encode($format, $dest);
$this->probe->probeFormat($dest); $this->probe->probeFormat($dest);