annotate TOOLS/wma2ogg.pl @ 18314:39f1bc23b65e

Fix amr_nb-fixed compilation: Don't depend on amr_nb.
author diego
date Thu, 27 Apr 2006 13:12:51 +0000
parents 03d3ab9f6400
children 32725ca88fed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12482
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
1 #!/usr/bin/perl
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
2
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
3 #################################
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
4 # wma converter 0.3.6 for Linux #
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
5 #################################
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
6
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
7 # Made by Peter Simon <simon.peter@linuxuser.hu>
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
8 # License: GNU GPL
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
9 #
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
10 # Needed programs:
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
11 #
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
12 # Getopt::Long - Perl Module
12860
03d3ab9f6400 embarassing typo
diego
parents: 12482
diff changeset
13 # MPlayer - http://www.mplayerhq.hu
12482
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
14 # BladeEnc - http://bladeenc.mp3.no
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
15 # oggenc - http://www.vorbis.com
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
16 # mp3info - http://www.ibiblio.org/mp3info
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
17
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
18 # changelog:
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
19 # 0.1.0
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
20 # decoding all files to wav without any switches and encoders
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
21 # 0.2.0
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
22 # converting to mp3 or ogg with bitrate, delete options
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
23 # 0.2.1
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
24 # L.A.M.E. support for fanatics
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
25 # Default output filetype: ogg
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
26 # Some error warnings
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
27 # 0.3.0
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
28 # Reading the wma tags out and puting into the mp3 or the ogg tags. (What the MPlayer shows of those.)
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
29 # Default output bitrate: the original bitrate
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
30 # Simlink for the default encode mode (wma2ogg = ogg, wma2mp3 = mp3)
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
31 # 0.3.1
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
32 # Neglecting missing encoders if those are not in use.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
33 # 0.3.2
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
34 # Using mp3info for the mp3 tags
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
35 # 0.3.3
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
36 # Convert more then one files in the start dir.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
37 # 0.3.4-5
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
38 # Some bugfixes.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
39 # 0.3.6
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
40 # Some bugfixes by Diego Biurrun
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
41
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
42 # Why BladeEnc?
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
43 # Eg.: The L.A.M.E.'s code isn't compatible for some hardwer-decoders. Makes noise and clashings.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
44 # I never met this trouble using BladeEnc.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
45 # That's it.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
46
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
47 use Getopt::Long qw(:config pass_through);
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
48
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
49 $ver="0.3.6";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
50
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
51 GetOptions("help|?",\&showhelp, 'a' => \$all, "file|f=s" => \@files,"t=s" => \$mtype, "lame" => \$needlame, "del" => \$delete, "br=i" => \$sbrate);
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
52
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
53 if (@ARGV) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
54 foreach (@ARGV) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
55 error ("Missing parameter after the $_ switch!");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
56 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
57 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
58 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
59
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
60 print "wma2ogg $ver\nPeter Simon <simon.peter\@linuxuser.hu>";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
61
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
62 if (!$all && !@files) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
63 error ("There is no selected file!");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
64 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
65 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
66
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
67 if ($0 =~/wma2mp3/ && !$mtype) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
68 $mtype="mp3";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
69 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
70
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
71 if ($mtype eq "ogg") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
72 $ttype{"ogg"}="oggenc";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
73 needed_prgs (oggenc, "http://www.vorbis.com");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
74 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
75
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
76 if ($needlame && $mtype eq "ogg") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
77 error ("\nYou can not use L.A.M.E. & oggenc together!\n");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
78 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
79 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
80
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
81 if (!$mtype && !$needlame) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
82 $mtype="ogg";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
83 $ttype{"ogg"}="oggenc";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
84 needed_prgs (oggenc, "http://www.vorbis.com");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
85 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
86
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
87
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
88 if (!$needlame && $mtype eq "mp3") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
89 $ttype{"mp3"}="BladeEnc";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
90 needed_prgs (BladeEnc, "http://bladeenc.mp3.no", mp3info, "http://www.ibiblio.org/mp3info");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
91 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
92
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
93 if ($needlame) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
94 $mtype="mp3";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
95 $ttype{"mp3"}="lame";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
96 needed_prgs (lame, "http://lame.sourceforge.net", mp3info, "http://www.ibiblio.org/mp3info");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
97 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
98
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
99 # Main program
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
100 print "\nUsing lame - WARNING - this is not optimal!\n";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
101 ch_needed ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
102 ch_type ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
103 ch_files ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
104 decode();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
105 # the end.
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
106
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
107
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
108 sub ch_type {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
109 $o_type=$ttype{$mtype};
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
110
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
111 if ($mtype ne "wav") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
112 $def_path=$ENV{PATH};
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
113 @exec_path=split /\:/, $def_path;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
114 foreach $temp_path (@exec_path) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
115 if (-d $temp_path && !$enc_ok) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
116 $enc_ok=`find $temp_path -name $o_type -type f -maxdepth 1 2>/dev/null`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
117 chomp ($enc_ok);
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
118 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
119 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
120 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
121 if ((!$o_type || !$enc_ok) && $mtype ne "wav") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
122 error("Unknown encoder.");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
123 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
124 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
125 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
126
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
127 sub ch_br {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
128 if ($sbrate && ((($sbrate <32 || $sbrate>350) && $mtype eq "mp3") || (($sbrate<64 || $sbrate>500) && $mtype eq "ogg") )) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
129 error("Invalid, missing or redundant bitrate.");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
130 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
131 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
132 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
133
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
134 sub ch_files {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
135 if ($all && @files) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
136 error ("You can't use -a switch and -f together!");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
137 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
138 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
139
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
140 if ($all) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
141 @enc_files=`ls | grep '.wma'\$`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
142 foreach (@enc_files) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
143 chomp $_;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
144 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
145 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
146
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
147 if (@files) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
148 @enc_files=@files;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
149 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
150
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
151 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
152
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
153 sub showhelp {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
154 print "\n\nUsage: wma2ogg [OPTIONS] (-f FILE1 | -f FILE2 ... | -a)\n
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
155 -f, -file filename
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
156 -a converts all wma files in the current directory\n
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
157 OPTIONS:
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
158 -t output filetype (ogg, mp3) [default=ogg]
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
159 -lame I wanna use L.A.M.E. sure enough!
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
160 -br bitrate (kb/s) [default=from the wma]
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
161 -del remove wma file(s) after the transcoding\n";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
162 print $miss_text;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
163 print "\n$errtext\nExiting program.\n";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
164 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
165
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
166 sub error {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
167 $errtext=@_[0];
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
168 showhelp ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
169
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
170 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
171
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
172 sub missing_prg {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
173 $what=$keys;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
174 $that=$needed{$keys};
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
175 $miss_text.="\nThe needed \'$what\' program is missing, see: $that!";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
176 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
177
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
178 sub ch_needed {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
179
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
180 `perl -e 'use Getopt::Long;' 2>./err`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
181 open (FILE, "<./err");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
182 while ($sor=<FILE>) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
183 if ($sor =~ /Can\'t locate/) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
184 missing_prg ("Getopt::Long", ": your Perl is too old... (uhhh... get a new one!)");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
185 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
186 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
187 `rm ./err`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
188
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
189
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
190 foreach $keys (keys %needed) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
191 `$keys 2>./err`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
192 open (FILE, "<./err");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
193 while ($sor=<FILE>) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
194 if ($sor =~ /$keys\: command not found/) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
195 missing_prg ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
196 $error=1;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
197 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
198 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
199 `rm ./err`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
200 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
201
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
202 close FILE;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
203 if ($error) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
204 showhelp ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
205 exit;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
206 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
207 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
208
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
209 sub get_tags {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
210 my $outfile;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
211 open (FILE, "<./1");
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
212 while ($sor=<FILE>) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
213 $outfile.=$sor;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
214 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
215 close FILE;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
216
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
217 $outfile=~ s/\((\d+\,\d+)\ kbit\)/$1/e;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
218 print "\noriginal bitrate: $1";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
219 $kept_orig_brate=$1;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
220 $kept_orig_brate=~ s/(\d+)/$1/e;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
221 $kept_orig_brate=$1;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
222
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
223 if (!$sbrate) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
224 $brate=$kept_orig_brate;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
225 print " (kept as default)";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
226 } else {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
227 $brate=$sbrate;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
228 print " (new: $brate,0)";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
229 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
230
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
231 ch_br ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
232
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
233 `rm ./1`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
234 my @temp_info=split /Clip\ info\:/, $outfile;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
235 my @temp2_info=split /\n/, @temp_info[1];
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
236 my @temp_title=split /\ /, $temp2_info[1],3;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
237 my @temp_author=split /\ /, $temp2_info[2],3;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
238 my @temp_copyright=split /\ /, $temp2_info[3],3;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
239 my @temp_comments=split /\ /, $temp2_info[4],3;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
240 return ($temp_title[2], $temp_author[2], $temp_copyright[2], $temp2_comments[2]);
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
241 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
242
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
243 sub needed_prgs {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
244 %needed=(
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
245 $_[0]=>$_[1],
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
246 $_[2]=>$_[3],
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
247 mplayer=>"http://www.mplayerhq.hu",
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
248 );
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
249 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
250
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
251 sub mp3_info {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
252 if ($title) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
253 $infofile=" -t '$title'";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
254 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
255 if ($author) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
256 $infofile.=" -a '$author'";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
257 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
258 if ($comments) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
259 $infofile.=" -c '$comments'";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
260 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
261
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
262 `mp3info "$p_name.$mtype" $infofile`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
263
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
264 undef ($infofile);
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
265 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
266
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
267
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
268 sub decode {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
269 foreach (@enc_files) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
270 $wav_name=$_;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
271 $wav_name=~ s/(.+)\./$1/e;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
272 $p_name=$1;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
273 $wav_name=$p_name.".wav";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
274 $pwd=`pwd`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
275 chomp $pwd;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
276 $pwd.="/t2";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
277 print "\nConverting $_ to \"wav\" file.\n";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
278 print "Using MPlayer...\n";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
279
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
280 `mplayer "$_" -ao pcm -input conf="$pwd" 2>/dev/null >./1`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
281 `mv "audiodump.wav" "$wav_name"`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
282
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
283 @tags=get_tags ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
284
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
285 $title=$tags[0];
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
286 print "\ntitle: $title";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
287 $author=$tags[1];
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
288 print "\nauthor: $author";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
289 $copyright=$tags[2];
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
290 print "\ncopyright: $copyright";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
291 $comments=$tags[3];
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
292 print "\ncomments: $comments";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
293
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
294 $comments=$copyright." ".$comments."Transcoded by wma2ogg";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
295
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
296 print "\n\nConverting $wav_name to \"$mtype\" file.";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
297
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
298 print "\nUsing $o_type...";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
299
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
300 if ($mtype eq "ogg") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
301 $br_sw="b";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
302 if ($title) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
303 $infofile=" -t '$title'";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
304 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
305 if ($author) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
306 $infofile.=" -a '$author'";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
307 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
308 if ($comments) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
309 $infofile.=" -c COMMENT='$comments'";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
310 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
311
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
312 `"$o_type" "-$br_sw" "$brate" "-Q" "./$wav_name" $infofile "-o" "$p_name.$mtype"`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
313 `rm -f "$wav_name"`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
314 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
315 if ($mtype eq "mp3" && !$needlame) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
316 $br_sw="br";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
317 `"$o_type" "$wav_name" "$p_name.$mtype" "-$br_sw" "$brate" 2>/dev/null >/dev/null`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
318
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
319 mp3_info ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
320
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
321 `rm -f "$wav_name"`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
322 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
323 if ($mtype eq "mp3" && $needlame) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
324
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
325 $br_sw="b";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
326 `"$o_type" "-$br_sw" "$brate" "-f" "$wav_name" "$p_name.$mtype" 2>/dev/null >/dev/null`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
327
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
328 mp3_info ();
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
329
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
330 `rm -f "$wav_name"`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
331 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
332 if ($delete) {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
333 `rm -f "$_"`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
334 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
335 if (-e "./err") {
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
336 `rm ./err`;
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
337 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
338 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
339 print "\n\nDone.\n\n";
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
340 }
ad68ea76bc05 WMA to Ogg conversion script by Peter Simon <simon.peter@linuxuser.hu>,
diego
parents:
diff changeset
341