« blib/lib/Media/Convert/Asset/Profile/mpeg2.pm
↑ Summary
blib/lib/Media/Convert/Asset/Profile/mp4.pm »
| 1 | package Media::Convert::Normalizer; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Media::Convert::Normalizer - normalize the audio of an asset. | ||||||||||
| 8 | |||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||
| 10 | |||||||||||
| 11 | Media::Convert::Normalizer->new(input => Media::Convert::Asset->new(...), output => Media::Convert::Asset->new(...))->run(); | ||||||||||
| 12 | |||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||
| 14 | |||||||||||
| 15 | C<Media::Convert::Normalizer> is a class to normalize the audio of a | ||||||||||
| 16 | given Media::Convert::Asset asset, using ffmpeg by default. | ||||||||||
| 17 | |||||||||||
| 18 | =head1 ATTRIBUTES | ||||||||||
| 19 | |||||||||||
| 20 | The following attributes are supported by | ||||||||||
| 21 | Media::Convert::Normalizer. | ||||||||||
| 22 | |||||||||||
| 23 | =head2 input | ||||||||||
| 24 | |||||||||||
| 25 | An L<Media::Convert::Asset> object for which the audio should be normalized. | ||||||||||
| 26 | |||||||||||
| 27 | Required. | ||||||||||
| 28 | |||||||||||
| 29 | =cut | ||||||||||
| 30 | |||||||||||
| 31 | 1 | has 'input' => ( | |||||||||
| 32 | is => 'rw', | ||||||||||
| 33 | isa => 'Media::Convert::Asset', | ||||||||||
| 34 | required => 1, | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | =head2 output | ||||||||||
| 38 | |||||||||||
| 39 | An L<Media::Convert::Asset> object that the normalized audio will be | ||||||||||
| 40 | written to, together with the copied video from the input file (if any). | ||||||||||
| 41 | |||||||||||
| 42 | Required. Must point to a .mkv file. | ||||||||||
| 43 | |||||||||||
| 44 | =cut | ||||||||||
| 45 | |||||||||||
| 46 | 1 | has 'output' => ( | |||||||||
| 47 | is => 'rw', | ||||||||||
| 48 | isa => 'Media::Convert::Asset', | ||||||||||
| 49 | required => 1, | ||||||||||
| 50 | ); | ||||||||||
| 51 | |||||||||||
| 52 | =head2 impl | ||||||||||
| 53 | |||||||||||
| 54 | The normalizer implementation to use. Defaults to "ffmpeg". Valid | ||||||||||
| 55 | options: any subclass of this module, assumes it is in the | ||||||||||
| 56 | C<Media::Convert::Normalizer::> namespace. | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | 1 | has 'impl' => ( | |||||||||
| 61 | is => 'rw', | ||||||||||
| 62 | isa => 'Str', | ||||||||||
| 63 | lazy => 1, | ||||||||||
| 64 | default => 'ffmpeg', | ||||||||||
| 65 | ); | ||||||||||
| 66 | |||||||||||
| 67 | =head1 METHODS | ||||||||||
| 68 | |||||||||||
| 69 | =head2 run | ||||||||||
| 70 | |||||||||||
| 71 | Performs the normalization. | ||||||||||
| 72 | |||||||||||
| 73 | =cut | ||||||||||
| 74 | |||||||||||
| 75 | 1 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 76 | 1 | my $self = shift; | |||||||||
| 77 | 1 | my $pkg = "Media::Convert::Normalizer::" . ucfirst($self->impl); | |||||||||
| 78 | 1 | eval "require $pkg;"; ## no critic(StringyEval) | |||||||||
| 79 | 1 | ▶ | if($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 0 | die "$@: $!"; | |||||||||
| 81 | } | ||||||||||
| 82 | 1 | return $pkg->new(input => $self->input, output => $self->output)->run(); | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 1 | 1; | |||||||||