Mercurial > mplayer.hg
annotate TOOLS/dvd2divxscript.pl @ 11876:f531170db832
10l
author | henry |
---|---|
date | Thu, 29 Jan 2004 12:05:24 +0000 |
parents | a5785a0b9ee1 |
children | f32e4c04aecd |
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 # |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
4 # (c) 2002 by Florian Schilhabel <florian.schilhabel@web.de> |
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 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
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 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
39 $speed_default = 4; # and the writer speed |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
40 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
41 # end of default Settings |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
42 |
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 sub delete_tempfiles { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
46 if (open(FILE, "< audio.stderr")) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
47 close (FILE); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
48 system ("rm audio.stderr") |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
49 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
50 if (open(FILE, "< frameno.avi")) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
51 close (FILE); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
52 system ("rm frameno.avi"); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
53 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
54 if (open(FILE, "< lavc_stats.txt")) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
55 close (FILE); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
56 system ("rm lavc_stats.txt"); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
57 } |
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 GetOptions( "help" => \$help, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
61 "abr=i" => \$abr, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
62 "lang=s" =>\$lang, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
63 "cdsize=i" => \$cdsize, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
64 "dvd=i" => \$dvd_track, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
65 "keeptemp" => \$keeptemp, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
66 "shutdown" => \$shutdown, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
67 "out=s" => \$output, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
68 "writecd" => \$writecd, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
69 "writedev=s" => \$writedev, |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
70 "speed=i" => \$speed ); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
71 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
72 if ($help) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
73 print "Welcome to the DVD to DIVX Helper Script\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
74 print "\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
75 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
|
76 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
|
77 print "as well as the corresponding audio track to mp3\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 "and shuts down the Computer.\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
80 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
|
81 print "Usage:\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
82 print "--help show this text\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
83 print "--abr (AudioBitRate) Please enter the desired bitrate\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
84 print " this can be either [96|128|192] kbit/sec.\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
85 print " Default: 128 kbit/sec.\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
86 print "--lang specify the Language of the audio track\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
87 print " this can be for example <en> or <de>\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
88 print " Default: <de>\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
89 print "--dvd specify the DVD Track, you want to encode\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
90 print "--cdsize specify the Size of your CD-ROM\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
91 print " Default: 700MB\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
92 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
|
93 print " this will only be possible if you are root\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
94 print "--out Specify the Name of your encoded Movie\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
95 print " The File Extension will be appended automatically\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
96 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
|
97 print "--writedev is the usual cdrecord device identifier\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
98 print " for example 0,1,0\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
99 print "--speed the writing speed\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
100 print " Default: 4\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
101 exit; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
102 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
103 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
104 delete_tempfiles(); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
105 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
106 # testing user values && set defaults... |
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 if ($abr == 96){} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
109 elsif ($abr == 128) {} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
110 elsif ($abr == 192) {} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
111 elsif ($abr == 0 ) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
112 print "No AudioBitRate specified - Setting to Default Value\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
113 $abr = $abr_default; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
114 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
115 else { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
116 print "AudioBitRate not valid. please choose [96|128|192]\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
117 exit; |
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 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
120 if ($lang eq "") { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
121 print "No Language specified - Setting to Default Value\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
122 $lang = $lang_default; |
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 else {} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
125 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
126 if ($dvd_track == 0 ) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
127 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
|
128 exit; |
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 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
131 if ($cdsize == 650) {} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
132 elsif ($cdsize == 700) {} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
133 elsif ($cdsize == 800) {} |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
134 elsif ($cdsize == 0 ) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
135 print "No CD Size Specified - Setting to Default Value\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
136 $cdsize = $cdsize_default; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
137 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
138 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
139 else { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
140 print "CD Size not valid. please choose [650|700|800]\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
141 exit; |
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 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
144 if ($output eq "") { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
145 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
|
146 exit; |
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 else { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
149 ($name, $extension) = split(/./, $out); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
150 if ($extension eq "avi") { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
151 $vob_tempfile = "$name.vob"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
152 $avi_filename = "$output"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
153 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
154 else { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
155 $vob_tempfile = "$output.vob"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
156 print "VOB CacheFile set to $vob_tempfile\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
157 $avi_filename = "$output.avi"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
158 print "Movie Filename set to $avi_filename\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
159 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
160 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
161 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
162 if ($shutdown) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
163 # test who i am |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
164 $user = `id -u`; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
165 if ($user == 0) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
166 print "System will be shut down after Movie encoding\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
167 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
168 else { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
169 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
|
170 exit; |
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 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
173 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
174 if ($writecd) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
175 if ($writedev == "") { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
176 print "Setting CD Writer Device to Default Value\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
177 $writedev = $writedev_default; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
178 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
179 if ($speed == 0) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
180 print "Setting CD Writer Speed to Default value\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
181 $speed = $speed_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 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
184 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
185 |
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 print "Your Settings for this run are:\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
191 print "AudioBitRate: $abr\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
192 print "Language: $lang\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
193 print "DVD-Track: $dvd_track\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
194 print "CD-Rom Size: $cdsize\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
195 print "Movie FIlename: $avi_filename\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
196 if ($writecd) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
197 print "CD Writer Dev.: $writedev\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
198 print "Writer Speed: $speed\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
199 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
200 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
201 # here comes the fun part... |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
202 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
203 print "precacheing...\n"; |
10405 | 204 $status = system ("mencoder dvd://$dvd_track -ovc copy -oac copy -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
|
205 die "Prechacheing failed. mencoder exited with Status Code $?" unless $status == 0; |
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 "Encoding Audio...\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
208 $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
|
209 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
|
210 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
211 # 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
|
212 # my current method to find this out is, hmm, well, *strange* |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
213 # but anyway, it works ;-)) |
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 open(FILE, "< audio.stderr") or die "Unable to open audio.stderr."; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
216 @lines = <FILE>; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
217 foreach $line (@lines) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
218 ($index, $zz) = split(" ", $line); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
219 if ($index eq "Recommended") { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
220 ($a, $b, $c, $d, $size, $f, $bitrate) = split(" ", $line); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
221 if ($cdsize == $size) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
222 $video_bitrate = $bitrate; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
223 print "Setting Videobitrate to $video_bitrate\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
224 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
225 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
226 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
227 close (FILE); |
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 print "Encoding Video Stream, 1st pass...\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
230 $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
|
231 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
|
232 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
233 print "Encoding Video Stream, 2nd 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=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
|
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 "finished encoding\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
238 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
239 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
240 if ($writecd) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
241 print "Now writing CD-Rom\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
242 $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
|
243 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
|
244 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
245 delete_tempfiles(); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
246 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
247 print "Finished - have a nice day ;-)\n"; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
248 if ($shutdown) { |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
249 system("halt"); |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
250 exit; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
251 } |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
252 exit; |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
253 |
e751a2b0991d
written by Florian Schilhabel <florian.schilhabel@gmx.net>
alex
parents:
diff
changeset
|
254 |
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 |
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 |