From c4fcee4517bd33936128280997dce7ec2fe034ec Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Dec 2013 17:38:12 +0100 Subject: [PATCH 1/2] Fix width / height detection --- src/FFMpeg/FFProbe/DataMapping/Stream.php | 4 +++- tests/FFMpeg/Tests/FFProbe/DataMapping/StreamTest.php | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/FFMpeg/FFProbe/DataMapping/Stream.php b/src/FFMpeg/FFProbe/DataMapping/Stream.php index 5c32520..55957af 100644 --- a/src/FFMpeg/FFProbe/DataMapping/Stream.php +++ b/src/FFMpeg/FFProbe/DataMapping/Stream.php @@ -71,7 +71,9 @@ class Stream extends AbstractData } 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); diff --git a/tests/FFMpeg/Tests/FFProbe/DataMapping/StreamTest.php b/tests/FFMpeg/Tests/FFProbe/DataMapping/StreamTest.php index 6f71d7e..dc28776 100644 --- a/tests/FFMpeg/Tests/FFProbe/DataMapping/StreamTest.php +++ b/tests/FFMpeg/Tests/FFProbe/DataMapping/StreamTest.php @@ -83,6 +83,12 @@ class StreamTest extends TestCase $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 */ @@ -91,7 +97,7 @@ class StreamTest extends TestCase $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')); From 9dd5dec9fd5dd7bb48228418c99a02b89088d994 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Dec 2013 17:38:54 +0100 Subject: [PATCH 2/2] Update Changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 490e027..b6f5e14 100644 --- a/CHANGELOG.md +++ b/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)