public function applyFilter(Video $video)
 {
     return $video->filters()->framerate($this->framerate, $this->gop);
 }
 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
文件: FFmpeg.php 项目: buse974/dms
 /**
  * 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());
 }
 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);
 }