Пример #1
1
 public function applyFilter(Video $video)
 {
     return $video->filters()->framerate($this->framerate, $this->gop);
 }
Пример #2
1
 public function applyFilter(Video $video)
 {
     return $video->filters()->synchronize();
 }
Пример #3
1
 public function applyFilter(Video $video)
 {
     return $video->filters()->resize($this->dimension, $this->mode, $this->useStandards);
 }
Пример #4
1
 public function applyFilter(Video $video)
 {
     return $video->filters()->crop($this->point, $this->dimension);
 }
Пример #5
0
 public function testSaveInvalidForgedVideo()
 {
     $ffmpeg = $this->getFFMpeg();
     $video = new Video(__DIR__ . '/../../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe());
     $this->setExpectedException('FFMpeg\\Exception\\RuntimeException');
     $video->save(new X264('libvo_aacenc'), __DIR__ . '/output/output-x264.mp4');
 }
Пример #6
0
 /**
  * Get Size.
  *
  * @return string
  */
 public function getSize()
 {
     $stream = $this->video->getStreams()->first();
     $dim = null;
     if ($stream->isVideo()) {
         $dim = $stream->getDimensions()->getWidth() . 'x' . $stream->getDimensions()->getHeight();
     }
     return $dim;
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function apply(Video $video, VideoInterface $format)
 {
     foreach ($video->getStreams()->videos() as $stream) {
         if ($stream->has('width') && $stream->has('height')) {
             $stream->set('width', $this->dimension->getWidth());
             $stream->set('height', $this->dimension->getHeight());
         }
     }
     return array('-filter:v', 'crop=' . $this->dimension->getWidth() . ':' . $this->dimension->getHeight() . ':' . $this->point->getX() . ':' . $this->point->getY());
 }
Пример #8
0
 public function testBatchGenerate()
 {
     $times = ['00:00:00:01', '00:00:00:11', '00:00:00:21'];
     foreach ($times as $time) {
         $timecode = TimeCode::fromString($time);
         $this->ffmpeg->open('1.mp4')->willReturn($this->video->reveal())->shouldBeCalled();
         $this->video->frame($timecode)->willReturn($this->frame->reveal())->shouldBeCalled();
         $this->frame->save(str_replace(':', '.', '/' . $time . '.jpg'))->shouldBeCalled();
     }
     $this->videoThumbnailService->batchGenerate('1.mp4', $times, '');
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function apply(Video $video, VideoInterface $format)
 {
     if (in_array($this->angle, array(self::ROTATE_90, self::ROTATE_270), true)) {
         foreach ($video->getStreams()->videos() as $stream) {
             if ($stream->has('width') && $stream->has('height')) {
                 $width = $stream->get('width');
                 $stream->set('width', $stream->get('height'));
                 $stream->set('height', $width);
             }
         }
     }
     return array('-vf', $this->angle, '-metadata:s:v:0', 'rotate=0');
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function apply(Video $video, VideoInterface $format)
 {
     $dimensions = null;
     $commands = array();
     foreach ($video->getStreams() as $stream) {
         if ($stream->isVideo()) {
             try {
                 $dimensions = $stream->getDimensions();
                 break;
             } catch (RuntimeException $e) {
             }
         }
     }
     if (null !== $dimensions) {
         $dimensions = $this->getComputedDimensions($dimensions, $format->getModulus());
         $commands[] = '-s';
         $commands[] = $dimensions->getWidth() . 'x' . $dimensions->getHeight();
     }
     return $commands;
 }
Пример #11
0
 public function __construct(Video $video, FFMpegDriver $driver, FFProbe $ffprobe, TimeCode $timecode)
 {
     parent::__construct($video->getFilePath(), $driver, $ffprobe);
     $this->timecode = $timecode;
     $this->video = $video;
 }
Пример #12
0
 public function applyFilter(Video $video)
 {
     return $video->filters()->rotate($this->angle);
 }
Пример #13
0
 public function testSaveShouldNotStoreCodecFiltersInTheMedia()
 {
     $driver = $this->getFFMpegDriverMock();
     $ffprobe = $this->getFFProbeMock();
     $configuration = $this->getMock('Alchemy\\BinaryDriver\\ConfigurationInterface');
     $driver->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration));
     $configuration->expects($this->any())->method('has')->with($this->equalTo('ffmpeg.threads'))->will($this->returnValue(true));
     $configuration->expects($this->any())->method('get')->with($this->equalTo('ffmpeg.threads'))->will($this->returnValue(24));
     $capturedCommands = array();
     $driver->expects($this->exactly(4))->method('command')->with($this->isType('array'), false, $this->anything())->will($this->returnCallback(function ($commands, $errors, $listeners) use(&$capturedCommands, &$capturedListeners) {
         $capturedCommands[] = $commands;
     }));
     $outputPathfile = '/target/file';
     $format = $this->getMock('FFMpeg\\Format\\VideoInterface');
     $format->expects($this->any())->method('getExtraParams')->will($this->returnValue(array('param')));
     $video = new Video(__FILE__, $driver, $ffprobe);
     $video->save($format, $outputPathfile);
     $video->save($format, $outputPathfile);
     $expectedPass1 = array('-y', '-i', __FILE__, 'param', '-threads', 24, '-b:v', 'k', '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', '-pass', '1', '-passlogfile', '/target/file');
     $expectedPass2 = array('-y', '-i', __FILE__, 'param', '-threads', 24, '-b:v', 'k', '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', '-pass', '2', '-passlogfile', '/target/file');
     $n = 1;
     foreach ($capturedCommands as $capturedCommand) {
         foreach ($capturedCommand as $command) {
             if (0 === strpos($command, 'pass-')) {
                 $prefix = $command;
                 break;
             }
         }
         if (null === $prefix) {
             $this->fail('Unable to find pass prefix command.');
         }
         $found = false;
         foreach ($capturedCommand as $key => $command) {
             if ($command === $prefix) {
                 $found = true;
                 unset($capturedCommand[$key]);
                 $capturedCommand = array_values($capturedCommand);
                 break;
             }
         }
         if (!$found) {
             $this->fail('Unable to find pass prefix command back.');
         }
         if (0 === $n % 2) {
             $this->assertEquals($expectedPass2, $capturedCommand);
         } else {
             $this->assertEquals($expectedPass1, $capturedCommand);
         }
         $n++;
     }
 }
Пример #14
0
 public function applyFilter(Video $video)
 {
     return $video->filters()->resample($this->rate);
 }
Пример #15
0
 public function applyFilter(Video $video)
 {
     return $video->filters()->watermark($this->watermarkPath, $this->coordinates);
 }
Пример #16
0
 /**
  * @param int $frameNumber
  *
  * @return Frame
  */
 public function getFrame($frameNumber)
 {
     return $this->movie->frame(TimeCode::fromSeconds($frameNumber));
 }
Пример #17
-3
 public function applyFilter(Video $video)
 {
     return $video->filters()->clip($this->start, $this->duration);
 }