« blib/lib/Media/Convert/Normalizer/Ffmpeg.pm
↑ Summary
blib/lib/Media/Convert/Asset/Profile/av1.pm »
| 1 | package Media::Convert::Asset::PNGGen; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | extends 'Media::Convert::Asset'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Media::Convert::Asset::PNGGen - Generate a video from a (list of) PNG files | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | use Media::Convert::Asset; | ||||||||||||||||||||||||||||
| 15 | use Media::Convert::Asset::PNGGen; | ||||||||||||||||||||||||||||
| 16 | use Media::Convert::Pipe; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | my $input = Media::Convert::Asset::PNGGen->new(url => $input_png_filename); | ||||||||||||||||||||||||||||
| 19 | my $output = Media::Convert::Asset->new(url => $output_filename); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Media::Convert::Pipe->new(inputs => [$input], output => $output)->run; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | This module uses the lavfi (the "libavfilter input virtual device", you | ||||||||||||||||||||||||||||
| 26 | figure out how that matches the abbreviation) functionality in ffmpeg to | ||||||||||||||||||||||||||||
| 27 | convert an image file into a video. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | It will automatically match the input framerate to the output framerate; | ||||||||||||||||||||||||||||
| 30 | this means that the framerate on the output file I<must> be set, either | ||||||||||||||||||||||||||||
| 31 | through a profile or by setting it explicitly. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head2 audio_channels | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | The option to give to the C<channel_layout> attribute of the C<anullsrc> | ||||||||||||||||||||||||||||
| 38 | audio source. Defaults to "mono". | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | has "audio_channels" => ( | |||||||||||||||||||||||||||
| 43 | is => "rw", | ||||||||||||||||||||||||||||
| 44 | isa => "Str", | ||||||||||||||||||||||||||||
| 45 | default => "mono", | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head2 loop | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | If truthy, loops over the PNG files given. Useful if there is only one | ||||||||||||||||||||||||||||
| 51 | PNG file, but then a video length for the output file should be given. | ||||||||||||||||||||||||||||
| 52 | If falsy, stops after all the input files are processed. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Defaults to true. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | has "loop" => ( | |||||||||||||||||||||||||||
| 59 | is => "rw", | ||||||||||||||||||||||||||||
| 60 | isa => "Bool", | ||||||||||||||||||||||||||||
| 61 | default => 1, | ||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head1 BUGS | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | This module does not work correctly with L<Media::Convert::Map>. If you | ||||||||||||||||||||||||||||
| 67 | need to create a map, first generate a video with this file and then | ||||||||||||||||||||||||||||
| 68 | initialize a regular L<Media::Convert::Asset> object with it. | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub readopts { | ||||||||||||||||||||||||||
|
Subroutine
readopts: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 74 | 0 | my $output = shift; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if(defined($output->video_size) && ($self->video_size ne $output->video_size)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $output->video_size and $self->video_size ne $output->video_size
MC/DC0%0/2
defined $output->video_size and $self->video_size ne $output->video_size
defined $output->video_size
$self->video_size ne $output->video_size
Truth table0%0/3
A and B
A= defined $output->video_sizeB= $self->video_size ne $output->video_size
| |||||||||||||||||||||||||||||
| 77 | 0 | carp "Video resolution does not match image resolution. Will scale, but the result may be suboptimal..."; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 0 | my @rv; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | if($self->loop) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | push @rv, ("-loop", '1'); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 0 | push @rv, ('-framerate', $output->video_framerate, '-i', $self->url, '-f', 'lavfi', '-i', 'anullsrc=channel_layout=' . $self->audio_channels); | |||||||||||||||||||||||||||
| 85 | 0 | return @rv; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | 1; | |||||||||||||||||||||||||||