/** * @covers MediaAlchemyst\Alchemyst::turnInto * @covers MediaAlchemyst\Alchemyst::routeAction */ public function testTurnIntoVideoVideo() { $dest = __DIR__ . '/../../files/output.webm'; $this->object->turnInto(__DIR__ . '/../../files/Test.ogv', $dest, $this->specsVideo); $media = $this->getMediaVorus()->guess($dest); $this->assertEquals(MediaInterface::TYPE_VIDEO, $media->getType()); unlink($dest); }
/** * @expectedException MediaAlchemyst\Exception\RuntimeException */ public function testTurnIntoVideoVideoWithFFProbe() { $driversContainer = new DriversContainer(); $driversContainer['configuration'] = array('ffmpeg.ffprobe.binaries' => 'nofile'); $object = new Alchemyst($driversContainer, $this->getFsManager()); $dest = __DIR__ . '/../../files/output.webm'; $object->turnInto(__DIR__ . '/../../files/Test.ogv', $dest, $this->specsVideo); }
public function execute(InputInterface $input, OutputInterface $output) { $spec = $this->getSpecification($input->getArgument('spec')); $file = $input->getArgument('file'); if (!file_exists($file)) { throw new InvalidArgumentException(sprintf('file `%s` does not exists', $file)); } $target = $input->getArgument('target'); $force = $input->getOption('force'); if (realpath($file) === realpath($target)) { throw new InvalidArgumentException('Source and target should be different'); } if (file_exists($target) && !$force) { throw new InvalidArgumentException(sprintf('file `%s` already exists ; use --force to overwrite', $target)); } if (method_exists($spec, 'setAudioCodec')) { if ($input->getOption('acodec')) { $spec->setAudioCodec($input->getOption('acodec')); } } if (method_exists($spec, 'setVideoCodec')) { if ($input->getOption('vcodec')) { $spec->setVideoCodec($input->getOption('vcodec')); } } if (method_exists($spec, 'setFrameRate')) { if ($input->getOption('framerate')) { $spec->setFrameRate($input->getOption('framerate')); } } if (method_exists($spec, 'setDimensions')) { if ($input->getOption('width') && $input->getOption('height')) { $spec->setDimensions($input->getOption('width'), $input->getOption('height')); } elseif (!$input->getOption('width') && $input->getOption('height') || $input->getOption('width') && !$input->getOption('height')) { throw new InvalidArgumentException('You should provide both dimensions or no dimensions'); } } $drivers = new DriversContainer(); $drivers['ffmpeg.threads'] = $input->getOption('threads') ?: 1; $fs = new Filesystem(); $manager = new Manager(new TemporaryFilesystem($fs), $fs); $Alchemyst = new AlchemystTransmuter($drivers, $manager); $Alchemyst->turnInto($file, $target, $spec); }
/** * * @param int $angle * @param Alchemyst $alchemyst * @param MediaVorus $mediavorus * * @return media_subdef */ public function rotate($angle, Alchemyst $alchemyst, MediaVorus $mediavorus) { if (!$this->is_physically_present()) { throw new \Alchemy\Phrasea\Exception\RuntimeException('You can not rotate a substitution'); } $specs = new \MediaAlchemyst\Specification\Image(); $specs->setRotationAngle($angle); try { $alchemyst->turnInto($this->get_pathfile(), $this->get_pathfile(), $specs); } catch (\MediaAlchemyst\Exception\ExceptionInterface $e) { return $this; } $media = $mediavorus->guess($this->get_pathfile()); $sql = "UPDATE subdef\n SET height = :height , width = :width, updated_on = NOW()\n WHERE record_id = :record_id AND name = :name"; $params = [':width' => $media->getWidth(), ':height' => $media->getHeight(), ':record_id' => $this->get_record_id(), ':name' => $this->get_name()]; $stmt = $this->record->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); $this->width = $media->getWidth(); $this->height = $media->getHeight(); $this->delete_data_from_cache(); unset($media); return $this; }