-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFfmpegHelper.pm
92 lines (59 loc) · 2.07 KB
/
FfmpegHelper.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package Plugins::C3PO::FfmpegHelper;
use strict;
sub split_{
my $transcodeTable =shift;
my $isRuntime = Plugins::C3PO::Transcoder::isRuntime($transcodeTable);
my $inCodec = $transcodeTable->{'transitCodec'};
my $start = $transcodeTable->{'options'}->{'startSec'};
my $end = $transcodeTable->{'options'}->{'durationSec'};
my $file = $transcodeTable->{'options'}->{'file'};
my $exe = $transcodeTable->{'pathToFFmpeg'};
Plugins::C3PO::Logger::verboseMessage('Start ffmpeg split_');
$inCodec=_translateCodec($inCodec);
if ($isRuntime){
my $commandString= qq("$exe" -vn -v 0 );
#print $commandString."\n";
if (defined $start){
$commandString = $commandString.'-ss '.$start.' ';
}
if (defined $end){
$commandString = $commandString.'-t '.$end.' ';
}
if ((!defined $file) || ($file eq "")|| ($file eq "-")) {
$commandString=$commandString.qq(-i - -f $inCodec -);
} else{
$commandString= qq($commandString -i "$file" -f $inCodec -);
}
return $commandString;
} else{
return '[ffmpeg] -vn -v 0 $START$ $END$ -i $FILE$ -f '.$inCodec.' -';
}
}
sub transcode {
my $transcodeTable =shift;
my $isRuntime = Plugins::C3PO::Transcoder::isRuntime($transcodeTable);
my $outCodec = Plugins::C3PO::Transcoder::getOutputCodec($transcodeTable);
my $command = $transcodeTable->{'command'};
my $exe = $transcodeTable->{'pathToFFmpeg'};
my $file = $transcodeTable->{'options'}->{'file'};
Plugins::C3PO::Logger::verboseMessage('Start ffmpeg transcode');
$outCodec=_translateCodec($outCodec);
my $commandString="";
if ((!defined $command) || ($command eq "")){
$commandString= qq(-vn -v 0 -i "$file" -f $outCodec -);
} else{
$commandString= qq(-vn -v 0 -i - -f $outCodec -);
}
if ($isRuntime){
$commandString = qq("$exe" $commandString);
} else{
$commandString = '[ffmpeg] '.$commandString;
}
return $commandString;
}
sub _translateCodec{
my $codec= shift;
if ($codec eq 'aif') {return 'aiff';}
return $codec;
}
1;