Skip to content

Commit

Permalink
Merge branch 'PS-670-rendition-video_enhance3' of github.com:alchemy-…
Browse files Browse the repository at this point in the history
…fr/phraseanet-services into w2445
  • Loading branch information
nmaillat committed Nov 18, 2024
2 parents 1cb7213 + 33f9791 commit 61b993a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -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')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 61b993a

Please sign in to comment.