forked from samyk/samytools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconv
executable file
·63 lines (50 loc) · 2.06 KB
/
conv
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
#!/usr/bin/perl
die "usage: $0 <from> <to>\nconverts any file format to another\n" unless @ARGV;
my ($a, $b) = @ARGV;
my ($type1, $type2);
$type1 = lc($1) if $a =~ /(\w+)$/;
$type2 = lc($1) if $b =~ /(\w+)$/;
if (@ARGV == 1)
{
$b = $a;
$b =~ s/\w+$/mp3/;
$type2 = "mp3";
}
my $FFMPEG = "/opt/local/bin/ffmpeg";
my %types = (
"mov-aiff" => [$FFMPEG, "-i", $a, "-f", "aiff", "-ab", "320000", "-vn", $b],
"mov-aif" => [$FFMPEG, "-i", $a, "-f", "aiff", "-ab", "320000", "-vn", $b],
"mp4-aiff" => [$FFMPEG, "-i", $a, "-f", "aiff", "-ab", "320000", "-vn", $b],
"mp4-aif" => [$FFMPEG, "-i", $a, "-f", "aiff", "-ab", "320000", "-vn", $b],
"flv-aiff" => [$FFMPEG, "-i", $a, "-f", "aiff", "-ab", "320000", "-vn", $b],
"flv-aif" => [$FFMPEG, "-i", $a, "-f", "aiff", "-ab", "320000", "-vn", $b],
"mp4-wav" => [$FFMPEG, "-i", $a, "-f", "wav", "-ab", "320000", "-vn", $b],
"mov-wav" => [$FFMPEG, "-i", $a, "-f", "wav", "-ab", "320000", "-vn", $b],
"flv-wav" => [$FFMPEG, "-i", $a, "-f", "wav", "-ab", "320000", "-vn", $b],
"mp4-mp3" => [$FFMPEG, "-i", $a, "-f", "mp3", "-ab", "320000", "-vn", $b],
"mov-mp3" => [$FFMPEG, "-i", $a, "-f", "mp3", "-ab", "320000", "-vn", $b],
"flv-mp3" => [$FFMPEG, "-i", $a, "-f", "mp3", "-ab", "320000", "-vn", $b],
"aif-mp3" => ["sox", "-V3", $a, "-C", "320", $b],
"aiff-mp3" => ["sox", "-V3", $a, "-C", "320", $b],
"flac-mp3" => ["sox", "-V3", $a, "-C", "320", $b],
#"m4a" => ["faad -o - 04\ Kiss\ Kiss\ Bang\ Bang.m4a | lame - "
#"mp4-mov" => [$FFMPEG, "-i", $a, $b],
"mov" => [$FFMPEG, "-i", $a, $b],
"mp3" => ["sox", "-V3", $a, "-C", "320", $b],
"wav" => ["sox", "-V3", $a, "-C", "320", $b],
"jpg" => ["convert", "-verbose", $a, $b],
"png" => ["convert", "-verbose", $a, $b],
"gif" => ["convert", "-verbose", $a, $b],
"bmp" => ["convert", "-verbose", $a, $b],
);
my $out = $types{"$type1-$type2"} || $types{$type2};
if ($type1 eq $type2)
{
die "Can't convert to the same type ($type1)\n";
}
if (!$out)
{
die "Don't understand type $type1 or $type2\n";
}
print "> " . join(" ", @{$out}) . "\n";
system(@{$out});