DASHTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * This file is part of the PHP-FFmpeg-video-streaming package.
  4. *
  5. * (c) Amin Yazdanpanah <contact@aminyazdanpanah.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Tests\FFMpegStreaming;
  11. use Streaming\DASH;
  12. use Streaming\Stream;
  13. use Streaming\Format\StreamFormat;
  14. use Streaming\Representation;
  15. class DASHTest extends TestCase
  16. {
  17. public function testDASHClass()
  18. {
  19. $this->assertInstanceOf(Stream::class, $this->getDASH());
  20. }
  21. public function testFormat()
  22. {
  23. $dash = $this->getDASH();
  24. $dash->HEVC();
  25. $this->assertInstanceOf(StreamFormat::class, $dash->getFormat());
  26. }
  27. public function testAutoRepresentations()
  28. {
  29. $dash = $this->getDASH();
  30. $dash->HEVC()
  31. ->autoGenerateRepresentations();
  32. $representations = $dash->getRepresentations()->all();
  33. $this->assertIsArray($representations);
  34. $this->assertInstanceOf(Representation::class, current($representations));
  35. $this->assertEquals('256x144', $representations[0]->size2string());
  36. $this->assertEquals('426x240', $representations[1]->size2string());
  37. $this->assertEquals('640x360', $representations[2]->size2string());
  38. $this->assertEquals(103, $representations[0]->getKiloBitrate());
  39. $this->assertEquals(138, $representations[1]->getKiloBitrate());
  40. $this->assertEquals(207, $representations[2]->getKiloBitrate());
  41. }
  42. public function testSet()
  43. {
  44. $dash = $this->getDASH();
  45. $dash->setAdaption('test-adaption');
  46. $this->assertEquals('test-adaption', $dash->getAdaption());
  47. }
  48. public function testSave()
  49. {
  50. $dash = $this->getDASH();
  51. $export_class = $dash->HEVC()
  52. ->autoGenerateRepresentations()
  53. ->save($this->srcDir . '/dash/test.mpd');
  54. $this->assertFileExists($this->srcDir . '/dash/test.mpd');
  55. $this->assertInstanceOf(Stream::class, $export_class);
  56. }
  57. private function getDASH()
  58. {
  59. return new DASH($this->getVideo());
  60. }
  61. }