Merge pull request #52 from alchemy-fr/synchro
Fix #46 : A/V synchronization works on flash player, not on html5 one
This commit is contained in:
commit
5309adcdd6
3 changed files with 7 additions and 69 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue