line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# video::convert Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Video::Convert; |
7
|
1
|
|
|
1
|
|
524
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
416
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable avi jpg) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
datadir => [ qw(directory) ], |
20
|
|
|
|
|
|
|
output_pattern => [ qw(file_pattern) ], |
21
|
|
|
|
|
|
|
keep_only_first => [ qw(0|1) ], |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
attributes_default => { |
24
|
|
|
|
|
|
|
output_pattern => 'image_%04d.jpg', |
25
|
|
|
|
|
|
|
keep_only_first => 0, |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
commands => { |
28
|
|
|
|
|
|
|
install => [ ], # Inherited |
29
|
|
|
|
|
|
|
to_jpg => [ qw(input) ], |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
require_modules => { |
32
|
|
|
|
|
|
|
'Metabrik::File::Find' => [ ], |
33
|
|
|
|
|
|
|
'Metabrik::System::File' => [ ], |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
require_binaries => { |
36
|
|
|
|
|
|
|
'ffmpeg' => [ ], |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
need_packages => { |
39
|
|
|
|
|
|
|
ubuntu => [ qw(ffmpeg) ], |
40
|
|
|
|
|
|
|
debian => [ qw(ffmpeg) ], |
41
|
|
|
|
|
|
|
kali => [ qw(ffmpeg) ], |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub to_jpg { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($input) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
51
|
0
|
|
|
|
|
|
my $output_pattern = $self->output_pattern; |
52
|
0
|
|
|
|
|
|
my $keep_only_first = $self->keep_only_first; |
53
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('to_jpg', $input) or return; |
54
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('to_jpg', $input) or return; |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
my $ff = Metabrik::File::Find->new_from_brik_init($self) or return; |
57
|
0
|
0
|
|
|
|
|
my $sf = Metabrik::System::File->new_from_brik_init($self) or return; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# This program is only provided for compatibility and will be removed in a future release. |
60
|
|
|
|
|
|
|
# Please use avconv instead. |
61
|
0
|
|
|
|
|
|
my $cmd = "ffmpeg -i $input $datadir/".$output_pattern; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$self->execute($cmd) or return; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
(my $find = $output_pattern) =~ s/^(.*)%.*$/$1/; |
66
|
0
|
0
|
|
|
|
|
my $found = $ff->files($datadir, "$find.*") or return; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ($keep_only_first) { |
69
|
0
|
|
|
|
|
|
my $keep = shift @$found; |
70
|
0
|
|
|
|
|
|
$sf->remove($found); |
71
|
0
|
|
|
|
|
|
$found = $keep; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $found; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |