Merge branch '0.3'
Conflicts: CHANGELOG.md
This commit is contained in:
commit
b6ec274d2e
3 changed files with 24 additions and 1 deletions
|
|
@ -3,6 +3,10 @@ CHANGELOG
|
||||||
|
|
||||||
* 0.4.0 (xx-xx-xxxx)
|
* 0.4.0 (xx-xx-xxxx)
|
||||||
|
|
||||||
|
* 0.3.4 (05-09-2013)
|
||||||
|
|
||||||
|
* Fix Invalid ratio computing.
|
||||||
|
|
||||||
* 0.3.3 (05-09-2013)
|
* 0.3.3 (05-09-2013)
|
||||||
|
|
||||||
* Add convenient Stream::getDimensions method to extract video dimension.
|
* Add convenient Stream::getDimensions method to extract video dimension.
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,12 @@ class Stream extends AbstractData
|
||||||
if ($stream->has($name)) {
|
if ($stream->has($name)) {
|
||||||
$ratio = $stream->get($name);
|
$ratio = $stream->get($name);
|
||||||
if (preg_match('/\d+:\d+/', $ratio)) {
|
if (preg_match('/\d+:\d+/', $ratio)) {
|
||||||
return array_map(function ($int) { return (int) $int; }, explode(':', $ratio));
|
$data = array_filter(explode(':', $ratio), function ($int) {
|
||||||
|
return $int > 0;
|
||||||
|
});
|
||||||
|
if (2 === count($data)) {
|
||||||
|
return array_map(function ($int) { return (int) $int; }, $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,4 +82,18 @@ class StreamTest extends TestCase
|
||||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => '4:3', 'display_aspect_ratio' => '16:9'));
|
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => '4:3', 'display_aspect_ratio' => '16:9'));
|
||||||
$this->assertEquals(new Dimension(1280, 720), $stream->getDimensions());
|
$this->assertEquals(new Dimension(1280, 720), $stream->getDimensions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideInvalidRatios
|
||||||
|
*/
|
||||||
|
public function testGetDimensionsFromVideoWithInvalidDisplayRatio($invalidRatio)
|
||||||
|
{
|
||||||
|
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => $invalidRatio, 'display_aspect_ratio' => '16:9'));
|
||||||
|
$this->assertEquals(new Dimension(960, 720), $stream->getDimensions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideInvalidRatios()
|
||||||
|
{
|
||||||
|
return array(array('0:1'), array('2:1:3'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue