From: <te...@us...> - 2003-07-17 13:12:22
|
Update of /cvsroot/quickrip/quickrip In directory sc8-pr-cvs1:/tmp/cvs-serv370 Modified Files: cli.py dvd.py gui.py guimain.py Log Message: Cleaned up DVD ripping code, especially DVD.ripDVD() method. All QuickRip functions should now be working with the new features (ETA, new GUI, select dvd device, select bitrate) Index: cli.py =================================================================== RCS file: /cvsroot/quickrip/quickrip/cli.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** cli.py 17 Jul 2003 10:41:22 -0000 1.13 --- cli.py 17 Jul 2003 13:12:14 -0000 1.14 *************** *** 500,511 **** def int_dispDVD(self): ! #print "Found %s titles" % (self.numtitles) ! #print "Found audio languages %s" % (self.alangs) ! #print "Found subtitle languages %s" % (self.slangs) ! print """ ! Found %s titles ! Found audio languages %s ! Found subtitle languages %s ! """ % (self.numtitles, self.alangs, self.slangs) def int_dispTrack(self, track): --- 500,506 ---- def int_dispDVD(self): ! print "Found %s titles" % (self.numtitles) ! print "Found audio languages %s" % (self.alangs) ! print "Found subtitle languages %s" % (self.slangs) def int_dispTrack(self, track): *************** *** 544,548 **** self.n = 0 ! def int_updateProgress(self, perc, tpass): for opt in sys.argv: if opt in ['-a', '--autoresize']: --- 539,543 ---- self.n = 0 ! def int_updateProgress(self, perc, trem, tpass): for opt in sys.argv: if opt in ['-a', '--autoresize']: Index: dvd.py =================================================================== RCS file: /cvsroot/quickrip/quickrip/dvd.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** dvd.py 17 Jul 2003 10:41:22 -0000 1.22 --- dvd.py 17 Jul 2003 13:12:14 -0000 1.23 *************** *** 199,203 **** for i in range(int(self.numtitles) + 1): if i > 0: ! cmd_tcprobe = "".join([str(self.config['tcprobe']), " -i ", self.config['dvd_device'] + " -T ", str(i) + " 2>&1"]) text = os.popen(cmd_tcprobe).readlines() del cmd_tcprobe --- 199,203 ---- for i in range(int(self.numtitles) + 1): if i > 0: ! cmd_tcprobe = "".join([str(self.config['tcprobe']), " -i ", str(self.config['dvd_device']) + " -T ", str(i) + " 2>&1"]) text = os.popen(cmd_tcprobe).readlines() del cmd_tcprobe *************** *** 269,273 **** self.torip.append(track) self.numrips = len(self.torip) ! # Check PDA mode (universal to all ripping methods) if int(self.config['pdamode']) == 0: --- 269,273 ---- self.torip.append(track) self.numrips = len(self.torip) ! # Check PDA mode (universal to all ripping methods) if int(self.config['pdamode']) == 0: *************** *** 312,349 **** self.track['crop'] = common_crop - pipe_perc = re.compile('.*f \((.\d)\%\)*') - pipe_Trem = re.compile('(?P<int>[0-9]+)min') - perc = 0 - Trem = 0 - # Clean up output dir in case QuickRip crashed out there os.popen("".join(["rm ", self.outdir, "frameno.avi 2>/dev/null"])) ! if self.config['passes'] is 1: ! all_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, "-oac", "mp3lame", "-lameopts", "cbr=" + str(self.track['abr']) + str(self.vol), "-ovc", "lavc", "-lavcopts", "".join(["vcodec=mpeg4:vhq:vbitrate=", str(int(self.track['vbr']))]), "-vop", "".join(["scale,crop=", self.track['crop']]), "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] ! if int(self.config['deinterlacing']) is 1: ! all_pass[14] = "".join([all_pass[14], ",dint"]) ! if int(self.config['deinterlacing']) is 2: ! all_pass[14] = "".join([all_pass[14], ",il"]) ! if int(self.config['deinterlacing']) is 3: ! all_pass[14] = "".join([all_pass[14], ",lavcdeint"]) ! if int(self.config['deinterlacing']) is 4: ! all_pass[14] = "".join([all_pass[14], ",pp=lb"]) ! if int(self.config['aspectratio']) is 1: ! all_pass.insert(3, "-aspect") ! all_pass.insert(4, "4:3") ! if int(self.config['aspectratio']) is 2: ! all_pass.insert(3, "-aspect") ! all_pass.insert(4, "16:9") ! if int(self.config['aspectratio']) is 3: all_pass.insert(3, "-aspect") ! all_pass.insert(4, "2.35") if self.sLanguage is not "None": all_pass.insert(3, "-slang") all_pass.insert(4, self.sLanguage) ! # Uncomment to test command #string = "" --- 312,348 ---- self.track['crop'] = common_crop # Clean up output dir in case QuickRip crashed out there os.popen("".join(["rm ", self.outdir, "frameno.avi 2>/dev/null"])) ! lameopts = "".join(["cbr=", str(self.track['abr']), str(self.vol)]) ! ovc = "lavc" ! ovc_opts = "-lavcopts" ! lavcopts = "".join(["vcodec=mpeg4:vhq:vbitrate=", str(int(self.track['vbr']))]) ! vop = "".join(["scale,crop=",self.track['crop']]) ! if int(self.config['deinterlacing']) is not 0: ! vop = "".join([vop, ",", self.dio[self.config['deinterlacing']]]) ! if self.config['passes'] is 1: ! all_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, \ ! "-oac", "mp3lame", "-lameopts", lameopts, "-ovc", ovc, ovc_opts, lavcopts, "-vop", vop, "-zoom", \ ! "-xy", resolution, "-o", self.output, "2>/dev/null"] ! ! if int(self.config['aspectratio']) is not 0: all_pass.insert(3, "-aspect") ! all_pass.insert(4, self.aro[self.config['aspectratio']]) if self.sLanguage is not "None": all_pass.insert(3, "-slang") all_pass.insert(4, self.sLanguage) ! ! # # Uncomment to test command ! # string = "" ! # for bit in all_pass: ! # bit = "".join([" ", bit]) ! # string = "".join([string, bit]) ! # print string ! # sys.exit(1) ! # Uncomment to test command #string = "" *************** *** 354,402 **** #sys.exit(1) ! self.int_newPass("audio") ! self.pipe = popen2.Popen4(all_pass) ! pid = self.pipe.pid ! while 1: ! line = self.pipe.fromchild.read(1000) ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, "audio") ! os.waitpid(pid, os.WNOHANG) elif not self.config['passes'] or self.config['passes'] is 2: ! audio_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, "-oac", "mp3lame", "-lameopts", "".join(["cbr=", str(self.track['abr']), str(self.vol)]), "-ovc", "frameno", "-o", "".join([self.outdir, "frameno.avi"]), "2>/dev/null"] ! video_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-sws", "2", "-oac", "copy", "-ovc", "lavc", "-lavcopts", "".join(["vcodec=mpeg4:vhq:vbitrate=", str(int(self.track['vbr']))]), "-vop", "".join(["scale,crop=", self.track['crop']]), "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] ! ! if int(self.config['deinterlacing']) is 1: ! video_pass[12] = "".join([video_pass[12], ",dint"]) ! if int(self.config['deinterlacing']) is 2: ! video_pass[12] = "".join([video_pass[12], ",il"]) ! if int(self.config['deinterlacing']) is 3: ! video_pass[12] = "".join([video_pass[12], ",lavcdeint"]) ! if int(self.config['deinterlacing']) is 4: ! video_pass[12] = "".join([video_pass[12], ",pp=lb"]) ! if int(self.config['aspectratio']) is 1: ! video_pass.insert(3, "-aspect") ! video_pass.insert(4, "4:3") ! if int(self.config['aspectratio']) is 2: ! video_pass.insert(3, "-aspect") ! video_pass.insert(4, "16:9") ! if int(self.config['aspectratio']) is 3: video_pass.insert(3, "-aspect") ! video_pass.insert(4, "2.35") if self.sLanguage is not "None": - audio_pass.insert(3, "-slang") - audio_pass.insert(4, self.sLanguage) video_pass.insert(3, "-slang") video_pass.insert(4, self.sLanguage) ! ! # # Uncomment to test command # string1 = "" --- 353,375 ---- #sys.exit(1) ! self.runPass("audio", all_pass) elif not self.config['passes'] or self.config['passes'] is 2: ! audio_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, \ ! "-oac", "mp3lame", "-lameopts", lameopts, "-ovc", ovc, "frameno", "-o", \ ! "".join([self.outdir, "frameno.avi"]), "2>/dev/null"] ! video_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, \ ! "-sws", "2", "-oac", "copy", "-ovc", ovc, ovc_opts, lavcopts, "-vop", vop, "-zoom", "-xy", resolution, \ ! "-o", self.output, "2>/dev/null"] ! ! if int(self.config['aspectratio']) is not 0: video_pass.insert(3, "-aspect") ! video_pass.insert(4, self.aro[self.config['aspectratio']]) if self.sLanguage is not "None": video_pass.insert(3, "-slang") video_pass.insert(4, self.sLanguage) ! # # Uncomment to test command # string1 = "" *************** *** 412,450 **** # sys.exit(1) ! self.int_newPass("audio") ! self.pipe = popen2.Popen4(audio_pass) ! pid = self.pipe.pid ! while 1: ! line = self.pipe.fromchild.read(1000) ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, "audio") ! os.waitpid(pid, os.WNOHANG) ! ! # Nasty GUI-specific code to stop GUI running on to other passes when previous ! # pass was cleanly stopped (without exiting the whole program) ! if self.state is "stopped": ! return ! ! perc = 0 ! self.int_newPass("video1") ! self.pipe = popen2.Popen4(video_pass) ! pid = self.pipe.pid ! while 1: ! line = self.pipe.fromchild.readline() ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, "video1") ! os.waitpid(pid, os.WNOHANG) os.popen("rm divx2pass.log 2>/dev/null") --- 385,390 ---- # sys.exit(1) ! self.runPass("audio", audio_pass) ! self.runPass("video1", video_pass) os.popen("rm divx2pass.log 2>/dev/null") *************** *** 453,493 **** elif self.config['passes'] is 3: ! audio_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, "-oac", "mp3lame", "-lameopts", "cbr=" + str(self.track['abr']) + str(self.vol), "-ovc", "frameno", "-o", self.outdir + "frameno.avi", "2>/dev/null"] ! video_pass1 = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-sws", "2", "-oac", "copy", "-ovc", "lavc", "-lavcopts", "".join(["vcodec=mpeg4:vhq:vbitrate=", str(int(self.track['vbr'])), ":vpass=1"]), "-vop", "".join(["scale,crop=", self.track['crop']]), "-zoom", "-xy", resolution, "-o", "/dev/null", "2>/dev/null"] ! video_pass2 = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-sws", "2", "-oac", "copy", "-ovc", "lavc", "-lavcopts", "".join(["vcodec=mpeg4:vhq:vbitrate=", str(int(self.track['vbr'])), ":vpass=2"]), "-vop", "".join(["scale,crop=", self.track['crop']]), "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] ! if int(self.config['deinterlacing']) is 1: ! video_pass1[12] = "".join([video_pass1[12], ",dint"]) ! video_pass2[12] = "".join([video_pass2[12], ",dint"]) ! if int(self.config['deinterlacing']) is 2: ! video_pass1[12] = "".join([video_pass1[12], ",il"]) ! video_pass2[12] = "".join([video_pass2[12], ",il"]) ! if int(self.config['deinterlacing']) is 3: ! video_pass1[12] = "".join([video_pass1[12], ",lavcdeint"]) ! video_pass2[12] = "".join([video_pass2[12], ",lavcdeint"]) ! if int(self.config['deinterlacing']) is 4: ! video_pass1[12] = "".join([video_pass1[12], ",pp=lb"]) ! video_pass2[12] = "".join([video_pass2[12], ",pp=lb"]) ! if int(self.config['aspectratio']) is 1: ! video_pass1.insert(3, "-aspect") ! video_pass1.insert(4, "4:3") ! video_pass2.insert(3, "-aspect") ! video_pass2.insert(4, "4:3") ! if int(self.config['aspectratio']) is 2: ! video_pass1.insert(3, "-aspect") ! video_pass1.insert(4, "16:9") ! video_pass2.insert(3, "-aspect") ! video_pass2.insert(4, "16:9") ! if int(self.config['aspectratio']) is 3: video_pass1.insert(3, "-aspect") ! video_pass1.insert(4, "2.35") video_pass2.insert(3, "-aspect") ! video_pass2.insert(4, "2.35") if self.sLanguage is not "None": - audio_pass.insert(3, "-slang") - audio_pass.insert(4, self.sLanguage) video_pass1.insert(3, "-slang") video_pass1.insert(4, self.sLanguage) --- 393,415 ---- elif self.config['passes'] is 3: ! audio_pass = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, \ ! "-oac", "mp3lame", "-lameopts", lameopts, "-ovc", ovc, "frameno", "-o", \ ! "".join([self.outdir, "frameno.avi"]), "2>/dev/null"] ! video_pass1 = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, \ ! "-sws", "2", "-oac", "copy", "-ovc", ovc, ovc_opts, "".join([lavcopts, ":vpass=1"]), "-vop", vop, \ ! "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] + video_pass2 = [str(self.config['mencoder']), "-dvd", str(self.track['id']), "-alang", self.aLanguage, \ + "-sws", "2", "-oac", "copy", "-ovc", ovc, ovc_opts, "".join([lavcopts, ":vpass=2"]), "-vop", vop, \ + "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] ! if int(self.config['aspectratio']) is not 0: video_pass1.insert(3, "-aspect") ! video_pass1.insert(4, self.aro[self.config['aspectratio']]) video_pass2.insert(3, "-aspect") ! video_pass2.insert(4, self.aro[self.config['aspectratio']]) if self.sLanguage is not "None": video_pass1.insert(3, "-slang") video_pass1.insert(4, self.sLanguage) *************** *** 495,558 **** video_pass2.insert(4, self.sLanguage) ! # Uncomment to check the commands look valid ! #print audio_pass ! #print video_pass1 ! #self.int_finishRipping() ! ! self.int_newPass("audio") ! self.pipe = popen2.Popen4(audio_pass) ! pid = self.pipe.pid ! while 1: ! line = self.pipe.fromchild.read(1000) ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, "audio") ! os.waitpid(pid, os.WNOHANG) ! ! # Nasty GUI-specific code to stop GUI running on to other passes when previous ! # pass was cleanly stopped (without exiting the whole program) ! if self.state is "stopped": ! return ! ! perc = 0 ! self.int_newPass("video1") ! self.pipe = popen2.Popen4(video_pass1) ! pid = self.pipe.pid ! while 1: ! line = self.pipe.fromchild.readline() ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, "video1") ! os.waitpid(pid, os.WNOHANG) ! ! # Nasty GUI-specific code to stop GUI running on to other passes when previous ! # pass was cleanly stopped (without exiting the whole program) ! if self.state is "stopped": ! return ! ! perc = 0 ! self.int_newPass("video2") ! self.pipe = popen2.Popen4(video_pass2) ! while 1: ! line = self.pipe.fromchild.readline() ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, "video2") ! os.popen("rm divx2pass.log 2>/dev/null") os.popen("".join(["rm ", self.outdir, "frameno.avi 2>/dev/null"])) --- 417,424 ---- video_pass2.insert(4, self.sLanguage) ! self.runPass("audio", audio_pass) ! self.runPass("video1", video_pass1) ! self.runPass("video2", video_pass2) ! os.popen("rm divx2pass.log 2>/dev/null") os.popen("".join(["rm ", self.outdir, "frameno.avi 2>/dev/null"])) *************** *** 562,594 **** ! ## INHERIT THE CLASS AND SUBSTITUE THESE CLASS METHODS WITH YOUR ! ## OWN UI HOOKS ! def int_startScanning(self): ! pass ! def int_noTracks(self): ! pass ! def int_dispDVD(self): ! pass - def int_dispTrack(self, track): - pass ! def int_finishScanning(self): ! pass ! def int_startRipping(self): ! pass ! def int_newTrack(self, name, number, total, vbr): ! pass ! def int_newPass(self, passtype): ! pass ! def int_updateProgress(self, perc, tpass): ! pass ! def int_finishRipping(self): ! pass --- 428,487 ---- ! def runPass(self, name, command): ! # Nasty GUI-specific code to stop GUI running on to other passes when previous ! # pass was cleanly stopped (without exiting the whole program) ! if self.state is "stopped": ! return ! pipe_perc = re.compile('.*f \((.\d)\%\)*') ! pipe_Trem = re.compile('(?P<int>[0-9]+)min') ! perc = 0 ! Trem = 0 ! self.int_newPass(name) ! self.pipe = popen2.Popen4(command) ! pid = self.pipe.pid ! while 1: ! line = self.pipe.fromchild.read(1000) ! if not line:# == '': ! break ! if pipe_perc.search(line): ! perc = pipe_perc.search(line).group(1) ! perc = re.sub(' ', '', perc) ! if pipe_Trem.search(line): ! Trem = pipe_Trem.search(line).group(0) ! self.int_updateProgress(perc, Trem, name) ! os.waitpid(pid, os.WNOHANG) ! ## INHERIT THE CLASS AND SUBSTITUE THESE CLASS METHODS WITH YOUR ! ## OWN UI HOOKS ! def int_startScanning(self): ! pass ! def int_noTracks(self): ! pass ! def int_dispDVD(self): ! pass ! def int_dispTrack(self, track): ! pass ! def int_finishScanning(self): ! pass ! def int_startRipping(self): ! pass ! ! def int_newTrack(self, name, number, total, vbr): ! pass ! ! def int_newPass(self, passtype): ! pass ! ! def int_updateProgress(self, perc, tpass): ! pass ! ! def int_finishRipping(self): ! pass Index: gui.py =================================================================== RCS file: /cvsroot/quickrip/quickrip/gui.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** gui.py 17 Jul 2003 10:41:22 -0000 1.13 --- gui.py 17 Jul 2003 13:12:14 -0000 1.14 *************** *** 64,67 **** --- 64,69 ---- self.slangs = [] self.tracks = [] + self.dio = {0 : 'None', 1: 'dint', 2: 'il', 3: 'lavcdeint', 4: 'pp=lb'} + self.aro = {0: 'Default', 1: '4:3', 2: '16:9', 3: '2.35:1'} self.configfile = os.path.join(os.path.expanduser("~"),".quickriprc") (self.config, self.parser) = self.loadConfig() *************** *** 120,124 **** def int_startRipping(self): print "* Starting ripping" - self.openRipDialogue() def int_newTrack(self, name, number, total, vbr): --- 122,125 ---- *************** *** 147,151 **** self.trem = trem self.tpass = tpass ! self.Dialogue.ETA.setText(str(trem)) if self.tpass is "all": self.Dialogue.pm_audioPass.setProgress(int(perc)) --- 148,153 ---- self.trem = trem self.tpass = tpass ! eta = "".join(["ETA: ", str(trem), " (approximately)"]) ! self.Dialogue.l_ETA.setText(eta) if self.tpass is "all": self.Dialogue.pm_audioPass.setProgress(int(perc)) *************** *** 171,174 **** --- 173,177 ---- self.Dialogue.b_changeState.setText("Start") self.Dialogue.b_closeProgressDialogue.setEnabled(1) + self.Dialogue.l_ETA.setText("ETA: N/A") self.state = "stopped" os.chdir(self.cwd) Index: guimain.py =================================================================== RCS file: /cvsroot/quickrip/quickrip/guimain.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** guimain.py 16 Jul 2003 13:23:20 -0000 1.3 --- guimain.py 17 Jul 2003 13:12:14 -0000 1.4 *************** *** 3,7 **** # Form implementation generated from reading ui file 'ui/guimain.ui' # ! # Created: Fri Jul 11 16:29:54 2003 # by: The PyQt User Interface Compiler (pyuic) 3.6 # --- 3,7 ---- # Form implementation generated from reading ui file 'ui/guimain.ui' # ! # Created: Thu Jul 17 12:24:59 2003 # by: The PyQt User Interface Compiler (pyuic) 3.6 [...2423 lines suppressed...] self.connect(self.outputDir,SIGNAL("textChanged(const QString&)"),self.checkEnableRip) self.connect(self.fileSize,SIGNAL("valueChanged(int)"),self.newFileSize) *************** *** 1673,1679 **** print "MainWindow.scanDVD(): Not implemented yet" - def ripDVD(self): - print "MainWindow.ripDVD(): Not implemented yet" - def checkEnableRip(self,a0): print "MainWindow.checkEnableRip(const QString&): Not implemented yet" --- 1631,1634 ---- *************** *** 1705,1706 **** --- 1660,1664 ---- def newAudioBitrate(self): print "MainWindow.newAudioBitrate(): Not implemented yet" + + def openRipDialogue(self): + print "MainWindow.openRipDialogue(): Not implemented yet" |