diff --git a/Create-PillarBox.ps1 b/Create-PillarBox.ps1 index 12b1843..25a4645 100644 --- a/Create-PillarBox.ps1 +++ b/Create-PillarBox.ps1 @@ -9,8 +9,12 @@ saved alongside the source (e.g. video.mp4 + -Effect black -> video-black.mp4). .PARAMETER Effect The effect to apply to the side bars. Possible values are: - black: The side bars will be black. - white: The side bars will be white. + black: The side bars will be solid black (#000000). + white: The side bars will be solid white (#FFFFFF). + silver: The side bars will be solid silver (#C0C0C0), a light neutral gray. + gray: The side bars will be solid mid gray (#808080). + charcoal: The side bars will be solid charcoal (#36454F), a very dark blue-gray. + color:RRGGBB: The side bars will be filled with the given hex color (case-insensitive). Example: -Effect color:FFFF00 yields yellow bars. standard: Creates softly blurred side bars generated from the video itself, with a subtle zoom to fill the 16:9 frame. dark: Produces blurred side bars with reduced brightness, creating a darker, more contrasted background that enhances focus on the main video. gaussian: Generates smooth, high‑quality Gaussian‑blurred side bars for a clean, professional broadcast-style background. @@ -186,10 +190,30 @@ function Resolve-Size { } # Validate -Effect first so it can be used in the default -Target name. -$validEffects = @('black', 'white', 'standard', 'dark', 'gaussian') +# Solid-color effects map an effect name to the ffmpeg color string used in the pad filter. +# Named SVG colors (black, white, silver, gray) are passed through directly; custom shades +# (e.g. charcoal) use an explicit 0xRRGGBB value since ffmpeg does not recognise the name. +$solidColorMap = @{ + 'black' = 'black' + 'white' = 'white' + 'silver' = 'silver' + 'gray' = 'gray' + 'charcoal' = '0x36454F' +} +$blurEffects = @('standard', 'dark', 'gaussian') +$validEffects = @($solidColorMap.Keys) + $blurEffects $effectLower = $Effect.ToLower() -if ($effectLower -notin $validEffects) { - throw "Invalid -Effect value: $Effect. Must be one of: $($validEffects -join ', ')" + +# Ad-hoc solid color via 'color:RRGGBB' syntax (case-insensitive on the hex value). +# The hex string is normalised to lowercase and the effect is treated like the +# built-in solid-color effects (simple pad filter, no blur). +$customColorHex = $null +if ($effectLower -match '^color:([0-9a-f]{6})$') { + $customColorHex = $Matches[1] + $effectLower = "color:$customColorHex" +} +elseif ($effectLower -notin $validEffects) { + throw "Invalid -Effect value: $Effect. Must be one of: $($validEffects -join ', '), or 'color:RRGGBB' (6 hex digits)." } # Append .mp4 extension if missing on -Source @@ -205,10 +229,13 @@ $sourceFull = (Resolve-Path -LiteralPath $Source).Path # Default -Target: same directory and base name as -Source, with the effect appended # (e.g. C:\clips\video.mp4 + -Effect Black -> C:\clips\video-black.mp4). +# For 'color:RRGGBB', the colon is replaced with a dash to keep the filename valid +# (e.g. -Effect color:FFFF00 -> video-color-ffff00.mp4). if ([string]::IsNullOrWhiteSpace($Target)) { $srcDir = [System.IO.Path]::GetDirectoryName($sourceFull) $srcBase = [System.IO.Path]::GetFileNameWithoutExtension($sourceFull) - $Target = Join-Path $srcDir "$srcBase-$effectLower.mp4" + $effectForName = $effectLower -replace ':', '-' + $Target = Join-Path $srcDir "$srcBase-$effectForName.mp4" } elseif (-not [System.IO.Path]::GetExtension($Target)) { $Target = "$Target.mp4" @@ -256,14 +283,21 @@ if ($outHeight % 2) { $outHeight++ } $scaleFg = "scale=w=${outWidth}:h=${outHeight}:force_original_aspect_ratio=decrease" # Build the video filter graph depending on the requested -Effect. -# black/white : simple pad with the solid color (uses -vf) +# solid colors : simple pad with the chosen color (uses -vf) +# black, white, silver, gray, charcoal, color:RRGGBB # standard : softly blurred background with a subtle zoom (uses -filter_complex) # dark : blurred background with reduced brightness/saturation (uses -filter_complex) # gaussian : high-quality Gaussian-blurred background (uses -filter_complex) -$useFilterComplex = $effectLower -in @('standard', 'dark', 'gaussian') +$useFilterComplex = $effectLower -in $blurEffects if (-not $useFilterComplex) { - $padExpr = "pad=${outWidth}:${outHeight}:(ow-iw)/2:(oh-ih)/2:${effectLower}" + if ($customColorHex) { + $padColor = "0x$customColorHex" + } + else { + $padColor = $solidColorMap[$effectLower] + } + $padExpr = "pad=${outWidth}:${outHeight}:(ow-iw)/2:(oh-ih)/2:${padColor}" $vf = "${scaleFg},${padExpr},setsar=1" } else {