From 543d9aaeafc94dbf8eba0ec0b9130a51aa8d990d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 7 Aug 2013 19:44:01 +0200 Subject: [PATCH] Fix #46 : A/V synchronization works on flash player, not on html5 one --- CHANGELOG.md | 4 ++ .../Filters/Video/SynchronizeFilter.php | 28 +----------- .../Filters/Video/SynchronizeFilterTest.php | 44 +------------------ 3 files changed, 7 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6521721..d82e89e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG --------- +* 0.3.2 (xx-08-2013) + + * Fix A/V synchronization over flash and HTML5 players. + * 0.3.1 (06-08-2013) * Allow use of FFProbe on remote URIs. diff --git a/src/FFMpeg/Filters/Video/SynchronizeFilter.php b/src/FFMpeg/Filters/Video/SynchronizeFilter.php index 2863d87..8ca72e0 100644 --- a/src/FFMpeg/Filters/Video/SynchronizeFilter.php +++ b/src/FFMpeg/Filters/Video/SynchronizeFilter.php @@ -39,32 +39,6 @@ class SynchronizeFilter implements VideoFilterInterface */ public function apply(Video $video, VideoInterface $format) { - $streams = $video->getStreams(); - - if (null === $videoStream = $streams->videos()->first()) { - return array(); - } - if (!$videoStream->has('start_time')) { - return array(); - } - - $params = array( - '-itsoffset', - $videoStream->get('start_time'), - '-i', - $video->getPathfile(), - ); - - foreach ($streams as $stream) { - if ($videoStream === $stream) { - $params[] = '-map'; - $params[] = '1:' . $stream->get('index'); - } else { - $params[] = '-map'; - $params[] = '0:' . $stream->get('index'); - } - } - - return $params; + return array('-async', '1'); } } diff --git a/tests/FFMpeg/Tests/Filters/Video/SynchronizeFilterTest.php b/tests/FFMpeg/Tests/Filters/Video/SynchronizeFilterTest.php index 8a50f05..69fb681 100644 --- a/tests/FFMpeg/Tests/Filters/Video/SynchronizeFilterTest.php +++ b/tests/FFMpeg/Tests/Filters/Video/SynchronizeFilterTest.php @@ -3,56 +3,16 @@ namespace FFMpeg\Tests\Filters\Video; use FFMpeg\Tests\TestCase; -use FFMpeg\FFProbe\DataMapping\StreamCollection; -use FFMpeg\FFProbe\DataMapping\Stream; use FFMpeg\Filters\Video\SynchronizeFilter; class SynchronizeFilterTest extends TestCase { - /** - * @dataProvider provideStreams - */ - public function testApply($streams, $expected) + public function testApply() { $video = $this->getVideoMock(); $format = $this->getMock('FFMpeg\Format\VideoInterface'); - $video->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - $video->expects($this->any()) - ->method('getPathfile') - ->will($this->returnValue(__FILE__)); $filter = new SynchronizeFilter(); - $this->assertEquals($expected, $filter->apply($video, $format)); - } - - public function provideStreams() - { - $audio = new StreamCollection(array(new Stream(array( - 'index' => 0, - 'codec_type' => 'audio', - )))); - $synced = new StreamCollection(array(new Stream(array( - 'index' => 0, - 'codec_type' => 'video', - )), new Stream(array( - 'index' => 1, - 'codec_type' => 'audio', - )))); - $video = new StreamCollection(array(new Stream(array( - 'index' => 0, - 'codec_type' => 'video', - 'start_time' => '0.123456', - )), new Stream(array( - 'index' => 1, - 'codec_type' => 'audio', - )))); - - return array( - array($audio, array()), - array($synced, array()), - array($video, array('-itsoffset', '0.123456', '-i', __FILE__, '-map', '1:0', '-map', '0:1')), - ); + $this->assertEquals(array('-async', '1'), $filter->apply($video, $format)); } }