/[amv]/frames.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /frames.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Thu Jul 19 17:09:18 2007 UTC (16 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1223 byte(s)
small script to create template avi file
1 #!/usr/bin/perl -w
2
3 # frames.pl
4 #
5 # 07/19/07 18:06:13 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use strict;
8
9 use GD;
10 use File::Path;
11
12 my $tmp = '/tmp/frames';
13 my $out = '/tmp/frames.avi';
14
15 mkpath $tmp || die "can't create $tmp: $!";
16
17 my $im = new GD::Image( 160, 120 );
18
19 my $im_col;
20
21 sub col {
22 my $hex = shift;
23 $hex = lc($hex);
24 die "not hex: $hex" unless ( $hex =~ m/^([0-9a-f])([0-9a-f])([0-9a-f])$/i );
25 my ( $r,$g,$b ) = ( hex($1 . $1),hex($2 . $2),hex($3 . $3) );
26 if ( ! defined( $im_col->{$hex} ) ) {
27 my $col = $im->colorAllocate( $r, $g, $b );
28 warn "creating color $col $hex\n";
29 $im_col->{$hex} = $col;
30 }
31 return $im_col->{$hex};
32 }
33
34 my @cols = (
35 '000',
36 'f00',
37 '0f0',
38 '00f',
39 'ff0',
40 '0ff',
41 'fff',
42 );
43
44 my $frame = 1;
45
46 foreach my $c ( @cols ) {
47 foreach ( 1 .. 16 ) {
48 $im->fill(50,50, col($c) );
49 warn "frame $frame\n";
50 my $path = sprintf('%s/%03d.jpg', $tmp, $frame++);
51 open(my $fh, '>', $path) || die "can't open $path: $!";
52 print $fh $im->jpeg(100) || die "can't save picture $path: $!";
53 close($fh) || die "can't close picture $path: $!";
54 }
55 }
56
57 system("ffmpeg -i $tmp/%03d.jpg -r 16 -vcodec copy -y $out") == 0 or
58 die "encoding failed: $?";
59
60 rmdir $tmp || die "can't remove $tmp: $!";

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26