line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Video::Generator; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
26393
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
5
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
81
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
8
|
3
|
|
|
3
|
|
2580
|
use English; |
|
3
|
|
|
|
|
14185
|
|
|
3
|
|
|
|
|
41
|
|
9
|
3
|
|
|
3
|
|
4370
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
24311
|
|
|
3
|
|
|
|
|
163
|
|
10
|
3
|
|
|
3
|
|
9217
|
use Getopt::Std; |
|
3
|
|
|
|
|
145
|
|
|
3
|
|
|
|
|
206
|
|
11
|
3
|
|
|
3
|
|
2920
|
use Image::Select; |
|
3
|
|
|
|
|
271215
|
|
|
3
|
|
|
|
|
158
|
|
12
|
3
|
|
|
3
|
|
34
|
use Readonly; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
144
|
|
13
|
3
|
|
|
3
|
|
2718
|
use Video::Generator; |
|
3
|
|
|
|
|
230365
|
|
|
3
|
|
|
|
|
33
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constants. |
16
|
|
|
|
|
|
|
Readonly::Scalar our $EMPTY_STR => q{}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Version. |
19
|
|
|
|
|
|
|
our $VERSION = 0.07; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Constructor. |
22
|
|
|
|
|
|
|
sub new { |
23
|
1
|
|
|
1
|
1
|
12
|
my $class = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Create object. |
26
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Object. |
29
|
1
|
|
|
|
|
3
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Run script. |
33
|
|
|
|
|
|
|
sub run { |
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Process arguments. |
37
|
0
|
|
|
|
|
|
$self->{'_opts'} = { |
38
|
|
|
|
|
|
|
'd' => 10000, |
39
|
|
|
|
|
|
|
'f' => 60, |
40
|
|
|
|
|
|
|
'h' => 0, |
41
|
|
|
|
|
|
|
'i' => $EMPTY_STR, |
42
|
|
|
|
|
|
|
's' => '1920x1080', |
43
|
|
|
|
|
|
|
'v' => 0, |
44
|
|
|
|
|
|
|
}; |
45
|
0
|
0
|
0
|
|
|
|
if (! getopts('d:f:hi:s:v', $self->{'_opts'}) || @ARGV < 1 |
|
|
|
0
|
|
|
|
|
46
|
|
|
|
|
|
|
|| $self->{'_opts'}->{'h'}) { |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
print STDERR "Usage: $0 [-d duration] [-f fps] [-h]\n\t". |
49
|
|
|
|
|
|
|
"[-i input_dir] [-s size] [-v] [--version] ". |
50
|
|
|
|
|
|
|
"output_file\n\n"; |
51
|
0
|
|
|
|
|
|
print STDERR "\t-d duration\tDuration in numeric value or ". |
52
|
|
|
|
|
|
|
"with ms/s/min/h suffix\n\t\t\t(default value is ". |
53
|
|
|
|
|
|
|
"10000 [=10s]).\n"; |
54
|
0
|
|
|
|
|
|
print STDERR "\t-f fps\t\tFrame rate\n"; |
55
|
0
|
|
|
|
|
|
print STDERR "\t-h\t\tPrint help.\n"; |
56
|
0
|
|
|
|
|
|
print STDERR "\t-i input_dir\tInput directory with ". |
57
|
|
|
|
|
|
|
"images (default value is nothing).\n"; |
58
|
0
|
|
|
|
|
|
print STDERR "\t-s size\t\tSize (default value is ". |
59
|
|
|
|
|
|
|
"1920x1080).\n"; |
60
|
0
|
|
|
|
|
|
print STDERR "\t-v\t\tVerbose mode.\n"; |
61
|
0
|
|
|
|
|
|
print STDERR "\t--version\tPrint version.\n"; |
62
|
0
|
|
|
|
|
|
exit 1; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
$self->{'_output_file'} = $ARGV[0]; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Check size. |
67
|
0
|
0
|
|
|
|
|
if ($self->{'_opts'}->{'s'} !~ m/^(\d+)x(\d+)$/ms) { |
68
|
0
|
|
|
|
|
|
err 'Bad size value.', 'Value', $self->{'_opts'}->{'s'}; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
$self->{'_width'} = $1; |
71
|
0
|
|
|
|
|
|
$self->{'_height'} = $2; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Run. |
74
|
0
|
|
|
|
|
|
eval { |
75
|
|
|
|
|
|
|
# Images from directory. |
76
|
0
|
|
|
|
|
|
my $image_generator; |
77
|
0
|
0
|
|
|
|
|
if ($self->{'_opts'}->{'i'} ne $EMPTY_STR) { |
78
|
|
|
|
|
|
|
$image_generator = Image::Select->new( |
79
|
|
|
|
|
|
|
'debug' => ($self->{'_opts'}->{'v'} ? 1 : 0), |
80
|
|
|
|
|
|
|
'height' => $self->{'_height'}, |
81
|
|
|
|
|
|
|
'path_to_images' => $self->{'_opts'}->{'i'}, |
82
|
0
|
0
|
|
|
|
|
'width' => $self->{'_width'}, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $vg = Video::Generator->new( |
87
|
|
|
|
|
|
|
'duration' => $self->{'_opts'}->{'d'}, |
88
|
|
|
|
|
|
|
'fps' => $self->{'_opts'}->{'f'}, |
89
|
|
|
|
|
|
|
'height' => $self->{'_height'}, |
90
|
|
|
|
|
|
|
'image_generator' => $image_generator, |
91
|
|
|
|
|
|
|
'verbose' => $self->{'_opts'}->{'v'}, |
92
|
0
|
|
|
|
|
|
'width' => $self->{'_width'}, |
93
|
|
|
|
|
|
|
); |
94
|
0
|
|
|
|
|
|
$vg->create($self->{'_output_file'}); |
95
|
|
|
|
|
|
|
}; |
96
|
0
|
0
|
|
|
|
|
if ($EVAL_ERROR) { |
97
|
0
|
|
|
|
|
|
err 'Cannot create video.'; |
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
|
|
|
return 0; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |