Add convenient Stream::getDimensions method to extract video dimension.
This commit is contained in:
parent
9fcb485d49
commit
15711a0e50
5 changed files with 134 additions and 10 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FFMpeg\Tests\FFProbe\DataMapping;
|
||||
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use FFMpeg\Tests\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
|
||||
|
|
@ -40,4 +41,45 @@ class StreamTest extends TestCase
|
|||
array(false, array('codec_type' => 'audio')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException FFMpeg\Exception\LogicException
|
||||
* @expectedExceptionMessage Dimensions can only be retrieved from video streams.
|
||||
*/
|
||||
public function testGetDimensionsFromAudio()
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'audio'));
|
||||
$stream->getDimensions();
|
||||
}
|
||||
|
||||
public function testGetDimensionsFromVideo()
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720));
|
||||
$this->assertEquals(new Dimension(960, 720), $stream->getDimensions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidPropertiesForDimensionsExtraction
|
||||
* @expectedException FFMpeg\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Unable to extract dimensions.
|
||||
*/
|
||||
public function testUnableToGetDimensionsFromVideo($properties)
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960));
|
||||
$stream->getDimensions();
|
||||
}
|
||||
|
||||
public function provideInvalidPropertiesForDimensionsExtraction()
|
||||
{
|
||||
return array(
|
||||
array('codec_type' => 'video', 'width' => 960),
|
||||
array('codec_type' => 'video', 'height' => 960),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetDimensionsFromVideoWithDisplayRatio()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue