Add Audio and Video interfaces
This commit is contained in:
		
					parent
					
						
							
								aa681f66b1
							
						
					
				
			
			
				commit
				
					
						94775176c9
					
				
			
		
					 14 changed files with 294 additions and 222 deletions
				
			
		|  | @ -54,7 +54,7 @@ class FFMpeg extends Binary | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function encode(Format\Format $format, $outputPathfile, $threads = 1) |     public function encode(Format\AudioFormat $format, $outputPathfile, $threads = 1) | ||||||
|     { |     { | ||||||
|         if ( ! $this->pathfile) |         if ( ! $this->pathfile) | ||||||
|         { |         { | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								src/FFMpeg/Format/AudioFormat.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/FFMpeg/Format/AudioFormat.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace FFMpeg\Format; | ||||||
|  | 
 | ||||||
|  | interface AudioFormat | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     public function getAudioCodec(); | ||||||
|  | 
 | ||||||
|  |     public function getAudioSampleRate(); | ||||||
|  | 
 | ||||||
|  |     public function getKiloBitrate(); | ||||||
|  | 
 | ||||||
|  | } | ||||||
							
								
								
									
										64
									
								
								src/FFMpeg/Format/DefaultAudioFormat.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								src/FFMpeg/Format/DefaultAudioFormat.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,64 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace FFMpeg\Format; | ||||||
|  | 
 | ||||||
|  | abstract class DefaultAudioFormat implements AudioFormat | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     protected $audioCodec; | ||||||
|  |     protected $audioSampleRate = 44100; | ||||||
|  |     protected $kiloBitrate     = 1000; | ||||||
|  | 
 | ||||||
|  |     public function getExtraParams() | ||||||
|  |     { | ||||||
|  |         return ''; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function getAudioCodec() | ||||||
|  |     { | ||||||
|  |         return $this->audioCodec; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function setAudioCodec($audioCodec) | ||||||
|  |     { | ||||||
|  |         if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs())) | ||||||
|  |         { | ||||||
|  |             throw new \InvalidArgumentException('Wrong audiocodec value'); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->audioCodec = $audioCodec; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function getAudioSampleRate() | ||||||
|  |     { | ||||||
|  |         return $this->audioSampleRate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function setAudioSampleRate($audioSampleRate) | ||||||
|  |     { | ||||||
|  |         if ($audioSampleRate < 1) | ||||||
|  |         { | ||||||
|  |             throw new \InvalidArgumentException('Wrong audio sample rate value'); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->audioSampleRate = (int) $audioSampleRate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function getKiloBitrate() | ||||||
|  |     { | ||||||
|  |         return $this->kiloBitrate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function setKiloBitrate($kiloBitrate) | ||||||
|  |     { | ||||||
|  |         if ($kiloBitrate < 1) | ||||||
|  |         { | ||||||
|  |             throw new \InvalidArgumentException('Wrong kiloBitrate value'); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->kiloBitrate = (int) $kiloBitrate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     abstract protected function getAvailableAudioCodecs(); | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -2,16 +2,13 @@ | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format; | ||||||
| 
 | 
 | ||||||
| abstract class DefaultFormat implements Format | abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFormat | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     protected $width; |     protected $width; | ||||||
|     protected $height; |     protected $height; | ||||||
|     protected $frameRate = 25; |     protected $frameRate = 25; | ||||||
|     protected $audioCodec; |  | ||||||
|     protected $audioSampleRate = 44100; |  | ||||||
|     protected $videoCodec; |     protected $videoCodec; | ||||||
|     protected $kiloBitrate     = 1000; |  | ||||||
|     protected $GOPsize   = 25; |     protected $GOPsize   = 25; | ||||||
| 
 | 
 | ||||||
|     public function __construct($width, $height) |     public function __construct($width, $height) | ||||||
|  | @ -19,11 +16,6 @@ abstract class DefaultFormat implements Format | ||||||
|         $this->setDimensions($width, $height); |         $this->setDimensions($width, $height); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function getExtraParams() |  | ||||||
|     { |  | ||||||
|         return ''; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function getWidth() |     public function getWidth() | ||||||
|     { |     { | ||||||
|         return $this->width; |         return $this->width; | ||||||
|  | @ -66,36 +58,6 @@ abstract class DefaultFormat implements Format | ||||||
|         $this->frameRate = (int) $frameRate; |         $this->frameRate = (int) $frameRate; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function getAudioCodec() |  | ||||||
|     { |  | ||||||
|         return $this->audioCodec; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function setAudioCodec($audioCodec) |  | ||||||
|     { |  | ||||||
|         if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs())) |  | ||||||
|         { |  | ||||||
|             throw new \InvalidArgumentException('Wrong audiocodec value'); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         $this->audioCodec = $audioCodec; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function getAudioSampleRate() |  | ||||||
|     { |  | ||||||
|         return $this->audioSampleRate; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function setAudioSampleRate($audioSampleRate) |  | ||||||
|     { |  | ||||||
|         if ($audioSampleRate < 1) |  | ||||||
|         { |  | ||||||
|             throw new \InvalidArgumentException('Wrong audio sample rate value'); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         $this->audioSampleRate = (int) $audioSampleRate; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function getVideoCodec() |     public function getVideoCodec() | ||||||
|     { |     { | ||||||
|         return $this->videoCodec; |         return $this->videoCodec; | ||||||
|  | @ -111,21 +73,6 @@ abstract class DefaultFormat implements Format | ||||||
|         $this->videoCodec = $videoCodec; |         $this->videoCodec = $videoCodec; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function getKiloBitrate() |  | ||||||
|     { |  | ||||||
|         return $this->kiloBitrate; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function setKiloBitrate($kiloBitrate) |  | ||||||
|     { |  | ||||||
|         if ($kiloBitrate < 1) |  | ||||||
|         { |  | ||||||
|             throw new \InvalidArgumentException('Wrong kiloBitrate value'); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         $this->kiloBitrate = (int) $kiloBitrate; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function getGOPsize() |     public function getGOPsize() | ||||||
|     { |     { | ||||||
|         return $this->GOPsize; |         return $this->GOPsize; | ||||||
|  | @ -172,8 +119,6 @@ abstract class DefaultFormat implements Format | ||||||
|         return (int) $ret; |         return (int) $ret; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     abstract protected function getAvailableAudioCodecs(); |  | ||||||
| 
 |  | ||||||
|     abstract protected function getAvailableVideoCodecs(); |     abstract protected function getAvailableVideoCodecs(); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -1,8 +1,10 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format\Video; | ||||||
| 
 | 
 | ||||||
| class Ogg extends DefaultFormat | use FFMpeg\Format\DefaultVideoFormat; | ||||||
|  | 
 | ||||||
|  | class Ogg extends DefaultVideoFormat | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     protected $audioCodec = 'libvorbis'; |     protected $audioCodec = 'libvorbis'; | ||||||
|  | @ -1,8 +1,10 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format\Video; | ||||||
| 
 | 
 | ||||||
| class WebM extends DefaultFormat | use FFMpeg\Format\DefaultVideoFormat; | ||||||
|  | 
 | ||||||
|  | class WebM extends DefaultVideoFormat | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     protected $audioCodec = 'libvorbis'; |     protected $audioCodec = 'libvorbis'; | ||||||
|  | @ -1,8 +1,10 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format\Video; | ||||||
| 
 | 
 | ||||||
| class X264 extends DefaultFormat | use FFMpeg\Format\DefaultVideoFormat; | ||||||
|  | 
 | ||||||
|  | class X264 extends DefaultVideoFormat | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     protected $audioCodec = 'libmp3lame'; |     protected $audioCodec = 'libmp3lame'; | ||||||
|  | @ -2,25 +2,17 @@ | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format; | ||||||
| 
 | 
 | ||||||
| interface Format | interface VideoFormat | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     public function getExtraParams(); |  | ||||||
| 
 |  | ||||||
|     public function getWidth(); |     public function getWidth(); | ||||||
| 
 | 
 | ||||||
|     public function getHeight(); |     public function getHeight(); | ||||||
| 
 | 
 | ||||||
|     public function getFrameRate(); |     public function getFrameRate(); | ||||||
| 
 | 
 | ||||||
|     public function getAudioCodec(); |  | ||||||
| 
 |  | ||||||
|     public function getAudioSampleRate(); |  | ||||||
| 
 |  | ||||||
|     public function getVideoCodec(); |     public function getVideoCodec(); | ||||||
| 
 | 
 | ||||||
|     public function getKiloBitrate(); |  | ||||||
| 
 |  | ||||||
|     public function getGOPSize(); |     public function getGOPSize(); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -53,7 +53,6 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase | ||||||
|         unlink($dest); |         unlink($dest); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\FFMpeg::extractImage |      * @covers FFMpeg\FFMpeg::extractImage | ||||||
|      * @expectedException \RuntimeException |      * @expectedException \RuntimeException | ||||||
|  | @ -69,7 +68,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase | ||||||
|      */ |      */ | ||||||
|     public function testEncode() |     public function testEncode() | ||||||
|     { |     { | ||||||
|         $this->object->encode(new Format\WebM(32, 32), './invalid.file'); |         $this->object->encode(new Format\Video\WebM(32, 32), './invalid.file'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -83,7 +82,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase | ||||||
| 
 | 
 | ||||||
|         $ffmpeg = new FFMpeg('wrongbinary', $logger); |         $ffmpeg = new FFMpeg('wrongbinary', $logger); | ||||||
|         $ffmpeg->open(__DIR__ . '/../../files/Test.ogv'); |         $ffmpeg->open(__DIR__ . '/../../files/Test.ogv'); | ||||||
|         $ffmpeg->encode(new Format\WebM(32, 32), './invalid.file'); |         $ffmpeg->encode(new Format\Video\WebM(32, 32), './invalid.file'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -94,7 +93,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase | ||||||
|         $dest = __DIR__ . '/../../files/encode_test.webm'; |         $dest = __DIR__ . '/../../files/encode_test.webm'; | ||||||
| 
 | 
 | ||||||
|         $this->object->open(__DIR__ . '/../../files/Test.ogv'); |         $this->object->open(__DIR__ . '/../../files/Test.ogv'); | ||||||
|         $this->object->encode(new Format\WebM(32, 32), $dest); |         $this->object->encode(new Format\Video\WebM(32, 32), $dest); | ||||||
| 
 | 
 | ||||||
|         $this->probe->probeFormat($dest); |         $this->probe->probeFormat($dest); | ||||||
| 
 | 
 | ||||||
|  | @ -109,7 +108,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase | ||||||
|         $dest = __DIR__ . '/../../files/encode_test.ogv'; |         $dest = __DIR__ . '/../../files/encode_test.ogv'; | ||||||
| 
 | 
 | ||||||
|         $this->object->open(__DIR__ . '/../../files/Test.ogv'); |         $this->object->open(__DIR__ . '/../../files/Test.ogv'); | ||||||
|         $this->object->encode(new Format\Ogg(32, 32), $dest); |         $this->object->encode(new Format\Video\Ogg(32, 32), $dest); | ||||||
| 
 | 
 | ||||||
|         $this->probe->probeFormat($dest); |         $this->probe->probeFormat($dest); | ||||||
| 
 | 
 | ||||||
|  | @ -124,7 +123,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase | ||||||
|         $dest = __DIR__ . '/../../files/encode_test.mp4'; |         $dest = __DIR__ . '/../../files/encode_test.mp4'; | ||||||
| 
 | 
 | ||||||
|         $this->object->open(__DIR__ . '/../../files/Test.ogv'); |         $this->object->open(__DIR__ . '/../../files/Test.ogv'); | ||||||
|         $this->object->encode(new Format\X264(32, 32), $dest); |         $this->object->encode(new Format\Video\X264(32, 32), $dest); | ||||||
| 
 | 
 | ||||||
|         $this->probe->probeFormat($dest); |         $this->probe->probeFormat($dest); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										154
									
								
								tests/src/FFMpeg/Format/DefaultAudioFormatTest.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										154
									
								
								tests/src/FFMpeg/Format/DefaultAudioFormatTest.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,154 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace FFMpeg\Format; | ||||||
|  | 
 | ||||||
|  | require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/DefaultAudioFormat.php'; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Test class for DefaultAudioFormat. | ||||||
|  |  * Generated by PHPUnit on 2012-04-13 at 12:32:39. | ||||||
|  |  */ | ||||||
|  | class DefaultAudioFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @var DefaultAudioFormat | ||||||
|  |      */ | ||||||
|  |     protected $object; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets up the fixture, for example, opens a network connection. | ||||||
|  |      * This method is called before a test is executed. | ||||||
|  |      */ | ||||||
|  |     protected function setUp() | ||||||
|  |     { | ||||||
|  |         $this->object = new DefaultAudioFormatTester(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Tears down the fixture, for example, closes a network connection. | ||||||
|  |      * This method is called after a test is executed. | ||||||
|  |      */ | ||||||
|  |     protected function tearDown() | ||||||
|  |     { | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::getExtraParams | ||||||
|  |      */ | ||||||
|  |     public function testGetExtraParams() | ||||||
|  |     { | ||||||
|  |         $this->assertEquals('-f format', $this->object->getExtraParams()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::getAudioCodec | ||||||
|  |      */ | ||||||
|  |     public function testGetAudioCodec() | ||||||
|  |     { | ||||||
|  |         $this->assertEquals('audiocodec1', $this->object->getAudioCodec()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::setAudioCodec | ||||||
|  |      */ | ||||||
|  |     public function testSetAudioCodec() | ||||||
|  |     { | ||||||
|  |         $this->object->setAudioCodec('audiocodec2'); | ||||||
|  |         $this->assertEquals('audiocodec2', $this->object->getAudioCodec()); | ||||||
|  |         $this->object->setAudioCodec('audiocodec1'); | ||||||
|  |         $this->assertEquals('audiocodec1', $this->object->getAudioCodec()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::setAudioCodec | ||||||
|  |      * @expectedException \InvalidArgumentException | ||||||
|  |      */ | ||||||
|  |     public function testSetWrongAudioCodec() | ||||||
|  |     { | ||||||
|  |         $this->object->setAudioCodec('audiocodec4'); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::getAudioSampleRate | ||||||
|  |      */ | ||||||
|  |     public function testGetAudioSampleRate() | ||||||
|  |     { | ||||||
|  |         $this->assertEquals(44100, $this->object->getAudioSampleRate()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::setAudioSampleRate | ||||||
|  |      */ | ||||||
|  |     public function testSetAudioSampleRate() | ||||||
|  |     { | ||||||
|  |         $this->object->setAudioSampleRate(22050); | ||||||
|  |         $this->assertEquals(22050, $this->object->getAudioSampleRate()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::setAudioSampleRate | ||||||
|  |      * @expectedException \InvalidArgumentException | ||||||
|  |      * @dataProvider getWrongAudioSampleRate | ||||||
|  |      */ | ||||||
|  |     public function testSetWrongAudioSampleRate($samplerate) | ||||||
|  |     { | ||||||
|  |         $this->object->setAudioSampleRate($samplerate); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function getWrongAudioSampleRate() | ||||||
|  |     { | ||||||
|  |         return array(array(-5), array(0)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::getKiloBitrate | ||||||
|  |      */ | ||||||
|  |     public function testGetKiloBitrate() | ||||||
|  |     { | ||||||
|  |         $this->assertEquals(1000, $this->object->getKiloBitrate()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::setKiloBitrate | ||||||
|  |      */ | ||||||
|  |     public function testSetKiloBitrate() | ||||||
|  |     { | ||||||
|  |         $this->object->setKiloBitrate(500); | ||||||
|  |         $this->assertEquals(500, $this->object->getKiloBitrate()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @covers FFMpeg\Format\DefaultAudioFormat::setKiloBitrate | ||||||
|  |      * @dataProvider getWrongKiloBitrate | ||||||
|  |      * @expectedException \InvalidArgumentException | ||||||
|  |      */ | ||||||
|  |     public function testSetWrongKiloBitrate($kbrate) | ||||||
|  |     { | ||||||
|  |         $this->object->setKiloBitrate($kbrate); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function getWrongKiloBitrate() | ||||||
|  |     { | ||||||
|  |         return array(array(-5), array(0)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class DefaultAudioFormatTester extends DefaultAudioFormat | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     protected $audioCodec = 'audiocodec1'; | ||||||
|  | 
 | ||||||
|  |     protected function getAvailableAudioCodecs() | ||||||
|  |     { | ||||||
|  |         return array('audiocodec1', 'audiocodec2', 'audiocodec3'); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function getExtraParams() | ||||||
|  |     { | ||||||
|  |         return '-f format'; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -2,29 +2,33 @@ | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format; | ||||||
| 
 | 
 | ||||||
| require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/DefaultFormat.php'; | require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/DefaultVideoFormat.php'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Test class for DefaultFormat. |  * Test class for DefaultVideoFormat. | ||||||
|  * Generated by PHPUnit on 2012-04-13 at 11:03:02. |  * Generated by PHPUnit on 2012-04-13 at 12:32:40. | ||||||
|  */ |  */ | ||||||
| class DefaultFormatTest extends \PHPUnit_Framework_TestCase | class DefaultVideoFormatTest extends \PHPUnit_Framework_TestCase | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @var DefaultFormat |      * @var DefaultVideoFormat | ||||||
|      */ |      */ | ||||||
|     protected $object; |     protected $object; | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets up the fixture, for example, opens a network connection. | ||||||
|  |      * This method is called before a test is executed. | ||||||
|  |      */ | ||||||
|     protected function setUp() |     protected function setUp() | ||||||
|     { |     { | ||||||
|         $this->object = new DefaultFormatTester(320, 240); |         $this->object = new DefaultVideoFormatTester(320, 240); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::__construct |      * @covers FFMpeg\Format\DefaultVideoFormat::__construct | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getWidth |      * @covers FFMpeg\Format\DefaultVideoFormat::getWidth | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getHeight |      * @covers FFMpeg\Format\DefaultVideoFormat::getHeight | ||||||
|      */ |      */ | ||||||
|     public function testConstruct() |     public function testConstruct() | ||||||
|     { |     { | ||||||
|  | @ -33,15 +37,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getExtraParams |      * @covers FFMpeg\Format\DefaultVideoFormat::setDimensions | ||||||
|      */ |  | ||||||
|     public function testGetExtraParams() |  | ||||||
|     { |  | ||||||
|         $this->assertEquals('-f format', $this->object->getExtraParams()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setDimensions |  | ||||||
|      */ |      */ | ||||||
|     public function testSetDimensions() |     public function testSetDimensions() | ||||||
|     { |     { | ||||||
|  | @ -55,7 +51,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setDimensions |      * @covers FFMpeg\Format\DefaultVideoFormat::setDimensions | ||||||
|      * @dataProvider getWrongDimensions |      * @dataProvider getWrongDimensions | ||||||
|      * @expectedException \InvalidArgumentException |      * @expectedException \InvalidArgumentException | ||||||
|      */ |      */ | ||||||
|  | @ -82,7 +78,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getFrameRate |      * @covers FFMpeg\Format\DefaultVideoFormat::getFrameRate | ||||||
|      */ |      */ | ||||||
|     public function testGetFrameRate() |     public function testGetFrameRate() | ||||||
|     { |     { | ||||||
|  | @ -90,7 +86,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setFrameRate |      * @covers FFMpeg\Format\DefaultVideoFormat::setFrameRate | ||||||
|      */ |      */ | ||||||
|     public function testSetFrameRate() |     public function testSetFrameRate() | ||||||
|     { |     { | ||||||
|  | @ -99,7 +95,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setFrameRate |      * @covers FFMpeg\Format\DefaultVideoFormat::setFrameRate | ||||||
|      * @dataProvider getWrongFrameRates |      * @dataProvider getWrongFrameRates | ||||||
|      * @expectedException \InvalidArgumentException |      * @expectedException \InvalidArgumentException | ||||||
|      */ |      */ | ||||||
|  | @ -119,67 +115,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getAudioCodec |      * @covers FFMpeg\Format\DefaultVideoFormat::getVideoCodec | ||||||
|      */ |  | ||||||
|     public function testGetAudioCodec() |  | ||||||
|     { |  | ||||||
|         $this->assertEquals('audiocodec1', $this->object->getAudioCodec()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setAudioCodec |  | ||||||
|      */ |  | ||||||
|     public function testSetAudioCodec() |  | ||||||
|     { |  | ||||||
|         $this->object->setAudioCodec('audiocodec2'); |  | ||||||
|         $this->assertEquals('audiocodec2', $this->object->getAudioCodec()); |  | ||||||
|         $this->object->setAudioCodec('audiocodec1'); |  | ||||||
|         $this->assertEquals('audiocodec1', $this->object->getAudioCodec()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setAudioCodec |  | ||||||
|      * @expectedException \InvalidArgumentException |  | ||||||
|      */ |  | ||||||
|     public function testSetWrongAudioCodec() |  | ||||||
|     { |  | ||||||
|         $this->object->setAudioCodec('audiocodec4'); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getAudioSampleRate |  | ||||||
|      */ |  | ||||||
|     public function testGetAudioSampleRate() |  | ||||||
|     { |  | ||||||
|         $this->assertEquals(44100, $this->object->getAudioSampleRate()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setAudioSampleRate |  | ||||||
|      */ |  | ||||||
|     public function testSetAudioSampleRate() |  | ||||||
|     { |  | ||||||
|         $this->object->setAudioSampleRate(22050); |  | ||||||
|         $this->assertEquals(22050, $this->object->getAudioSampleRate()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setAudioSampleRate |  | ||||||
|      * @expectedException \InvalidArgumentException |  | ||||||
|      * @dataProvider getWrongAudioSampleRate |  | ||||||
|      */ |  | ||||||
|     public function testSetWrongAudioSampleRate($samplerate) |  | ||||||
|     { |  | ||||||
|         $this->object->setAudioSampleRate($samplerate); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function getWrongAudioSampleRate() |  | ||||||
|     { |  | ||||||
|         return array(array(-5), array(0)); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getVideoCodec |  | ||||||
|      */ |      */ | ||||||
|     public function testGetVideoCodec() |     public function testGetVideoCodec() | ||||||
|     { |     { | ||||||
|  | @ -187,7 +123,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setVideoCodec |      * @covers FFMpeg\Format\DefaultVideoFormat::setVideoCodec | ||||||
|      */ |      */ | ||||||
|     public function testSetVideoCodec() |     public function testSetVideoCodec() | ||||||
|     { |     { | ||||||
|  | @ -198,7 +134,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setVideoCodec |      * @covers FFMpeg\Format\DefaultVideoFormat::setVideoCodec | ||||||
|      * @expectedException \InvalidArgumentException |      * @expectedException \InvalidArgumentException | ||||||
|      */ |      */ | ||||||
|     public function testSetWrongVideoCodec() |     public function testSetWrongVideoCodec() | ||||||
|  | @ -207,39 +143,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getKiloBitrate |      * @covers FFMpeg\Format\DefaultVideoFormat::getGOPsize | ||||||
|      */ |  | ||||||
|     public function testGetKiloBitrate() |  | ||||||
|     { |  | ||||||
|         $this->assertEquals(1000, $this->object->getKiloBitrate()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setKiloBitrate |  | ||||||
|      */ |  | ||||||
|     public function testSetKiloBitrate() |  | ||||||
|     { |  | ||||||
|         $this->object->setKiloBitrate(500); |  | ||||||
|         $this->assertEquals(500, $this->object->getKiloBitrate()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setKiloBitrate |  | ||||||
|      * @dataProvider getWrongKiloBitrate |  | ||||||
|      * @expectedException \InvalidArgumentException |  | ||||||
|      */ |  | ||||||
|     public function testSetWrongKiloBitrate($kbrate) |  | ||||||
|     { |  | ||||||
|         $this->object->setKiloBitrate($kbrate); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function getWrongKiloBitrate() |  | ||||||
|     { |  | ||||||
|         return array(array(-5), array(0)); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getGOPsize |  | ||||||
|      */ |      */ | ||||||
|     public function testGetGOPsize() |     public function testGetGOPsize() | ||||||
|     { |     { | ||||||
|  | @ -247,7 +151,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setGOPsize |      * @covers FFMpeg\Format\DefaultVideoFormat::setGOPsize | ||||||
|      */ |      */ | ||||||
|     public function testSetGOPsize() |     public function testSetGOPsize() | ||||||
|     { |     { | ||||||
|  | @ -256,7 +160,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::setGOPsize |      * @covers FFMpeg\Format\DefaultVideoFormat::setGOPsize | ||||||
|      * @dataProvider getWrongGOPsize |      * @dataProvider getWrongGOPsize | ||||||
|      * @expectedException \InvalidArgumentException |      * @expectedException \InvalidArgumentException | ||||||
|      */ |      */ | ||||||
|  | @ -271,7 +175,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\DefaultFormat::getMultiple |      * @covers FFMpeg\Format\DefaultVideoFormat::getMultiple | ||||||
|      */ |      */ | ||||||
|     public function testGetMultiple() |     public function testGetMultiple() | ||||||
|     { |     { | ||||||
|  | @ -285,7 +189,7 @@ class DefaultFormatTest extends \PHPUnit_Framework_TestCase | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class DefaultFormatTester extends DefaultFormat | class DefaultVideoFormatTester extends DefaultVideoFormat | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|     protected $audioCodec = 'audiocodec1'; |     protected $audioCodec = 'audiocodec1'; | ||||||
|  | @ -312,3 +216,4 @@ class DefaultFormatTester extends DefaultFormat | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | @ -1,8 +1,6 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format\Video; | ||||||
| 
 |  | ||||||
| require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/Ogg.php'; |  | ||||||
| 
 | 
 | ||||||
| class OggTest extends \PHPUnit_Framework_TestCase | class OggTest extends \PHPUnit_Framework_TestCase | ||||||
| { | { | ||||||
|  | @ -19,11 +17,11 @@ class OggTest extends \PHPUnit_Framework_TestCase | ||||||
| 
 | 
 | ||||||
|     public function testConstruct() |     public function testConstruct() | ||||||
|     { |     { | ||||||
|         $this->assertInstanceOf('\\FFMpeg\\Format\\DefaultFormat', $this->object); |         $this->assertInstanceOf('\\FFMpeg\\Format\\DefaultVideoFormat', $this->object); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\Ogg::getAvailableAudioCodecs |      * @covers FFMpeg\Format\Video\Ogg::getAvailableAudioCodecs | ||||||
|      */ |      */ | ||||||
|     public function testGetAvailableAudioCodecs() |     public function testGetAvailableAudioCodecs() | ||||||
|     { |     { | ||||||
|  | @ -31,7 +29,7 @@ class OggTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\Ogg::getAvailableVideoCodecs |      * @covers FFMpeg\Format\Video\Ogg::getAvailableVideoCodecs | ||||||
|      */ |      */ | ||||||
|     public function testGetAvailableVideoCodecs() |     public function testGetAvailableVideoCodecs() | ||||||
|     { |     { | ||||||
|  | @ -1,8 +1,6 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format\Video; | ||||||
| 
 |  | ||||||
| require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/WebM.php'; |  | ||||||
| 
 | 
 | ||||||
| class WebMTest extends \PHPUnit_Framework_TestCase | class WebMTest extends \PHPUnit_Framework_TestCase | ||||||
| { | { | ||||||
|  | @ -18,7 +16,7 @@ class WebMTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\WebM::getAvailableAudioCodecs |      * @covers FFMpeg\Format\Video\WebM::getAvailableAudioCodecs | ||||||
|      */ |      */ | ||||||
|     public function testGetAvailableAudioCodecs() |     public function testGetAvailableAudioCodecs() | ||||||
|     { |     { | ||||||
|  | @ -26,7 +24,7 @@ class WebMTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\WebM::getAvailableVideoCodecs |      * @covers FFMpeg\Format\Video\WebM::getAvailableVideoCodecs | ||||||
|      */ |      */ | ||||||
|     public function testGetAvailableVideoCodecs() |     public function testGetAvailableVideoCodecs() | ||||||
|     { |     { | ||||||
|  | @ -34,7 +32,7 @@ class WebMTest extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\WebM::getExtraParams |      * @covers FFMpeg\Format\Video\WebM::getExtraParams | ||||||
|      */ |      */ | ||||||
|     public function testGetExtraParams() |     public function testGetExtraParams() | ||||||
|     { |     { | ||||||
|  | @ -43,7 +41,7 @@ class WebMTest extends \PHPUnit_Framework_TestCase | ||||||
| 
 | 
 | ||||||
|     public function testConstruct() |     public function testConstruct() | ||||||
|     { |     { | ||||||
|         $this->assertInstanceOf('\\FFMpeg\\Format\\DefaultFormat', $this->object); |         $this->assertInstanceOf('\\FFMpeg\\Format\\DefaultVideoFormat', $this->object); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -1,8 +1,6 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| namespace FFMpeg\Format; | namespace FFMpeg\Format\Video; | ||||||
| 
 |  | ||||||
| require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/X264.php'; |  | ||||||
| 
 | 
 | ||||||
| class X264Test extends \PHPUnit_Framework_TestCase | class X264Test extends \PHPUnit_Framework_TestCase | ||||||
| { | { | ||||||
|  | @ -19,11 +17,11 @@ class X264Test extends \PHPUnit_Framework_TestCase | ||||||
| 
 | 
 | ||||||
|     public function testConstruct() |     public function testConstruct() | ||||||
|     { |     { | ||||||
|         $this->assertInstanceOf('\\FFMpeg\\Format\\DefaultFormat', $this->object); |         $this->assertInstanceOf('\\FFMpeg\\Format\\DefaultVideoFormat', $this->object); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\X264::getAvailableAudioCodecs |      * @covers FFMpeg\Format\Video\X264::getAvailableAudioCodecs | ||||||
|      */ |      */ | ||||||
|     public function testGetAvailableAudioCodecs() |     public function testGetAvailableAudioCodecs() | ||||||
|     { |     { | ||||||
|  | @ -31,12 +29,11 @@ class X264Test extends \PHPUnit_Framework_TestCase | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers FFMpeg\Format\X264::getAvailableVideoCodecs |      * @covers FFMpeg\Format\Video\X264::getAvailableVideoCodecs | ||||||
|      */ |      */ | ||||||
|     public function testGetAvailableVideoCodecs() |     public function testGetAvailableVideoCodecs() | ||||||
|     { |     { | ||||||
|         $this->object->setVideoCodec('libx264'); |         $this->object->setVideoCodec('libx264'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| } | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue