From: <te...@us...> - 2003-06-15 20:18:18
|
Update of /cvsroot/quickrip/quickrip In directory sc8-pr-cvs1:/tmp/cvs-serv22920 Modified Files: dvd.py Log Message: Added new code to cropdetect each track before ripping, and supply proper cropping parameters to -vop string Index: dvd.py =================================================================== RCS file: /cvsroot/quickrip/quickrip/dvd.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** dvd.py 13 Jun 2003 20:18:35 -0000 1.15 --- dvd.py 15 Jun 2003 20:18:13 -0000 1.16 *************** *** 171,175 **** self.int_dispDVD() ! # Run through tracks looking for playback times and chapters for i in range(int(self.numtitles) + 1): if i > 0: --- 171,175 ---- self.int_dispDVD() ! # Run through tracks looking for playback times, chapters and cropping for i in range(int(self.numtitles) + 1): if i > 0: *************** *** 199,203 **** numchapters = regexp_chap.search(line).group(1) #elif regexp_scale.search(line): ! # scale = regexp_scale.search(line).group(1) # Clean up title --- 199,204 ---- numchapters = regexp_chap.search(line).group(1) #elif regexp_scale.search(line): ! # scale = regexp_scale.search(line).group(1) ! # Clean up title *************** *** 264,267 **** --- 265,289 ---- if (self.volumead is not "0"): self.vol = "".join([":vol=", self.volumead]) + + # Look for cropping + sstep = int(self.track['time']) / 31 + if not sstep: + sstep = 1 + cmd = "".join(["mplayer -dvd ", str(self.track['id']), " -vop cropdetect -nosound -vo null -frames 10 -sstep ", str(sstep), " 2>/dev/null"]) + text = os.popen(cmd).readlines() + regexp = re.compile('.*-vop crop=(\d*:\d*:\d*:\d*).*') + crop_options = {} + common_crop = "" + cc_hits = 0 + for line in text: + if regexp.search(line): + crop = regexp.search(line).group(1) + try: + crop_options[crop] = crop_options[crop] + 1 + if crop_options[crop] > cc_hits: + common_crop = crop + except: + crop_options[crop] = 1 + self.track['crop'] = common_crop pipe_perc = re.compile('.*f \((.\d)\%\)*') *************** *** 272,276 **** 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", "scale,cropdetect", "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] if int(self.config['deinterlacing']) is 1: --- 294,298 ---- 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: *************** *** 297,307 **** 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) self.int_newPass("audio") --- 319,329 ---- 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) self.int_newPass("audio") *************** *** 320,324 **** 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", "scale,cropdetect", "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] if int(self.config['deinterlacing']) is 1: --- 342,346 ---- 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: *************** *** 399,404 **** 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", "scale,cropdetect", "-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", "scale,cropdetect", "-zoom", "-xy", resolution, "-o", self.output, "2>/dev/null"] if int(self.config['deinterlacing']) is 1: --- 421,426 ---- 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: |