Inject Video at Frame construction
This commit is contained in:
parent
f530d60118
commit
5814eb3085
4 changed files with 29 additions and 9 deletions
|
|
@ -18,16 +18,30 @@ use FFMpeg\Driver\FFMpegDriver;
|
||||||
use FFMpeg\FFProbe;
|
use FFMpeg\FFProbe;
|
||||||
use FFMpeg\Exception\RuntimeException;
|
use FFMpeg\Exception\RuntimeException;
|
||||||
use FFMpeg\Coordinate\TimeCode;
|
use FFMpeg\Coordinate\TimeCode;
|
||||||
|
use FFMpeg\Media\Video;
|
||||||
|
|
||||||
class Frame extends AbstractMediaType
|
class Frame extends AbstractMediaType
|
||||||
{
|
{
|
||||||
/** @var TimeCode */
|
/** @var TimeCode */
|
||||||
private $timecode;
|
private $timecode;
|
||||||
|
/** @var Video */
|
||||||
|
private $video;
|
||||||
|
|
||||||
public function __construct($pathfile, FFMpegDriver $driver, FFProbe $ffprobe, TimeCode $timecode)
|
public function __construct(Video $video, FFMpegDriver $driver, FFProbe $ffprobe, TimeCode $timecode)
|
||||||
{
|
{
|
||||||
parent::__construct($pathfile, $driver, $ffprobe);
|
parent::__construct($video->getPathfile(), $driver, $ffprobe);
|
||||||
$this->timecode = $timecode;
|
$this->timecode = $timecode;
|
||||||
|
$this->video = $video;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the video related to the frame.
|
||||||
|
*
|
||||||
|
* @return Video
|
||||||
|
*/
|
||||||
|
public function getVideo()
|
||||||
|
{
|
||||||
|
return $this->video;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,6 @@ class Video extends Audio
|
||||||
*/
|
*/
|
||||||
public function frame(TimeCode $at)
|
public function frame(TimeCode $at)
|
||||||
{
|
{
|
||||||
return new Frame($this->pathfile, $this->driver, $this->ffprobe, $at);
|
return new Frame($this, $this->driver, $this->ffprobe, $at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class FrameTest extends AbstractMediaTestCase
|
||||||
$ffprobe = $this->getFFProbeMock();
|
$ffprobe = $this->getFFProbeMock();
|
||||||
$timecode = $this->getTimeCodeMock();
|
$timecode = $this->getTimeCodeMock();
|
||||||
|
|
||||||
$frame = new Frame(__FILE__, $driver, $ffprobe, $timecode);
|
$frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode);
|
||||||
$this->assertSame($timecode, $frame->getTimeCode());
|
$this->assertSame($timecode, $frame->getTimeCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ class FrameTest extends AbstractMediaTestCase
|
||||||
$ffprobe = $this->getFFProbeMock();
|
$ffprobe = $this->getFFProbeMock();
|
||||||
$timecode = $this->getTimeCodeMock();
|
$timecode = $this->getTimeCodeMock();
|
||||||
|
|
||||||
$frame = new Frame(__FILE__, $driver, $ffprobe, $timecode);
|
$frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode);
|
||||||
$this->assertInstanceOf('FFMpeg\Filters\Frame\FrameFilters', $frame->filters());
|
$this->assertInstanceOf('FFMpeg\Filters\Frame\FrameFilters', $frame->filters());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ class FrameTest extends AbstractMediaTestCase
|
||||||
->method('add')
|
->method('add')
|
||||||
->with($filter);
|
->with($filter);
|
||||||
|
|
||||||
$frame = new Frame(__FILE__, $driver, $ffprobe, $timecode);
|
$frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode);
|
||||||
$frame->setFiltersCollection($filters);
|
$frame->setFiltersCollection($filters);
|
||||||
$frame->addFilter($filter);
|
$frame->addFilter($filter);
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +75,7 @@ class FrameTest extends AbstractMediaTestCase
|
||||||
->method('command')
|
->method('command')
|
||||||
->with($commands);
|
->with($commands);
|
||||||
|
|
||||||
$frame = new Frame(__FILE__, $driver, $ffprobe, $timecode);
|
$frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode);
|
||||||
$this->assertSame($frame, $frame->save($pathfile, $accurate));
|
$this->assertSame($frame, $frame->save($pathfile, $accurate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,10 +122,16 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getVideoMock()
|
protected function getVideoMock($filename = null)
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('FFMpeg\Media\Video')
|
$video = $this->getMockBuilder('FFMpeg\Media\Video')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
$video->expects($this->any())
|
||||||
|
->method('getFilename')
|
||||||
|
->will($this->returnValue($filename));
|
||||||
|
|
||||||
|
return $video;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue