Apache-MP3
view release on metacpan or search on metacpan
MP3/Resample.pm view on Meta::CPAN
@p = @DECOMPRESSOR_DEFAULTS;
}
my @i = map {$_*2} (0..(@p-1)/2);
%DECOMPRESSORS = @p;
@DECOMPRESSORS = @p[@i];
}
my $mime = shift or return @DECOMPRESSORS;
return $DECOMPRESSORS{$mime};
}
sub sample_popup {
my $self = shift;
my @bitrates = $self->presets;
unshift @bitrates,0;
my %labels = (0 => '--');
return (
start_form(-name=>'form'),
table(
TR(th('Resample:'),
td(
popup_menu(-name => 'bitrate',
-value => \@bitrates,
-labels => \%labels,
-onChange => 'form.submit()'
),
)
)
),
end_form);
}
sub directory_top {
my $self = shift;
print start_table({-width=>'100%'});
print start_TR,start_td;
$self->SUPER::directory_top(@_);
print end_td;
print td({-align=>'RIGHT',-valign=>'TOP'},
$self->sample_popup());
print end_TR,end_table;
}
sub open_file {
my $self = shift;
return $self->SUPER::open_file(@_) unless $self->bitrate;
my $file = shift;
my $bitrate = $self->bitrate;
my $presets = $self->presets($bitrate);
my $type = $self->r->lookup_file($file)->content_type;
MP3/Resample.pm view on Meta::CPAN
Here is another example, which takes advantage of the --preset feature
present in newer versions of Lame.
PerlSetVar ResamplePresets 'phone => --preset phone,\
voice => --preset voice,\
fm => --preset fm, \
tape => --preset tape,\
hifi => --preset hifi,\
cd => --preset cd'
The user will see a popup menu containing the entries "16 kbps", "56
kbps" and so forth, as well as a blank ("--") entry that is provided
automatically. Upon selecting each option the corresponding
command-line arguments will be slotted into the "%s" variable in the
encoder line specified by B<MP3Encoder>.
More complex command line options are possible. For example, to
invoke VBR (variable bitrate) encoding and resample the output to
22.05 kHz, you could apply these options
PerlSetVar ResamplePresets '16 => -b16 -v --resample 22.05,\
MP3/Resample.pm view on Meta::CPAN
Return the parameters to append to an MP3 playlist entry in order to
activate resampling.
=item presets()
Get the names of the bitrate presets specified by the ResamplePresets
configuration variable, or the default names. Called with an argument
equal to the name of a preset, returns the command-line arguments to
pass to the encoder.
=item sample_popup()
Draws the popup menu with the sample rate options.
=back
=head1 BUGS
When the external program is invoked to downsample the MP3 data, its
standard error is redirected to /dev/null. This prevents Lame's
informational messages from gumming up the server error log, but also
prevents the system from giving you helpful diagnostic messages, such
as "file not found". If you are having trouble with the downsampling,
( run in 1.692 second using v1.01-cache-2.11-cpan-364913b4093 )