Skip to content

Commit

Permalink
add animation module and animated formats
Browse files Browse the repository at this point in the history
  • Loading branch information
jygaulier committed Oct 17, 2024
1 parent 1b3fe18 commit 228c78a
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 47 deletions.
6 changes: 3 additions & 3 deletions lib/php/rendition-factory/src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function configure(): void

$this->addArgument('src', InputArgument::REQUIRED, 'The source file');
$this->addArgument('build-config', InputArgument::REQUIRED, 'The build config YAML file');
$this->addOption('type', 't', InputOption::VALUE_OPTIONAL, 'Force the MIME type of file');
$this->addOption('type', 't', InputOption::VALUE_REQUIRED, 'Force the MIME type of file');
$this->addOption('working-dir', 'w', InputOption::VALUE_REQUIRED, 'The working directory. Defaults to system temp directory');
$this->addOption('output', 'o', InputOption::VALUE_REQUIRED, 'The output file name WITHOUT extension');
$this->addOption('debug', 'd', InputOption::VALUE_NONE, 'set to debug mode (keep files in working directory)');
Expand Down Expand Up @@ -72,6 +72,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$buildConfig,
$options
);
$output->writeln(sprintf('Rendition created: %s', $outputFile->getPath()));

} catch (\InvalidArgumentException $e) {
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));

Expand All @@ -91,8 +93,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 1;
}

$output->writeln(sprintf('Rendition created: %s', $outputFile->getPath()));

if (!$input->getOption('debug')) {
$this->renditionCreator->cleanUp();
}
Expand Down
1 change: 1 addition & 0 deletions lib/php/rendition-factory/src/Config/YamlLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private function parseTransformation(array $transformation): Transformation
{
return new Transformation(
$transformation['module'],
$transformation['enabled'] ?? true,
$transformation['options'] ?? [],
$transformation['description'] ?? null
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;


use Alchemy\RenditionFactory\DTO\FamilyEnum;
// use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;

// #[AutoconfigureTag(self::TAG)]
interface FormatInterface
{
final public const TAG = 'alchemy_rendition_factory.ffmpeg_format';

public static function getAllowedExtensions(): array;
public static function getMimeType(): string;
public static function getFormat(): string;
public static function getFamily(): FamilyEnum;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;

use Alchemy\RenditionFactory\DTO\FamilyEnum;
use FFMpeg\Format\Video\X264;

class JpegFormat implements FormatInterface
{
public static function getAllowedExtensions(): array
{
return ['jpg', 'jpeg'];
}

public static function getMimeType(): string
{
return 'image/jpeg';
}

public static function getFormat(): string
{
return 'image-jpeg';
}

public static function getFamily(): FamilyEnum
{
return FamilyEnum::Image;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;

use Alchemy\RenditionFactory\DTO\FamilyEnum;
use FFMpeg\Format\Video\X264;
use FFMpeg\Format\VideoInterface;

class MkvFormat implements FormatInterface
{
private VideoInterface $format;

public function __construct()
{
$this->format = new X264();
}

public static function getAllowedExtensions(): array
{
return ['mkv'];
}

public static function getMimeType(): string
{
return 'video/x-matroska';
}

public static function getFormat(): string
{
return 'video-mkv';
}

public static function getFamily(): FamilyEnum
{
return FamilyEnum::Video;
}

public function getFFMpegFormat(): VideoInterface
{
return $this->format;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;

use Alchemy\RenditionFactory\DTO\FamilyEnum;
use FFMpeg\Format\Video\X264;
use FFMpeg\Format\VideoInterface;

class Mpeg4Format implements FormatInterface
{
private VideoInterface $format;

public function __construct()
{
$this->format = new X264();
}

public static function getAllowedExtensions(): array
{
return ['mp4'];
}

public static function getMimeType(): string
{
return 'video/mp4';
}

public static function getFormat(): string
{
return 'video-mpeg4';
}

public static function getFamily(): FamilyEnum
{
return FamilyEnum::Video;
}

public function getFFMpegFormat(): VideoInterface
{
return $this->format;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;

use Alchemy\RenditionFactory\DTO\FamilyEnum;
use FFMpeg\Format\Video\X264;
use FFMpeg\Format\VideoInterface;

class MpegFormat implements FormatInterface
{
private VideoInterface $format;

public function __construct()
{
$this->format = new X264();
}

public static function getAllowedExtensions(): array
{
return ['mpeg'];
}

public static function getMimeType(): string
{
return 'video/mpeg';
}

public static function getFormat(): string
{
return 'video-mpeg';
}

public static function getFamily(): FamilyEnum
{
return FamilyEnum::Video;
}

public function getFFMpegFormat(): VideoInterface
{
return $this->format;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;

use Alchemy\RenditionFactory\DTO\FamilyEnum;
use FFMpeg\Format\Video\X264;
use FFMpeg\Format\VideoInterface;

class QuicktimeFormat implements FormatInterface
{
private VideoInterface $format;

public function __construct()
{
$this->format = new X264();
}

public static function getAllowedExtensions(): array
{
return ['mov'];
}

public static function getMimeType(): string
{
return 'video/quicktime';
}

public static function getFormat(): string
{
return 'video-quicktime';
}

public static function getFamily(): FamilyEnum
{
return FamilyEnum::Video;
}

public function getFFMpegFormat(): VideoInterface
{
return $this->format;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format;

use Alchemy\RenditionFactory\DTO\FamilyEnum;
use FFMpeg\Format\Video\WebM;
use FFMpeg\Format\VideoInterface;

class WebmFormat implements FormatInterface
{
private VideoInterface $format;

public function __construct()
{
$this->format = new WebM();
}

public static function getAllowedExtensions(): array
{
return ['webm'];
}

public static function getMimeType(): string
{
return 'video/webm';
}

public static function getFormat(): string
{
return 'video-webm';
}

public static function getFamily(): FamilyEnum
{
return FamilyEnum::Video;
}

public function getFFMpegFormat(): VideoInterface
{
return $this->format;
}
}

0 comments on commit 228c78a

Please sign in to comment.