Merge branch '0.3'

This commit is contained in:
Romain Neutron 2013-08-08 12:14:24 +02:00
commit 78c75b369d
3 changed files with 7 additions and 69 deletions

View file

@ -3,6 +3,10 @@ CHANGELOG
* 0.4.0 (xx-xx-xxxx)
* 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.

View file

@ -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');
}
}

View file

@ -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));
}
}