From 33f97913b81c26c1ec3ae778035241f343ccb75c Mon Sep 17 00:00:00 2001 From: jygaulier Date: Mon, 18 Nov 2024 19:38:32 +0100 Subject: [PATCH] WIP DO NOT MERGE - fix attributes access in twig : use `"{{ attr.myfield }}"` where `myfield` is the *slugified* attribute name --- .../src/Transformer/Video/FFMpegTransformerModule.php | 10 +++------- .../src/Transformer/Video/ModuleCommonArgs.php | 4 +--- .../Video/VideoSummaryTransformerModule.php | 8 +++----- .../Video/VideoToAnimationTransformerModule.php | 6 ++---- .../Video/VideoToFrameTransformerModule.php | 6 ++---- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/php/rendition-factory/src/Transformer/Video/FFMpegTransformerModule.php b/lib/php/rendition-factory/src/Transformer/Video/FFMpegTransformerModule.php index 615eceb31..9bdacba44 100644 --- a/lib/php/rendition-factory/src/Transformer/Video/FFMpegTransformerModule.php +++ b/lib/php/rendition-factory/src/Transformer/Video/FFMpegTransformerModule.php @@ -330,10 +330,8 @@ private function doVideo(array $options, InputFileInterface $inputFile, Transfor /** @var Video $video */ $video = $commonArgs->getFFMpeg()->open($inputFile->getPath()); - $resolverContext = [ - 'metadata' => $transformationContext->getTemplatingContext(), - 'input' => $video->getStreams()->videos()->first()->all(), - ]; + $resolverContext = $transformationContext->getTemplatingContext(); + $resolverContext['input'] = $video->getStreams()->videos()->first()->all(); if ($videoCodec = $this->optionsResolver->resolveOption($options['video_codec'] ?? null, $resolverContext)) { if (!in_array($videoCodec, $FFMpegFormat->getAvailableVideoCodecs())) { @@ -424,9 +422,7 @@ function ($filter) use ($resolverContext) { */ private function doAudio(array $options, InputFileInterface $inputFile, TransformationContextInterface $context, ModuleCommonArgs $commonArgs): OutputFileInterface { - $resolverContext = [ - 'metadata' => $context->getTemplatingContext(), - ]; + $resolverContext = $context->getTemplatingContext(); $format = $commonArgs->getOutputFormat()->getFormat(); if (!method_exists($commonArgs->getOutputFormat(), 'getFFMpegFormat')) { diff --git a/lib/php/rendition-factory/src/Transformer/Video/ModuleCommonArgs.php b/lib/php/rendition-factory/src/Transformer/Video/ModuleCommonArgs.php index c9a275563..e2fb15e1e 100644 --- a/lib/php/rendition-factory/src/Transformer/Video/ModuleCommonArgs.php +++ b/lib/php/rendition-factory/src/Transformer/Video/ModuleCommonArgs.php @@ -20,9 +20,7 @@ public function __construct( TransformationContextInterface $context, ModuleOptionsResolver $optionsResolver) { - $resolverContext = [ - 'metadata' => $context->getTemplatingContext(), - ]; + $resolverContext = $context->getTemplatingContext(); $format = $optionsResolver->resolveOption($options['format'] ?? null, $resolverContext); if (!$format) { diff --git a/lib/php/rendition-factory/src/Transformer/Video/VideoSummaryTransformerModule.php b/lib/php/rendition-factory/src/Transformer/Video/VideoSummaryTransformerModule.php index 29d6d4947..14a04ade8 100644 --- a/lib/php/rendition-factory/src/Transformer/Video/VideoSummaryTransformerModule.php +++ b/lib/php/rendition-factory/src/Transformer/Video/VideoSummaryTransformerModule.php @@ -70,11 +70,9 @@ public function transform(InputFileInterface $inputFile, array $options, Transfo /** @var FFMpeg\Media\Video $video */ $video = $commonArgs->getFFMpeg()->open($inputFile->getPath()); - $resolverContext = [ - 'metadata' => $context->getTemplatingContext(), - 'input' => $video->getStreams()->videos()->first()->all(), - ]; - + $resolverContext = $context->getTemplatingContext(); + $resolverContext['input'] = $video->getStreams()->videos()->first()->all(); + $period = $this->optionsResolver->resolveOption($options['period'] ?? 0, $resolverContext); $periodAsTimecode = FFMpegHelper::optionAsTimecode($period); if (null === $periodAsTimecode || ($period = FFMpegHelper::timecodeToseconds($periodAsTimecode)) <= 0) { diff --git a/lib/php/rendition-factory/src/Transformer/Video/VideoToAnimationTransformerModule.php b/lib/php/rendition-factory/src/Transformer/Video/VideoToAnimationTransformerModule.php index e83ee21ff..d17e0eaa3 100644 --- a/lib/php/rendition-factory/src/Transformer/Video/VideoToAnimationTransformerModule.php +++ b/lib/php/rendition-factory/src/Transformer/Video/VideoToAnimationTransformerModule.php @@ -94,10 +94,8 @@ public function transform(InputFileInterface $inputFile, array $options, Transfo /** @var FFMpeg\Media\Video $video */ $video = $commonArgs->getFFMpeg()->open($inputFile->getPath()); - $resolverContext = [ - 'metadata' => $context->getTemplatingContext(), - 'input' => $video->getStreams()->videos()->first()->all(), - ]; + $resolverContext = $context->getTemplatingContext(); + $resolverContext['input'] = $video->getStreams()->videos()->first()->all(); $start = $this->optionsResolver->resolveOption($options['start'] ?? 0, $resolverContext); $startAsTimecode = FFMpegHelper::optionAsTimecode($start); diff --git a/lib/php/rendition-factory/src/Transformer/Video/VideoToFrameTransformerModule.php b/lib/php/rendition-factory/src/Transformer/Video/VideoToFrameTransformerModule.php index 45b92891b..b6840f511 100644 --- a/lib/php/rendition-factory/src/Transformer/Video/VideoToFrameTransformerModule.php +++ b/lib/php/rendition-factory/src/Transformer/Video/VideoToFrameTransformerModule.php @@ -56,10 +56,8 @@ public function transform(InputFileInterface $inputFile, array $options, Transfo /** @var Video $video */ $video = $commonArgs->getFFMpeg()->open($inputFile->getPath()); - $resolverContext = [ - 'metadata' => $context->getTemplatingContext(), - 'input' => $video->getStreams()->videos()->first()->all(), - ]; + $resolverContext = $context->getTemplatingContext(); + $resolverContext['input'] = $video->getStreams()->videos()->first()->all(); $start = $this->optionsResolver->resolveOption($options['start'] ?? 0, $resolverContext); $startAsTimecode = FFMpegHelper::optionAsTimecode($start);