Skip to content

Commit

Permalink
Merge pull request #44 from whatbox/master
Browse files Browse the repository at this point in the history
Add --preset='s' argument
  • Loading branch information
robinbowes committed Jan 6, 2015
2 parents b65356a + 5642396 commit 5a150d6
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions flac2mp3.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,43 @@
my $flaccmd = 'flac';
my $lamecmd = 'lame';

# Modify lame options if required
my @lameargs = qw (
--noreplaygain
--vbr-new
-V 2
-h
--nohist
--quiet
# Modify presets if required
my %presets = (
'V2' => [
'--noreplaygain',
'--vbr-new',
'-V 2',
'-h',
'--nohist',
'--quiet'
],
'V0' => [
'--noreplaygain',
'--vbr-new',
'-V 0',
'-h',
'--nohist',
'--quiet'
],
'320' => [
'--noreplaygain',
'-b 320',
'-h',
'--nohist',
'--quiet'
],
);

# Use V2 preset by default
my $PRESET_DEFAULT = 'V2';

# Use one process by default
my $NUM_PROCESSES_DEFAULT = 1;

# -------- User-config options end here ---------

my @lameargs = @{$presets{$PRESET_DEFAULT}};

# use Id3 v2.3.0 tag separator by default
my $TAG_SEPARATOR_DEFAULT = '/';

Expand Down Expand Up @@ -156,7 +178,8 @@
\%Options, "quiet!", "tagdiff", "debug!",
"tagsonly!", "force!", "usage", "help",
"version", "pretend", "skipfile!", "skipfilename=s",
"processes=i", "tagseparator=s", "lameargs=s", "copyfiles"
"processes=i", "tagseparator=s", "preset=s", "lameargs=s",
"copyfiles"
);

# info flag is the inverse of --quiet
Expand All @@ -175,6 +198,15 @@
or $Options{usage}
or $Options{help} );

croak "--lameargs and --preset are mutually exclusive options"
if $Options{lameargs} && $Options{preset};

croak "Chosen preset does not exist"
if $Options{preset} && !defined $presets{$Options{preset}};

@lameargs = @{$presets{$Options{preset}}}
if $Options{preset};

@lameargs = $Options{lameargs}
if $Options{lameargs};

Expand Down Expand Up @@ -404,6 +436,9 @@ sub showusage {
--tagsonly Don't do any transcoding - just update tags
--force Force transcoding and tag update even if not required
--tagdiff Print source/dest tag values if different
--preset='s' Select a popular parameter set for the LAME encoder
Valid: "V0", "V2", "320"
Default: "V2"
--lameargs='s' specify parameter(string) to be passed to the LAME Encoder
Default: "--noreplaygain --vbr-new -V 2 -h --nohist --quiet"
--noskipfile Ignore any skip files
Expand Down

0 comments on commit 5a150d6

Please sign in to comment.