Automate-Animate-FFmpeg

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

script/automate-animate-ffmpeg.pl
t/000-load.t
t/050-build-ffmpeg-cmdline.t
t/100-input-patterns.t
t/400-basic-animation.t
t/500-animation-from-files.t
t/900-scripts.t
t/manifest.t
t/pod-coverage.t
t/pod.t
t/t-data/images/blue.png
t/t-data/images/green.jpg
t/t-data/images/green.png
t/t-data/images/red.png
t/t-data/images/Περισσότερα/Κόκκινο.png
t/t-data/images/Περισσότερα/πράσινο.png
t/t-data/images/κίτρινο.png
xt/boilerplate.t
META.yml                                 Module YAML meta-data (added by MakeMaker)
META.json                                Module JSON meta-data (added by MakeMaker)

README  view on Meta::CPAN

    FFmpeg <https://ffmpeg.org>. An excellent, open source program.

    FFmpeg binaries must already be installed in your system.

        use Automate::Animate::FFmpeg;
        my $aaFFobj = Automate::Animate::FFmpeg->new({
          # specify input images in any of these 4 ways or a combination:
          # 1) by specifying each input image (in the order to appear)
          #    in an ARRAYref
          'input-images' => [
            '/xyz/abc/im1.png',
            '/xyz/abc/im2.png',
            ...
          ],
          # 2) by specifying an input pattern (glob or regex)
          #    and optional search path
          'input-pattern' => ['*.png', './'],
          # 3) by specifying an ARRAY of input patterns
          #    (see above)
          'input-patterns' => [
              ['*.tiff'],
              # specify a regex to filter-in all files under search dir
              # NOTE: observe the escaping rules for each quotation method you use
              [qw!regex(/photos2023-.+?\\.png/i)!, 'abc/xyz'],
          ],
          # 4) by specifying a file which contains filenames
          #    of the input images.
          'input-images-from-file' => 'file-containing-a-list-of-pathnames-to-images.txt',
    
          # optionally specify the duration of each frame=image
          'frame-duration' => 5.3, # seconds
    
          'output-filename' => 'out.mp4',
        });
        # no animation yet!
    
        # options can be set after construction as well:
    
        # optionally add some extra params to FFmpeg as an arrayref
        $aaFF->ffmpeg_extra_params(['-x', 'abc', '-y', 1, 2, 3]);
    
        # you can also add images here, order is important
        $aaFF->input_images(['img1.png', 'img2.png']) or die;
    
        # or add images via a search pattern and optional search dir
        $aaFF->input_pattern(['*.png', './']);
    
        # or add images via multiple search patterns
        $aaFF->input_patterns([
            ['*.png', './'],
            ['*.jpg', '/images'],
            ['*.tiff'], # this defaults to current dir
        ]) or die;
    
        # and make the animation:
        die "make_animation() has failed"
          unless $aaFF->make_animation()
        ;

INSTALLATION

README  view on Meta::CPAN


