annotate TOOLS/dvd2divxscript.pl @ 24058:345b18b889c9

allow setting of ar from the commandline of configure
author mhoffman
date Thu, 16 Aug 2007 12:41:01 +0000
parents 401b440a6d76
children 277494cffeac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
1 #!/usr/bin/perl
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
2
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
3 #
12643
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
4 # (c) 2002-2004 by Florian Schilhabel <florian.schilhabel@web.de>
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
5 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
6 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
7 # version 0.1 initial release 22/08/2002
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
8 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
9 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
10 # If you have any comments, suggestions, etc., feel free to send me a mail ;-))
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
11 # flames and other things like that should go to /dev/null
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
12 # thankx to all the mplayer developers for this really *great* piece of software
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
13 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
14 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
15 # This script is free software; you can redistribute it and/or
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
16 # modify it under the terms of the GNU Lesser General Public
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
17 # License as published by the Free Software Foundation; either
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
18 # version 2 of the License, or (at your option) any later version.
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
19 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
20 # This script is distributed in the hope that it will be useful,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
23 # Lesser General Public License for more details.
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
24 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
25 # You should have received a copy of the GNU Lesser General Public
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
26 # License along with this library; if not, write to the Free Software
17367
401b440a6d76 Update licensing information: The FSF changed postal address.
diego
parents: 12643
diff changeset
27 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
28 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
29 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
30 #
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
31 use Getopt::Long;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
32
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
33 # specify your default Settings here...
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
34
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
35 $abr_default = 128; # The default AudioBitRate
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
36 $lang_default = "de"; # ... the language
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
37 $cdsize_default = 700; # ... the CD-Rom Size
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
38 $writedev_default = "0,1,0"; # ... the CD Writer Device
12643
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
39 $speed_default = 4; # ... the writer speed
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
40 $dvd_device = "/dev/dvd"; # and the DVD Rom Device
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
41
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
42 # end of default Settings
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
43
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
44
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
45
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
46 sub delete_tempfiles {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
47 if (open(FILE, "< audio.stderr")) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
48 close (FILE);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
49 system ("rm audio.stderr")
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
50 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
51 if (open(FILE, "< frameno.avi")) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
52 close (FILE);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
53 system ("rm frameno.avi");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
54 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
55 if (open(FILE, "< lavc_stats.txt")) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
56 close (FILE);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
57 system ("rm lavc_stats.txt");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
58 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
59 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
60
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
61 GetOptions( "help" => \$help,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
62 "abr=i" => \$abr,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
63 "lang=s" =>\$lang,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
64 "cdsize=i" => \$cdsize,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
65 "dvd=i" => \$dvd_track,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
66 "keeptemp" => \$keeptemp,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
67 "shutdown" => \$shutdown,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
68 "out=s" => \$output,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
69 "writecd" => \$writecd,
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
70 "writedev=s" => \$writedev,
12643
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
71 "speed=i" => \$speed,
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
72 "dvd-device=s" => \$dvd_device );
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
73
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
74 if ($help) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
75 print "Welcome to the DVD to DIVX Helper Script\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
76 print "\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
77 print "this script encodes a DVD track in 3-pass mode to libavcodec's mpeg4\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
78 print "Optionally it writes the resulting MovieFile to a CD-Rom\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
79 print "as well as the corresponding audio track to mp3\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
80 print "Optionally it writes the resulting MovieFile to a CD-Rom\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
81 print "and shuts down the Computer.\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
82 print "If you like, you can watch the mencoder output on /dev/tty8\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
83 print "Usage:\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
84 print "--help show this text\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
85 print "--abr (AudioBitRate) Please enter the desired bitrate\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
86 print " this can be either [96|128|192] kbit/sec.\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
87 print " Default: 128 kbit/sec.\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
88 print "--lang specify the Language of the audio track\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
89 print " this can be for example <en> or <de>\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
90 print " Default: <de>\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
91 print "--dvd specify the DVD Track, you want to encode\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
92 print "--cdsize specify the Size of your CD-ROM\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
93 print " Default: 700MB\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
94 print "--shutdown Shutdown the System, when the encoding process has finished\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
95 print " this will only be possible if you are root\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
96 print "--out Specify the Name of your encoded Movie\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
97 print " The File Extension will be appended automatically\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
98 print "--writecd takes the newly created Movie and writes it to a CD-Rom\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
99 print "--writedev is the usual cdrecord device identifier\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
100 print " for example 0,1,0\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
101 print "--speed the writing speed\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
102 print " Default: 4\n";
12643
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
103 print "--dvd-device device to pull the video off\n";
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
104 print " Default: /dev/dvd\n";
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
105 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
106 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
107
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
108 delete_tempfiles();
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
109
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
110 # testing user values && set defaults...
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
111
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
112 if ($abr == 96){}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
113 elsif ($abr == 128) {}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
114 elsif ($abr == 192) {}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
115 elsif ($abr == 0 ) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
116 print "No AudioBitRate specified - Setting to Default Value\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
117 $abr = $abr_default;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
118 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
119 else {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
120 print "AudioBitRate not valid. please choose [96|128|192]\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
121 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
122 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
123
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
124 if ($lang eq "") {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
125 print "No Language specified - Setting to Default Value\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
126 $lang = $lang_default;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
127 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
128 else {}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
129
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
130 if ($dvd_track == 0 ) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
131 print "No DVD Track selected - You must specify one with: --dvd trackno.\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
132 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
133 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
134
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
135 if ($cdsize == 650) {}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
136 elsif ($cdsize == 700) {}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
137 elsif ($cdsize == 800) {}
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
138 elsif ($cdsize == 0 ) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
139 print "No CD Size Specified - Setting to Default Value\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
140 $cdsize = $cdsize_default;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
141 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
142
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
143 else {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
144 print "CD Size not valid. please choose [650|700|800]\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
145 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
146 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
147
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
148 if ($output eq "") {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
149 print "No MovieName given - You must specify one with: --out [movie_name]\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
150 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
151 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
152 else {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
153 ($name, $extension) = split(/./, $out);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
154 if ($extension eq "avi") {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
155 $vob_tempfile = "$name.vob";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
156 $avi_filename = "$output";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
157 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
158 else {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
159 $vob_tempfile = "$output.vob";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
160 print "VOB CacheFile set to $vob_tempfile\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
161 $avi_filename = "$output.avi";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
162 print "Movie Filename set to $avi_filename\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
163 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
164 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
165
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
166 if ($shutdown) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
167 # test who i am
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
168 $user = `id -u`;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
169 if ($user == 0) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
170 print "System will be shut down after Movie encoding\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
171 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
172 else {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
173 print "Cannot shutdown the system after Movie encoding - you are not 'root'\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
174 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
175 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
176 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
177
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
178 if ($writecd) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
179 if ($writedev == "") {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
180 print "Setting CD Writer Device to Default Value\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
181 $writedev = $writedev_default;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
182 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
183 if ($speed == 0) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
184 print "Setting CD Writer Speed to Default value\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
185 $speed = $speed_default;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
186 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
187
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
188 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
189
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
190
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
191
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
192 ###
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
193
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
194 print "Your Settings for this run are:\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
195 print "AudioBitRate: $abr\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
196 print "Language: $lang\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
197 print "DVD-Track: $dvd_track\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
198 print "CD-Rom Size: $cdsize\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
199 print "Movie FIlename: $avi_filename\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
200 if ($writecd) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
201 print "CD Writer Dev.: $writedev\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
202 print "Writer Speed: $speed\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
203 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
204
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
205 # here comes the fun part...
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
206
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
207 print "precacheing...\n";
12643
f32e4c04aecd dvd-device option by Anton Tropashko <atropashko@yahoo.com>
alex
parents: 10405
diff changeset
208 $status = system ("mencoder dvd://$dvd_track -ovc copy -oac copy -dvd-device $dvd_device -alang $lang -o $vob_tempfile 1>/dev/tty8 2>/dev/tty8");
7116
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
209 die "Prechacheing failed. mencoder exited with Status Code $?" unless $status == 0;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
210
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
211 print "Encoding Audio...\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
212 $status = system ("mencoder $vob_tempfile -ovc frameno -oac mp3lame -lameopts br=$abr:cbr:vol=3 -o frameno.avi 1>./audio.stderr 2>/dev/tty8");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
213 die "Encoding Audio failed. mencoder exited with Status Code $?" unless $status == 0;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
214
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
215 # now we have to find out the recommended bitrate for the Video encoding process...
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
216 # my current method to find this out is, hmm, well, *strange*
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
217 # but anyway, it works ;-))
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
218
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
219 open(FILE, "< audio.stderr") or die "Unable to open audio.stderr.";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
220 @lines = <FILE>;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
221 foreach $line (@lines) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
222 ($index, $zz) = split(" ", $line);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
223 if ($index eq "Recommended") {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
224 ($a, $b, $c, $d, $size, $f, $bitrate) = split(" ", $line);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
225 if ($cdsize == $size) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
226 $video_bitrate = $bitrate;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
227 print "Setting Videobitrate to $video_bitrate\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
228 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
229 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
230 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
231 close (FILE);
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
232
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
233 print "Encoding Video Stream, 1st pass...\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
234 $status = system ("mencoder $vob_tempfile -ovc lavc -lavcopts vpass=1:vcodec=mpeg4:vbitrate=$video_bitrate:vhq -oac copy -o $avi_filename 1>/dev/tty8 2>/dev/tty8");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
235 die "Encoding Video Stream failed. mencoder exited with Status Code $?" unless $status == 0;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
236
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
237 print "Encoding Video Stream, 2nd pass...\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
238 $status = system ("mencoder $vob_tempfile -ovc lavc -lavcopts vpass=2:vcodec=mpeg4:vbitrate=$video_bitrate:vhq -oac copy -o $avi_filename 1>/dev/tty8 2>/dev/tty8");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
239 die "Encoding Video Stream failed. mencoder exited with Status Code $?" unless $status == 0;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
240
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
241 print "finished encoding\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
242
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
243
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
244 if ($writecd) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
245 print "Now writing CD-Rom\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
246 $status = system("mkisofs -r -J $avi_filename | cdrecord speed=$speed dev=$writedev -data - 2>/dev/tty8 1>/dev/tty8");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
247 die "Writing CD failed. cdrecord exited with Status Code $?" unless $status == 0;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
248 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
249 delete_tempfiles();
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
250
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
251 print "Finished - have a nice day ;-)\n";
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
252 if ($shutdown) {
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
253 system("halt");
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
254 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
255 }
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
256 exit;
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
257
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
258
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
259
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
260
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
261
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
262
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
263
e751a2b0991d written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff changeset
264