Skip to content

Commit

Permalink
Merge pull request #81 from alchemy-fr/fix-dimensions
Browse files Browse the repository at this point in the history
Fix dimensions
  • Loading branch information
romainneutron committed Dec 17, 2013
2 parents 197b534 + 9dd5dec commit 8dfaf18
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
CHANGELOG
---------

* 0.4.4 (12-17-2013)

* Fix width / height dimensions extraction.

* 0.4.3 (12-02-2013)

* Fix using rotate and resize filters at the same time (#78)
Expand Down
4 changes: 3 additions & 1 deletion src/FFMpeg/FFProbe/DataMapping/Stream.php
Expand Up @@ -71,7 +71,9 @@ public function getDimensions()
}

if (null !== $displayRatio && null !== $sampleRatio) {
$width = round($width / $sampleRatio[0] * $sampleRatio[1] * $displayRatio[0] / $displayRatio[1]);
if ($sampleRatio[0] !== 1 && $sampleRatio[1] !== 1) {
$width = round($width / $sampleRatio[0] * $sampleRatio[1] * $displayRatio[0] / $displayRatio[1]);
}
}

return new Dimension($width, $height);
Expand Down
8 changes: 7 additions & 1 deletion tests/FFMpeg/Tests/FFProbe/DataMapping/StreamTest.php
Expand Up @@ -83,6 +83,12 @@ public function testGetDimensionsFromVideoWithDisplayRatio()
$this->assertEquals(new Dimension(1280, 720), $stream->getDimensions());
}

public function testGetDimensionsFromVideoWith11SampleRatio()
{
$stream = new Stream(array('codec_type' => 'video', 'width' => 1920, 'height' => 1080, 'sample_aspect_ratio' => '1:1', 'display_aspect_ratio' => '16:9'));
$this->assertEquals(new Dimension(1920, 1080), $stream->getDimensions());
}

/**
* @dataProvider provideInvalidRatios
*/
Expand All @@ -91,7 +97,7 @@ 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'));
Expand Down

0 comments on commit 8dfaf18

Please sign in to comment.