Skip to content

Commit

Permalink
Fix config parsing
Browse files Browse the repository at this point in the history
Fix config parsing when non-parameter options are in encoder.ini.
  • Loading branch information
patrickenfuego committed May 13, 2023
1 parent a433179 commit 0b649fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 18 additions & 17 deletions FFEncoder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ param (
[Alias('Enc')]
[string]$Encoder = 'x265',

[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'CRF')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'VMAF')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'PASS')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'QP')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'CRF', HelpMessage='Enter full path to source file')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'VMAF', HelpMessage='Enter full path to source file')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'PASS', HelpMessage='Enter full path to source file')]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'QP', HelpMessage='Enter full path to source file')]
[ValidateScript( { if (Test-Path $_) { $true } else { throw 'Input path does not exist' } } )]
[Alias('I', 'Reference', 'Source')]
[string]$InputPath,
Expand Down Expand Up @@ -330,7 +330,8 @@ param (
[Parameter(Mandatory = $false, ParameterSetName = 'QP')]
[ValidateSet('copy', 'c', 'copyall', 'ca', 'aac', 'none', 'n', 'ac3', 'dee_dd', 'dee_ac3', 'dd', 'dts', 'flac', 'f',
'eac3', 'ddp', 'dee_ddp', 'dee_eac3', 'dee_ddp_51', 'dee_eac3_51', 'dee_thd', 'fdkaac', 'faac', 'aac_at',
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)]
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
)]
[Alias('A2')]
[string]$Audio2 = "none",

Expand All @@ -352,10 +353,11 @@ param (
[Parameter(Mandatory = $false, ParameterSetName = 'QP')]
[ValidateSet('all', 'a', 'copyall', 'ca', 'none', 'default', 'd', 'n', 'eng', 'fre', 'ger', 'spa', 'dut', 'dan',
'fin', 'nor', 'cze', 'pol', 'chi', 'zho', 'kor', 'gre', 'rum', 'rus', 'swe', 'est', 'ind', 'slv', 'tur', 'vie',
'hin', 'heb', 'ell', 'bul', 'ara', 'por', 'nld',
'hin', 'heb', 'ell', 'bul', 'ara', 'por', 'nld', 'tha',
'!eng', '!fre', '!ger', '!spa', '!dut', '!dan', '!fin', '!nor', '!cze', '!pol', '!chi', '!zho', '!kor', '!ara',
'!rum', '!rus', '!swe', '!est', '!ind', '!slv', '!tur', '!vie', '!hin', '!heb', '!gre', '!ell', '!bul', '!por',
'!nld')]
'!nld', '!tha'
)]
[Alias('S', 'Subs')]
[string]$Subtitles = 'default',

Expand All @@ -366,7 +368,7 @@ param (
[Alias('P')]
[string]$Preset = 'slow',

[Parameter(Mandatory = $true, ParameterSetName = 'CRF')]
[Parameter(Mandatory = $true, ParameterSetName = 'CRF', HelpMessage = 'Enter CRF value (1-51)')]
[ValidateRange(0.0, 51.0)]
[Alias('C')]
[double]$CRF,
Expand All @@ -376,7 +378,7 @@ param (
[Alias('QP')]
[int]$ConstantQP,

[Parameter(Mandatory = $true, ParameterSetName = 'PASS')]
[Parameter(Mandatory = $true, ParameterSetName = 'PASS', HelpMessage = 'Enter 2-pass Average Bitrate (Ex: 5M or 5000k)')]
[Alias('VBitrate')]
[ValidateScript(
{
Expand Down Expand Up @@ -706,10 +708,10 @@ param (
[Alias('CreateTagFile')]
[hashtable]$GenerateMKVTagFile,

[Parameter(Mandatory = $true, ParameterSetName = 'CRF')]
[Parameter(Mandatory = $true, ParameterSetName = 'VMAF')]
[Parameter(Mandatory = $true, ParameterSetName = 'PASS')]
[Parameter(Mandatory = $true, ParameterSetName = 'QP')]
[Parameter(Mandatory = $true, ParameterSetName = 'CRF', HelpMessage = 'Enter full path to encoded output file')]
[Parameter(Mandatory = $true, ParameterSetName = 'VMAF', HelpMessage = 'Enter full path to encoded output file')]
[Parameter(Mandatory = $true, ParameterSetName = 'PASS', HelpMessage = 'Enter full path to encoded output file')]
[Parameter(Mandatory = $true, ParameterSetName = 'QP', HelpMessage = 'Enter full path to encoded output file')]
[ValidateNotNullOrEmpty()]
[Alias('O', 'Encode', 'Distorted')]
[string]$OutputPath,
Expand Down Expand Up @@ -1011,12 +1013,11 @@ if ($EncoderExtra) {
}
foreach ($item in $EncoderExtra.GetEnumerator()) {
# If setting is in hash, get the key
if ($paramHash.Values.Contains($item.Name.ToLower())) {
$key = $paramHash.Keys.Where({ $paramHash[$_] -contains $item.Name })
}
else {
$hasValue = $paramHash.Values.Contains($item.Name)
if ($hasValue -notcontains $true) {
continue
}
$key = $paramHash.Keys.Where({ $paramHash[$_] -contains $item.Name })
# Related setting param not passed via CLI
if (!$PSBoundParameters[$key]) {
if ($key -eq 'VBV') {
Expand Down
2 changes: 1 addition & 1 deletion modules/FFTools/FFTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ___________ .__ __ .__ ______________________
'@

# Current script release version. Used for download prompt
[version]$release = '2.4.2'
[version]$release = '2.4.3'


#### End module variables ####
Expand Down

0 comments on commit 0b649fd

Please sign in to comment.