From aed8e476b5e70cd1ec701590078082d07d3b26de Mon Sep 17 00:00:00 2001 From: wgw Date: Sat, 29 Mar 2008 03:14:41 -0500 Subject: [PATCH] expand par/dar flexibility --- plugins/video/transcode.py | 60 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/plugins/video/transcode.py b/plugins/video/transcode.py index 247fceb..a88491a 100644 --- a/plugins/video/transcode.py +++ b/plugins/video/transcode.py @@ -65,12 +65,12 @@ def select_audiocodec(inFile, tsn = ''): # Default, compatible with all TiVo's codec = 'ac3' if config.getAudioCodec(tsn) == None: - type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar = video_info(inFile) + type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2 = video_info(inFile) if acodec in ('ac3', 'liba52', 'mp2'): if akbps == None: cmd_string = '-y -vcodec mpeg2video -r 29.97 -b 1000k -acodec copy -t 00:00:01 -f vob -' if video_check(inFile, cmd_string): - type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar = video_info(videotest) + type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2 = video_info(videotest) if not akbps == None and int(akbps) <= config.getMaxAudioBR(tsn): # compatible codec and bitrate, do not reencode audio codec = 'copy' @@ -80,7 +80,7 @@ def select_audiocodec(inFile, tsn = ''): def select_audiofr(inFile, tsn): freq = '48000' #default - type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar = video_info(inFile) + type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2 = video_info(inFile) if not afreq == None and afreq in ('44100', '48000'): # compatible frequency freq = afreq @@ -139,7 +139,7 @@ def select_aspect(inFile, tsn = ''): TIVO_WIDTH = config.getTivoWidth(tsn) TIVO_HEIGHT = config.getTivoHeight(tsn) - type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar = video_info(inFile) + type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2 = video_info(inFile) debug_write(__name__, fn_attr(), ['tsn:', tsn]) @@ -170,10 +170,10 @@ def select_aspect(inFile, tsn = ''): if config.isHDtivo(tsn) and not optres: if config.getPixelAR(0): - if vpar == None: + if par2 == None: npar = config.getPixelAR(1) else: - npar = vpar + npar = par2 # adjust for pixel aspect ratio, if set, because TiVo expects square pixels if npar<1.0: return ['-s', str(width) + 'x' + str(int(math.ceil(height/npar)))] @@ -184,7 +184,7 @@ def select_aspect(inFile, tsn = ''): # pass all resolutions to S3, except heights greater than conf height return [] # else, resize video. - if (rwidth, rheight) in [(1, 1)] and vpar == 8.0/9.0: + if (rwidth, rheight) in [(1, 1)] and par1 == '8:9': debug_write(__name__, fn_attr(), ['File + PAR is within 4:3.']) return ['-aspect', '4:3', '-s', str(TIVO_WIDTH) + 'x' + str(TIVO_HEIGHT)] elif (rwidth, rheight) in [(4, 3), (10, 11), (15, 11), (59, 54), (59, 72), (59, 36), (59, 54)]: @@ -300,7 +300,7 @@ def select_aspect(inFile, tsn = ''): def tivo_compatable(inFile, tsn = ''): supportedModes = [[720, 480], [704, 480], [544, 480], [480, 480], [352, 480]] - type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar = video_info(inFile) + type, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2 = video_info(inFile) #print type, width, height, fps, millisecs, kbps, akbps, acodec if (inFile[-5:]).lower() == '.tivo': @@ -336,10 +336,10 @@ def tivo_compatable(inFile, tsn = ''): return False if config.isHDtivo(tsn): - if vpar != 1.0: + if par2 != 1.0: if config.getPixelAR(0): - if vpar != None or config.getPixelAR(1) != 1.0: - debug_write(__name__, fn_attr(), ['FALSE,', vpar, 'not correct PAR,', inFile]) + if par2 != None or config.getPixelAR(1) != 1.0: + debug_write(__name__, fn_attr(), ['FALSE,', par2, 'not correct PAR,', inFile]) return False debug_write(__name__, fn_attr(), ['TRUE, HD Tivo detected, skipping remaining tests', inFile]) return True @@ -350,8 +350,8 @@ def tivo_compatable(inFile, tsn = ''): return False if not config.get169Setting(tsn): - if vdar == None or not vdar in (4.0/3.0, 8.0/9.0): - debug_write(__name__, fn_attr(), ['FALSE, DAR', vdar, 'not supported by BLACKLIST_169 tivos.', inFile]) + if dar1 == None or not dar1 in ('4:3', '8:9'): + debug_write(__name__, fn_attr(), ['FALSE, DAR', dar1, 'not supported by BLACKLIST_169 tivos.', inFile]) return False for mode in supportedModes: @@ -371,9 +371,9 @@ def video_info(inFile): return info_cache[inFile][1] if (inFile[-5:]).lower() == '.tivo': - info_cache[inFile] = (mtime, (True, True, True, True, True, True, True, True, True, True, True)) + info_cache[inFile] = (mtime, (True, True, True, True, True, True, True, True, True, True, True, True, True)) debug_write(__name__, fn_attr(), ['VALID, ends in .tivo.', inFile]) - return True, True, True, True, True, True, True, True, True, True, True + return True, True, True, True, True, True, True, True, True, True, True, True, True cmd = [ffmpeg_path(), '-i', inFile ] ffmpeg = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE) @@ -386,8 +386,8 @@ def video_info(inFile): if ffmpeg.poll() == None: kill(ffmpeg.pid) - info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None)) - return None, None, None, None, None, None, None, None, None, None, None + info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None, None, None)) + return None, None, None, None, None, None, None, None, None, None, None, None, None output = ffmpeg.stderr.read() debug_write(__name__, fn_attr(), ['ffmpeg output=', output]) @@ -397,9 +397,9 @@ def video_info(inFile): if x: codec = x.group(1) else: - info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None)) + info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None, None, None)) debug_write(__name__, fn_attr(), ['failed at video codec']) - return None, None, None, None, None, None, None, None, None, None, None + return None, None, None, None, None, None, None, None, None, None, None, None, None rezre = re.compile(r'.*Video: .+, (\d+)x(\d+)[, ].*') x = rezre.search(output) @@ -407,18 +407,18 @@ def video_info(inFile): width = int(x.group(1)) height = int(x.group(2)) else: - info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None)) + info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None, None, None)) debug_write(__name__, fn_attr(), ['failed at width/height']) - return None, None, None, None, None, None, None, None, None, None, None + return None, None, None, None, None, None, None, None, None, None, None, None, None rezre = re.compile(r'.*Video: .+, (.+) (?:fps|tb).*') x = rezre.search(output) if x: fps = x.group(1) else: - info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None)) + info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None, None, None, None, None, None)) debug_write(__name__, fn_attr(), ['failed at fps']) - return None, None, None, None, None, None, None, None, None, None, None + return None, None, None, None, None, None, None, None, None, None, None, None, None # Allow override only if it is mpeg2 and frame rate was doubled to 59.94 if (not fps == '29.97') and (codec == 'mpeg2video'): @@ -483,21 +483,21 @@ def video_info(inFile): rezre = re.compile(r'.*Video: .+PAR ([0-9]+):([0-9]+) DAR [0-9:]+.*') x = rezre.search(output) if x and x.group(1)!="0" and x.group(2)!="0": - vpar = float(x.group(1))/float(x.group(2)) + par1, par2 = x.group(1)+':'+x.group(2), float(x.group(1))/float(x.group(2)) else: - vpar = None + par1, par2 = None, None #get dar. rezre = re.compile(r'.*Video: .+DAR ([0-9]+):([0-9]+).*') x = rezre.search(output) if x and x.group(1)!="0" and x.group(2)!="0": - vdar = float(x.group(1))/float(x.group(2)) + dar1, dar2 = x.group(1)+':'+x.group(2), float(x.group(1))/float(x.group(2)) else: - vdar = None + dar1, dar2 = None, None - info_cache[inFile] = (mtime, (codec, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar)) - debug_write(__name__, fn_attr(), ['Codec=', codec, ' width=', width, ' height=', height, ' fps=', fps, ' millisecs=', millisecs, ' kbps=', kbps, ' akbps=', akbps, ' acodec=', acodec, ' afreq=', afreq, ' par=', vpar, ' dar=', vdar]) - return codec, width, height, fps, millisecs, kbps, akbps, acodec, afreq, vpar, vdar + info_cache[inFile] = (mtime, (codec, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2)) + debug_write(__name__, fn_attr(), ['Codec=', codec, ' width=', width, ' height=', height, ' fps=', fps, ' millisecs=', millisecs, ' kbps=', kbps, ' akbps=', akbps, ' acodec=', acodec, ' afreq=', afreq, ' par=', par1, par2, ' dar=', dar1, dar2]) + return codec, width, height, fps, millisecs, kbps, akbps, acodec, afreq, par1, par2, dar1, dar2 def video_check(inFile, cmd_string): cmd = [ffmpeg_path(), '-i', inFile] + cmd_string.split() -- 2.11.4.GIT