Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests... Remove -pre:v option for mp4 encoder. #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nbproject
composer.lock
64 changes: 59 additions & 5 deletions Tests/Html5Video/Html5VideoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ protected function setUp() {
}
}

protected function invokeMethod(&$object, $methodName, array $parameters = array())
{
$reflection = new \ReflectionClass(get_class($object));
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs($object, $parameters);
}

protected function createHtml5VideoMock($process = null, $cache = null) {
if (!$process) {
$process = new Process\ProcessMock();
Expand Down Expand Up @@ -71,16 +79,62 @@ public function testGetVersionWin() {
$this->assertEquals(array(2, 0, 0), $html5video->getVersion());
}

public function testGetVersion() {
$outputs = array(
'ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers',
' built on Apr 2 2013 17:02:36 with gcc 4.6.3'
public function testGetVersionDataProvider()
{
return array(
array(
array(
'ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers',
' built on Apr 2 2013 17:02:36 with gcc 4.6.3'
),
array(0, 8, 6)
),
array(
array(
'ffmpeg version git-2015-04-02-d759844 Copyright (c) 2000-2015 the FFmpeg developers',
'built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)'
),
array(2, 0, 0)
),
);
}

/**
* @dataProvider testGetVersionDataProvider
*/
public function testGetVersion($outputs, $result) {
$commandMock = new Process\ProcessMock(array('ffmpeg -version' => $outputs));
$html5video = $this->createHtml5VideoMock($commandMock);

$version = $html5video->getVersion();
$this->assertEquals(array(0, 8, 6), $version);
$this->assertEquals($result, $version);
}

public function testIsVersionIsGreaterOrEqualDataProvider()
{
return array(
array(array(2, 0, 0), array(0, 8), true),
array(array(2, 0, 0), array(0, 8, 0), true),
array(array(2, 0, 0), array(0, 11, 0), true),
array(array(2, 0, 0), array(2, 0, 0), true),
array(array(2, 0, 0), array(2, 0, 1), false),
array(array(2, 0, 0), array(2, 1), false),
);
}

/**
* @dataProvider testIsVersionIsGreaterOrEqualDataProvider
*/
public function testIsVersionIsGreaterOrEqual($version, $other, $result)
{
$outputs = array(
'ffmpeg version '.implode('.', $version).'-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers',
' built on Apr 2 2013 17:02:36 with gcc 4.6.3'
);
$commandMock = new Process\ProcessMock(array('ffmpeg -version' => $outputs));
$html5video = $this->createHtml5VideoMock($commandMock);

$this->assertSame($result, $this->invokeMethod($html5video, 'isVersionIsGreaterOrEqual', array($html5video->getVersion(), $other)));
}

public function testGetEncodersForVersion086() {
Expand Down
2 changes: 1 addition & 1 deletion src/Html5Video/Converter/Mp4Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function __construct($Process, $Driver, $config, $profile, $videoCodec, $audioCo
protected function addVideoArgs(&$options) {
parent::addVideoArgs($options);

$this->addOption('-pre:v', 'baseline');
$this->addOption('-profile:v', 'baseline');
$this->addOption('-level', 30);
$this->addOption('-refs', 1);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Html5Video/Html5Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ protected function parseInfo($lines) {
protected function isVersionIsGreaterOrEqual($version, $other) {
$max = min(count($version), count($other));
for ($i = 0; $i < $max; $i++) {
if ($version[$i] < $other[$i]) {
if ($version[$i] > $other[$i]) {
return true;
} elseif ($version[$i] < $other[$i]) {
return false;
}
}
Expand Down