Skip to content

Commit

Permalink
use output "formats" for ffmpeg (conf bc break)
Browse files Browse the repository at this point in the history
WIP : audio extraction ; animated gif/webp ; doc
  • Loading branch information
jygaulier committed Oct 15, 2024
1 parent 83d8b8e commit ef7c6ea
Show file tree
Hide file tree
Showing 14 changed files with 427 additions and 165 deletions.
28 changes: 28 additions & 0 deletions lib/php/rendition-factory-bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,35 @@ services:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\TransformerModuleInterface::TAG }

# FFMpeg "formats"
Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\JpegFormat:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\FormatInterface::TAG }

Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\MkvFormat:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\FormatInterface::TAG }

Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\Mpeg4Format:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\FormatInterface::TAG }

Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\MpegFormat:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\FormatInterface::TAG }

Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\QuicktimeFormat:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\FormatInterface::TAG }

Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\WebmFormat:
tags:
- { name: !php/const Alchemy\RenditionFactory\Transformer\Video\FFMpeg\Format\FormatInterface::TAG }


Imagine\Imagick\Imagine: ~
Imagine\Image\ImagineInterface: '@Imagine\Imagick\Imagine'

Alchemy\RenditionFactory\MimeType\MimeTypeGuesser: ~
Alchemy\RenditionFactory\Format\FormatGuesser: ~
Alchemy\RenditionFactory\Format\FormatFactory: ~
4 changes: 2 additions & 2 deletions lib/php/rendition-factory/src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
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
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;
}
}
Loading

0 comments on commit ef7c6ea

Please sign in to comment.