METHODS

 new

      my $ret = Automate::Animate::FFmpeg->new({ ... });

    All arguments are supplied via a hashref with the following keys:

      * input-images : an array of pathnames to input images. Image types
      can be what ffmpeg understands: png, jpeg, tiff, and lots more.

      * input-pattern : an arrayref of 1 or 2 items. The first item is the
      pattern which complies to what File::Find::Rule understands (See
      [https://metacpan.org/pod/File::Find::Rule#Matching-Rules]). For
      example *.png, regular expressions can be passed by enclosing them in
      regex(/.../modifiers) and should include the //. Modifiers can be
      after the last /. For example regex(/\.(mp3|ogg)$/i).

      The optional second parameter is the search path. If not specified,
      the current working dir will be used.

      Note that there is no implicit or explicit eval() in compiling the
      user-specified regex (i.e. when pattern is in the form
      regex(/.../modifiers)). Additionally there is a check in place for
      the user-specified modifiers to the regex: die "never trust user

README  view on Meta::CPAN


      $aaFF->input_pattern($m) or die "failed";

    Initiates a search via File::Find::Rule for the input image files to
    create the animation using the pattern $m->[0] with starting search dir
    being $m->[1], which is optional -- default being Cwd::cwd (current
    working dir). So, $m is an array ref of one or two items. The first is
    the search pattern and the optional second is the search path,
    defaulting to the current working dir.

    The pattern ($m->[0]) can be a shell wildcard, e.g. *.png, or a regex
    specified as regex(/REGEX-HERE/modifiers), for example
    regex(/\.(mp3|ogg)$/i) Both shell wildcards and regular expressions
    must comply with what File::Find::Rule expects, see
    [https://metacpan.org/pod/File::Find::Rule#Matching-Rules].

    The results of the search will be added to the list of input images in
    the order of appearance.

    Multiple calls to input_pattern() will load input images in the order
    they are found.

README  view on Meta::CPAN

    are called.

    Caveat: the regex is parsed, compiled and passed on to
    File::Find::Rule. Escaping of special characters (e.g. the backslash)
    may be required.

    Caveat: the order of the matched input images is entirely up to
    File::Find::Rule. There may be unexpected results when filenames
    contain unicode characters. Consider these orderings for example:

      * blue.png, κίτρινο.png, red.png,

      * blue.png, γάμμα.png, κίτρινο.png, red.png,

      * blue.png, κίτρινο.png, γαμμα.png red.png,

    Return value:

      * 0 on failure, 1 on success.

 input_patterns($m)

      $aaFF->input_patterns($m) or die "failed";

    Argument $m is an array of arrays each composed of one or two items.

README  view on Meta::CPAN

    
        [--frame-duration/-d SECONDS : specify the duration of each
        frame=input image in (fractional) seconds.]
    
        [--verbosity/-V N : specify verbosity. Zero being the mute.
        Default is 0.]

    As an example,

        automate-animate-ffmpeg.pl \
           --input-pattern '*.png' 't/t-data/images' \
           --output-filename out.mp4 \
           --frame-duration 3.5
    
        # or
    
        automate-animate-ffmpeg.pl \
           --input-pattern 'regex(/.+?.png/i)' \
           --output-filename out.mp4 \
           --frame-duration 3.5

 UNICODE FILENAMES

    Unicode filenames are supported ... I think. Please report any
    problems.

SEE ALSO

README.md  view on Meta::CPAN

An excellent, open source program.

FFmpeg binaries must already be installed in your system.

    use Automate::Animate::FFmpeg;
    my $aaFFobj = Automate::Animate::FFmpeg->new({
      # specify input images in any of these 4 ways or a combination:
      # 1) by specifying each input image (in the order to appear)
      #    in an ARRAYref
      'input-images' => [
        '/xyz/abc/im1.png',
        '/xyz/abc/im2.png',
        ...
      ],
      # 2) by specifying an input pattern (glob or regex)
      #    and optional search path
      'input-pattern' => ['*.png', './'],
      # 3) by specifying an ARRAY of input patterns
      #    (see above)
      'input-patterns' => [
          ['*.tiff'],
          # specify a regex to filter-in all files under search dir
          # NOTE: observe the escaping rules for each quotation method you use
          [qw!regex(/photos2023-.+?\\.png/i)!, 'abc/xyz'],
      ],
      # 4) by specifying a file which contains filenames
      #    of the input images.
      'input-images-from-file' => 'file-containing-a-list-of-pathnames-to-images.txt',

      # optionally specify the duration of each frame=image
      'frame-duration' => 5.3, # seconds

      'output-filename' => 'out.mp4',
    });
    # no animation yet!

    # options can be set after construction as well:

    # optionally add some extra params to FFmpeg as an arrayref
    $aaFF->ffmpeg_extra_params(['-x', 'abc', '-y', 1, 2, 3]);

    # you can also add images here, order is important
    $aaFF->input_images(['img1.png', 'img2.png']) or die;

    # or add images via a search pattern and optional search dir
    $aaFF->input_pattern(['*.png', './']);

    # or add images via multiple search patterns
    $aaFF->input_patterns([
        ['*.png', './'],
        ['*.jpg', '/images'],
        ['*.tiff'], # this defaults to current dir
    ]) or die;

    # and make the animation:
    die "make_animation() has failed"
      unless $aaFF->make_animation()
    ;

# INSTALLATION

README.md  view on Meta::CPAN

download a static build from said website.

# METHODS

## `new`

    my $ret = Automate::Animate::FFmpeg->new({ ... });

All arguments are supplied via a hashref with the following keys:

- `input-images` : an array of pathnames to input images. Image types can be what ffmpeg understands: png, jpeg, tiff, and lots more.
- `input-pattern` : an arrayref of 1 or 2 items. The first item is the pattern
which complies to what [File::Find::Rule](https://metacpan.org/pod/File%3A%3AFind%3A%3ARule) understands (See \[https://metacpan.org/pod/File::Find::Rule#Matching-Rules\]).
For example `*.png`, regular expressions can be passed by enclosing them in `regex(/.../modifiers)`
and should include the `//`. Modifiers can be after the last `/`. For example `regex(/\.(mp3|ogg)$/i)`.

    The optional second parameter is the search path. If not specified, the current working dir will be used.

    Note that there is no implicit or explicit `eval()` in compiling the user-specified
    regex (i.e. when pattern is in the form `regex(/.../modifiers)`).
    Additionally there is a check in place for the user-specified modifiers to the regex:
    `die "never trust user input" unless $modifiers=~/^[msixpodualn]+$/;`.
    Thank you [Discipulus](https://www.perlmonks.org/?node_id=174111).

README.md  view on Meta::CPAN

    $aaFF->input_pattern($m) or die "failed";

Initiates a search via [File::Find::Rule](https://metacpan.org/pod/File%3A%3AFind%3A%3ARule) for the
input image files to create the animation using
the pattern `$m->[0]` with starting search dir being `$m->[1]`,
which is optional -- default being `Cwd::cwd` (current working dir).
So, `$m` is an array ref of one or two items. The first is the search
pattern and the optional second is the search path, defaulting to the current
working dir.

The pattern (`$m->[0]`) can be a shell wildcard, e.g. `*.png`,
or a regex specified as `regex(/REGEX-HERE/modifiers)`, for example
`regex(/\.(mp3|ogg)$/i)` Both shell wildcards and regular expressions
must comply with what [File::Find::Rule](https://metacpan.org/pod/File%3A%3AFind%3A%3ARule) expects, see \[https://metacpan.org/pod/File::Find::Rule#Matching-Rules\].

The results of the search will be added to the list of input images
in the order of appearance.

Multiple calls to `input_pattern()` will load
input images in the order they are found.

README.md  view on Meta::CPAN

in the order they are called.

**Caveat**: the regex is parsed, compiled and passed on to [File::Find::Rule](https://metacpan.org/pod/File%3A%3AFind%3A%3ARule).
Escaping of special characters (e.g. the backslash) may be required.

**Caveat**: the order of the matched input images is entirely up
to [File::Find::Rule](https://metacpan.org/pod/File%3A%3AFind%3A%3ARule). There may be unexpected results
when filenames contain unicode characters. Consider
these orderings for example:

- `blue.png, κίτρινο.png, red.png`,
- `blue.png, γάμμα.png, κίτρινο.png, red.png`,
- `blue.png, κίτρινο.png, γαμμα.png red.png`,

Return value:

- 0 on failure, 1 on success.

## `input_patterns($m)`

    $aaFF->input_patterns($m) or die "failed";

Argument `$m` is an array of arrays each composed of one or two items.

README.md  view on Meta::CPAN


    [--frame-duration/-d SECONDS : specify the duration of each
    frame=input image in (fractional) seconds.]

    [--verbosity/-V N : specify verbosity. Zero being the mute.
    Default is 0.]

As an example,

    automate-animate-ffmpeg.pl \
       --input-pattern '*.png' 't/t-data/images' \
       --output-filename out.mp4 \
       --frame-duration 3.5

    # or

    automate-animate-ffmpeg.pl \
       --input-pattern 'regex(/.+?.png/i)' \
       --output-filename out.mp4 \
       --frame-duration 3.5

## UNICODE FILENAMES

Unicode filenames are supported ... I think. Please report
any problems.

# SEE ALSO

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN


	# input image filenames are read from specified file (one filename per line)
	$ak = 'input-images-from-file';
	if( exists($params->{$ak}) && defined($params->{$ak})
		&& scalar($params->{$ak})
	){
		if( ! $self->input_file_with_images($params->{$ak}) ){ print STDERR perl2dump($params->{$ak})."${whoami} (via $parent), line ".__LINE__." : error, failed to load input images from file containing their pathnames: '".$params->{$ak}."'.\n"; return un...
	}

	# input images can be specified via a pattern and a search dir
	# like : 'input-pattern' => ['*.png', '/x/y/searchdir']
	$ak = 'input-pattern';
	if( exists($params->{$ak}) && defined($params->{$ak}) ){
		if( ref($params->{$ak})ne'ARRAY' ){ print STDERR perl2dump($params->{$ak})."${whoami} (via $parent), line ".__LINE__." : error, the argument to '$ak' must be an ARRAYref of 1 or 2 items: the pattern and optionally the search dir. See above for what...
		if( ! $self->input_pattern($params->{$ak}) ){ print STDERR perl2dump($params->{$ak})."${whoami} (via $parent), line ".__LINE__." : error, failed to find input files based on the above pattern and search dir.\n"; return undef }
	}
	# or via multiple patterns (an ARRAY of ARRAY patterns, as above)
	$ak = 'input-patterns';
	if( exists($params->{$ak}) && defined($params->{$ak}) ){
		if( ref($params->{$ak})ne'ARRAY' ){ print STDERR perl2dump($params->{$ak})."${whoami} (via $parent), line ".__LINE__." : error, the argument to '$ak' must be an ARRAYref of one or more ARRAYrefs each of 1 or 2 items: the pattern and optionally the ...
		if( ! $self->input_patterns($params->{$ak}) ){ print STDERR perl2dump($params->{$ak})."${whoami} (via $parent), line ".__LINE__." : error, failed to find input files based on the above pattern and search dir.\n"; return undef }

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN

	while( <$fh> ){
		chomp;
		s/#.*$//;
		s/^\s*$//;
		$self->input_images($_) unless /^\s*$/;
	} close $fh;
	return 1
}
sub	clear_input_images { $#{ $_[0]->{'input-images'} } = -1 }
# Add using a single pattern/searchdir
# add image files via a pattern and an input dir, e.g. '*.png', '/x/y/z/'
# make sure that the order you expect is what you get during the pattern materialisation
# the search dir is optional, default is Cwd::cwd
sub	input_pattern {
	my ($self, $params) = @_;
	my $parent = ( caller(1) )[3] || "N/A";
	my $whoami = ( caller(0) )[3];
	my $verbos = $self->verbosity();
	my ($_pattern, $indir) = @$params;
	my $indir_need_encode_utf8 = 0;
	if( ! defined $indir ){

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN

An excellent, open source program.

FFmpeg binaries must already be installed in your system.

    use Automate::Animate::FFmpeg;
    my $aaFFobj = Automate::Animate::FFmpeg->new({
      # specify input images in any of these 4 ways or a combination:
      # 1) by specifying each input image (in the order to appear)
      #    in an ARRAYref
      'input-images' => [
        '/xyz/abc/im1.png',
        '/xyz/abc/im2.png',
        ...
      ],
      # 2) by specifying an input pattern (glob or regex)
      #    and optional search path
      'input-pattern' => ['*.png', './'],
      # 3) by specifying an ARRAY of input patterns
      #    (see above)
      'input-patterns' => [
          ['*.tiff'],
          # specify a regex to filter-in all files under search dir
	  # NOTE: observe the escaping rules for each quotation method you use
          [qw!regex(/photos2023-.+?\\.png/i)!, 'abc/xyz'],
      ],
      # 4) by specifying a file which contains filenames
      #    of the input images.
      'input-images-from-file' => 'file-containing-a-list-of-pathnames-to-images.txt',

      # optionally specify the duration of each frame=image
      'frame-duration' => 5.3, # seconds

      'output-filename' => 'out.mp4',
    });
    # no animation yet!

    # options can be set after construction as well:

    # optionally add some extra params to FFmpeg as an arrayref
    $aaFF->ffmpeg_extra_params(['-x', 'abc', '-y', 1, 2, 3]);

    # you can also add images here, order is important
    $aaFF->input_images(['img1.png', 'img2.png']) or die;

    # or add images via a search pattern and optional search dir
    $aaFF->input_pattern(['*.png', './']);

    # or add images via multiple search patterns
    $aaFF->input_patterns([
	['*.png', './'],
	['*.jpg', '/images'],
	['*.tiff'], # this defaults to current dir
    ]) or die;

    # and make the animation:
    die "make_animation() has failed"
      unless $aaFF->make_animation()
    ;

=head1 INSTALLATION

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN

=head1 METHODS

=head2 C<new>

  my $ret = Automate::Animate::FFmpeg->new({ ... });

All arguments are supplied via a hashref with the following keys:

=over 4

=item * C<input-images> : an array of pathnames to input images. Image types can be what ffmpeg understands: png, jpeg, tiff, and lots more.

=item * C<input-pattern> : an arrayref of 1 or 2 items. The first item is the pattern
which complies to what L<File::Find::Rule> understands (See [https://metacpan.org/pod/File::Find::Rule#Matching-Rules]).
For example C<*.png>, regular expressions can be passed by enclosing them in C<regex(/.../modifiers)>
and should include the C<//>. Modifiers can be after the last C</>. For example C<regex(/\.(mp3|ogg)$/i)>.

The optional second parameter is the search path. If not specified, the current working dir will be used.

Note that there is no implicit or explicit C<eval()> in compiling the user-specified
regex (i.e. when pattern is in the form C<regex(/.../modifiers)>).
Additionally there is a check in place for the user-specified modifiers to the regex:
C<die "never trust user input" unless $modifiers=~/^[msixpodualn]+$/;>.
Thank you L<Discipulus|https://www.perlmonks.org/?node_id=174111>.

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN

  $aaFF->input_pattern($m) or die "failed";

Initiates a search via L<File::Find::Rule> for the
input image files to create the animation using
the pattern C<$m-E<gt>[0]> with starting search dir being C<$m-E<gt>[1]>,
which is optional -- default being C<Cwd::cwd> (current working dir).
So, C<$m> is an array ref of one or two items. The first is the search
pattern and the optional second is the search path, defaulting to the current
working dir.

The pattern (C<$m-E<gt>[0]>) can be a shell wildcard, e.g. C<*.png>,
or a regex specified as C<regex(/REGEX-HERE/modifiers)>, for example
C<regex(/\.(mp3|ogg)$/i)> Both shell wildcards and regular expressions
must comply with what L<File::Find::Rule> expects, see [https://metacpan.org/pod/File::Find::Rule#Matching-Rules].

The results of the search will be added to the list of input images
in the order of appearance.

Multiple calls to C<input_pattern()> will load
input images in the order they are found.

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN

B<Caveat>: the regex is parsed, compiled and passed on to L<File::Find::Rule>.
Escaping of special characters (e.g. the backslash) may be required.

B<Caveat>: the order of the matched input images is entirely up
to L<File::Find::Rule>. There may be unexpected results
when filenames contain unicode characters. Consider
these orderings for example:

=over 2

=item * C<blue.png, κίτρινο.png, red.png>,

=item * C<blue.png, γάμμα.png, κίτρινο.png, red.png>,

=item * C<blue.png, κίτρινο.png, γαμμα.png red.png>,

=back

Return value:

=over 4

=item * 0 on failure, 1 on success.

=back

lib/Automate/Animate/FFmpeg.pm  view on Meta::CPAN


    [--frame-duration/-d SECONDS : specify the duration of each
    frame=input image in (fractional) seconds.]

    [--verbosity/-V N : specify verbosity. Zero being the mute.
    Default is 0.]

As an example,

    automate-animate-ffmpeg.pl \
       --input-pattern '*.png' 't/t-data/images' \
       --output-filename out.mp4 \
       --frame-duration 3.5

    # or

    automate-animate-ffmpeg.pl \
       --input-pattern 'regex(/.+?.png/i)' \
       --output-filename out.mp4 \
       --frame-duration 3.5

=head2 UNICODE FILENAMES

Unicode filenames are supported ... I think. Please report
any problems.

=head1 SEE ALSO

t/050-build-ffmpeg-cmdline.t  view on Meta::CPAN


use Automate::Animate::FFmpeg;

our $VERSION = '0.13';

my $curdir = Cwd::abs_path($FindBin::Bin);

my $anim_outfile = 'abc';

my @inpimages = (
	File::Spec->catfile($curdir, 't-data', 'images', 'red.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'green.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'blue.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'κίτρινο.png'),
);
my $aaFF = Automate::Animate::FFmpeg->new({
	'input-images' => \@inpimages,
	'output-filename' => $anim_outfile,
});
ok(defined $aaFF, 'Automate::Animate::FFmpeg->new()'." : called and got defined result.") or BAIL_OUT;

my $exe; if( !defined($exe=$aaFF->ffmpeg_executable()) || ($exe=~/^\s*$/) || (! -x $exe) ){
	diag "There is no FFmpeg executable set in this module. No tests will be run.";
	done_testing;

t/100-input-patterns.t  view on Meta::CPAN

use Automate::Animate::FFmpeg;

our $VERSION = '0.13';

my $curdir = Cwd::abs_path($FindBin::Bin);

my $anim_outfile = 'abc';
my $VERBOSITY = 10;

my @inpimages = (
	File::Spec->catfile($curdir, 't-data', 'images', 'blue.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'κίτρινο.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'red.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'green.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'Περισσότερα', 'πράσινο.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'Περισσότερα', 'Κόκκινο.png'),
);
my $aaFF = Automate::Animate::FFmpeg->new({
	'verbosity' => $VERBOSITY
});
ok(defined $aaFF, 'Automate::Animate::FFmpeg->new()'." : called and got defined result.") or BAIL_OUT;

is($aaFF->input_pattern(['*.png']), 1, 'input_pattern()'." : called and got good result.");
my $s1 = { map { $_ => 1 } @{ $aaFF->input_images() } };
my $s2 = { map { $_ => 1 } @inpimages };
is_deeply($s1, $s2, 'input_pattern()'." : called and got the images expected.") or BAIL_OUT("got:\n".perl2dump($s1)."\nexpected:\n".perl2dump($s2)."see above");
$aaFF->clear_input_images();

is($aaFF->input_pattern(['*.png', File::Spec->catdir($curdir, 't-data')]), 1, 'input_pattern()'." : called and got good result.");
$s1 = { map { $_ => 1 } @{ $aaFF->input_images() } };
$s2 = { map { $_ => 1 } @inpimages };
is_deeply($s1, $s2, 'input_pattern()'." : called and got the images expected.") or BAIL_OUT("got:\n".perl2dump($s1)."\nexpected:\n".perl2dump($s2)."see above");
$aaFF->clear_input_images();

is($aaFF->input_pattern([qw!regex(/.+?\.PNG$/i)!, File::Spec->catdir($curdir, 't-data')]), 1, 'input_pattern()'." : called and got good result.");
$s1 = { map { $_ => 1 } @{ $aaFF->input_images() } };
$s2 = { map { $_ => 1 } @inpimages };
is_deeply($s1, $s2, 'input_pattern()'." : called and got the images expected.") or BAIL_OUT("got:\n".perl2dump($s1)."\nexpected:\n".perl2dump($s2)."see above");
$aaFF->clear_input_images();

t/400-basic-animation.t  view on Meta::CPAN


my $curdir = Cwd::abs_path($FindBin::Bin);

# if for debug you change this make sure that it has path in it e.g. ./xyz
my $tmpdir = tempdir(); # will be erased unless a BAIL_OUT or env var set
ok(-d $tmpdir, "output dir exists");

my $anim_outfile = File::Spec->catfile($tmpdir, 'out.mp4');

my @inpimages = (
	File::Spec->catfile($curdir, 't-data', 'images', 'red.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'green.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'blue.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'κίτρινο.png'),
);

$aaFF->input_images(\@inpimages);
$aaFF->output_filename($anim_outfile);
$aaFF->frame_duration(3);
is($aaFF->make_animation(), 1, "make_animation() : run and got good result back");
ok(-f $anim_outfile, "$anim_outfile created") or BAIL_OUT("no output was created, something seriously wrong.");

diag "temp dir: $tmpdir ..." if exists($ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}) && $ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}>0;

t/500-animation-from-files.t  view on Meta::CPAN

	done_testing;
	exit(0);
}

# if for debug you change this make sure that it has path in it e.g. ./xyz
my $tmpdir = tempdir(); # will be erased unless a BAIL_OUT or env var set
ok(-d $tmpdir, "output dir exists");

# it should start with yellow/κίτρινο!
my @inpimages = reverse (
	File::Spec->catfile($curdir, 't-data', 'images', 'red.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'green.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'blue.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'κίτρινο.png'),
);

my $anim_outfile = File::Spec->catfile($tmpdir, 'out.mp4');
my $input_images_file = File::Spec->catfile($tmpdir, 'inimages.txt');
my $FH;
ok(open($FH, '>:encoding(UTF-8)', $input_images_file), "file to store input images ($input_images_file) opened for writing.") or BAIL_OUT("no it failed: $!");
for(@inpimages){ print $FH $_ . "\n" }
close $FH;
$aaFF->output_filename($anim_outfile);
is($aaFF->input_file_with_images($input_images_file), 1, "set input images via a file containing the list ($input_images_file).") or BAIL_OUT;

t/900-scripts.t  view on Meta::CPAN

# if for debug you change this make sure that it has path in it e.g. ./xyz
my $tmpdir = tempdir(); # will be erased unless a BAIL_OUT or env var set
ok(-d $tmpdir, "output dir exists");

my $FAILURE_REGEX = qr/(?:\: error,)|(?:Usage)/;

my $FRAME_DURATION = 3;
my $VERBOSITY = 10;
my $outfile = File::Spec->catfile($tmpdir, "γαγαγαγ.mp4");
my @IMGS = (
	File::Spec->catfile($curdir, 't-data', 'images', 'blue.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'green.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'red.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'κίτρινο.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'Περισσότερα', 'πράσινο.png'),
	File::Spec->catfile($curdir, 't-data', 'images', 'Περισσότερα', 'Κόκκινο.png'),
);
my $input_images_file = File::Spec->catfile($tmpdir, "filelist.txt");
my $FH;
ok(open($FH, '>:encoding(UTF-8)', $input_images_file), "opened file '$input_images_file' for writing the file list.") or BAIL_OUT;
print $FH join("\n", @IMGS)."\n"; close $FH;

# script must be relative!
my $execu = File::Spec->catfile('script', 'automate-animate-ffmpeg.pl');

my @TESTS = (
	# test the scripts (the keys) with the scripts contained in the values
	# script-filename	  CLI-params-for-success    CLI-params-for-failure
	# input pattern to select exactly 4 images with shell glob
	[
		# will succeed
		[$execu, '--output-filename', $outfile, '--verbosity', $VERBOSITY, '--frame-duration', $FRAME_DURATION, '--input-pattern', '*.png', '.'],
		# will fail
		[$execu, '--output-filename', $outfile, '--verbosity', $VERBOSITY, '--frame-duration', $FRAME_DURATION, '--input-pattern', 'aa*.png', '.'],
	],
	# input pattern to select exactly 4 images with regex
	[
		# will succeed
		[$execu, '--output-filename', $outfile, '--verbosity', $VERBOSITY, '--frame-duration', $FRAME_DURATION, '--input-pattern', qw!regex(/.+?\.png/i)!, '.'],
		# will fail
		[$execu, '--output-filename', $outfile, '--verbosity', $VERBOSITY, '--frame-duration', $FRAME_DURATION, '--input-pattern', qw!regex(/.+?\.tiff/i)!, '.'],
	],
	# 4 input images using --input-image for each
	[
		# will succeed
		[$execu, '--output-filename', $outfile, '--verbosity', $VERBOSITY, '--frame-duration', $FRAME_DURATION, map { ('--input-image', $_) } @IMGS],
		# will fail
		[$execu, '--output-filename', $outfile, '--verbosity', $VERBOSITY, '--frame-duration', $FRAME_DURATION]
	],



( run in 2.225 seconds using v1.01-cache-2.11-cpan-788537b7465 )