Skip to content

Commit

Permalink
allow to disable a filter in ffmpeg module ; allow to specify a direc…
Browse files Browse the repository at this point in the history
…tory as output of `alchemy:rendition-factory:create` (end with `/`, the input filename is then used)
  • Loading branch information
jygaulier committed Oct 21, 2024
1 parent ab4efca commit 67ee4c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/php/rendition-factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,21 @@ Generic module to chain ffmpeg "filters" in a single command.

- `filters` list of ffmpeg filters to apply.

Each "filter" has a name and a list of specific options.
Each "filter" has a name and a list of specific options ; Set `enable=false` to disable a filter.

```yaml
module: ffmpeg
options:
format: video-quicktime
filters:
filters:
-
name: resize
width: 320
height: 240
mode: inset
-
name: watermark
enabled: false # THIS FILTER IS DISABLED
# only local files are supported for now
path: "/var/workspace/my_watermarks/google_PNG.png"
position: relative
Expand Down
4 changes: 4 additions & 0 deletions lib/php/rendition-factory/src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

if ($outputPath = $input->getOption('output')) {
if(substr($outputPath, -1) === '/') {
// a directory is specified, use the filename of the source
$outputPath .= pathinfo($src, PATHINFO_FILENAME);
}
@mkdir(dirname($outputPath), 0755, true);
$outputPath .= '.'.$outputFile->getExtension();
rename($outputFile->getPath(), $outputPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ private function doVideo(FormatInterface $ouputFormat, string $extension, InputF
/** @var Video $video */
$video = $ffmpeg->open($inputFile->getPath());

$filters = $options['filters'] ?? [];
$filters = array_values(array_filter($options['filters'] ?? [],
function($filter) {
return $filter['enabled'] ?? true;
}));

// first, turn the video into a clip
if (!empty($filters) && 'pre_clip' === $filters[0]['name']) {
$filter = array_shift($filters);
Expand Down

0 comments on commit 67ee4c7

Please sign in to comment.