Exemplo n.º 1
0
def tivo_compatible_video(vInfo, tsn, mime=''):
    message = (True, '')
    while True:
        codec = vInfo.get('vCodec', '')
        is4k = config.is4Ktivo(tsn) and codec == 'hevc'
        if mime == 'video/mp4':
            if not (is4k or codec == 'h264'):
                message = (False, 'vCodec %s not compatible' % codec)

            break

        if mime == 'video/bif':
            if codec != 'vc1':
                message = (False, 'vCodec %s not compatible' % codec)

            break

        if mime == 'video/x-tivo-mpeg-ts':
            if not (is4k or codec in ('h264', 'mpeg2video')):
                message = (False, 'vCodec %s not compatible' % codec)

            break

        if codec not in ('mpeg2video', 'mpeg1video'):
            message = (False, 'vCodec %s not compatible' % codec)
            break

        if vInfo['kbps'] != None:
            abit = max('0', vInfo['aKbps'])
            if (int(vInfo['kbps']) - int(abit) >
                config.strtod(config.getMaxVideoBR(tsn)) / 1000):
                message = (False, '%s kbps exceeds max video bitrate' %
                                  vInfo['kbps'])
                break
        else:
            message = (False, '%s kbps not supported' % vInfo['kbps'])
            break

        if config.isHDtivo(tsn):
            # HD Tivo detected, skipping remaining tests.
            break

        if not vInfo['vFps'] in ['29.97', '59.94']:
            message = (False, '%s vFps, should be 29.97' % vInfo['vFps'])
            break

        if ((config.get169Blacklist(tsn) and not config.get169Setting(tsn))
            or (config.get169Letterbox(tsn) and config.get169Setting(tsn))):
            if vInfo['dar1'] and vInfo['dar1'] not in ('4:3', '8:9', '880:657'):
                message = (False, ('DAR %s not supported ' +
                                   'by BLACKLIST_169 tivos') % vInfo['dar1'])
                break

        mode = (vInfo['vWidth'], vInfo['vHeight'])
        if mode not in [(720, 480), (704, 480), (544, 480),
                        (528, 480), (480, 480), (352, 480), (352, 240)]:
            message = (False, '%s x %s not in supported modes' % mode)
        break

    return message
Exemplo n.º 2
0
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 =  video_info(inFile)
    #print type, width, height, fps, millisecs, kbps, akbps, acodec

    if (inFile[-5:]).lower() == '.tivo':
        debug_write(__name__, fn_attr(), ['TRUE, ends with .tivo.', inFile])
        return True

    if not type == 'mpeg2video':
        #print 'Not Tivo Codec'
        debug_write(__name__, fn_attr(), ['FALSE, type', type, 'not mpeg2video.', inFile])
        return False

    if os.path.splitext(inFile)[-1].lower() in ('.ts', '.mpv'):
        debug_write(__name__, fn_attr(), ['FALSE, ext', os.path.splitext(inFile)[-1],\
                'not tivo compatible.', inFile])
        return False

    if acodec == 'dca':
        debug_write(__name__, fn_attr(), ['FALSE, acodec', acodec, ', not supported.', inFile])
        return False

    if acodec != None:
        if not akbps or int(akbps) > config.getMaxAudioBR(tsn):
            debug_write(__name__, fn_attr(), ['FALSE,', akbps, 'kbps exceeds max audio bitrate.', inFile])
            return False

    if kbps != None:
        abit = max('0', akbps)
        if int(kbps)-int(abit) > config.strtod(config.getMaxVideoBR())/1000:
            debug_write(__name__, fn_attr(), ['FALSE,', kbps, 'kbps exceeds max video bitrate.', inFile])
            return False
    else:
        debug_write(__name__, fn_attr(), ['FALSE,', kbps, 'kbps not supported.', inFile])
        return False

    if config.isHDtivo(tsn):
        if vpar != 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])
                    return False
        debug_write(__name__, fn_attr(), ['TRUE, HD Tivo detected, skipping remaining tests', inFile])
        return True

    if not fps == '29.97':
        #print 'Not Tivo fps'
        debug_write(__name__, fn_attr(), ['FALSE,', fps, 'fps, should be 29.97.', inFile])
        return False

    for mode in supportedModes:
        if (mode[0], mode[1]) == (width, height):
            #print 'Is TiVo!'
            debug_write(__name__, fn_attr(), ['TRUE,', width, 'x', height, 'is valid.', inFile])
            return True
    #print 'Not Tivo dimensions'
    debug_write(__name__, fn_attr(), ['FALSE,', width, 'x', height, 'not in supported modes.', inFile])
    return False
Exemplo n.º 3
0
def tivo_compatible_video(vInfo, tsn, mime=""):
    message = (True, "")
    while True:
        codec = vInfo.get("vCodec", "")
        is4k = config.is4Ktivo(tsn) and codec == "hevc"
        if mime == "video/mp4":
            if not (is4k or codec == "h264"):
                message = (False, "vCodec %s not compatible" % codec)

            break

        if mime == "video/bif":
            if codec != "vc1":
                message = (False, "vCodec %s not compatible" % codec)

            break

        if mime == "video/x-tivo-mpeg-ts":
            if not (is4k or codec in ("h264", "mpeg2video")):
                message = (False, "vCodec %s not compatible" % codec)

            break

        if codec not in ("mpeg2video", "mpeg1video"):
            message = (False, "vCodec %s not compatible" % codec)
            break

        if vInfo["kbps"] != None:
            abit = max("0", vInfo["aKbps"])
            if int(vInfo["kbps"]) - int(abit) > config.strtod(config.getMaxVideoBR(tsn)) / 1000:
                message = (False, "%s kbps exceeds max video bitrate" % vInfo["kbps"])
                break
        else:
            message = (False, "%s kbps not supported" % vInfo["kbps"])
            break

        if config.isHDtivo(tsn):
            # HD Tivo detected, skipping remaining tests.
            break

        if not vInfo["vFps"] in ["29.97", "59.94"]:
            message = (False, "%s vFps, should be 29.97" % vInfo["vFps"])
            break

        if (config.get169Blacklist(tsn) and not config.get169Setting(tsn)) or (
            config.get169Letterbox(tsn) and config.get169Setting(tsn)
        ):
            if vInfo["dar1"] and vInfo["dar1"] not in ("4:3", "8:9", "880:657"):
                message = (False, ("DAR %s not supported " + "by BLACKLIST_169 tivos") % vInfo["dar1"])
                break

        mode = (vInfo["vWidth"], vInfo["vHeight"])
        if mode not in [(720, 480), (704, 480), (544, 480), (528, 480), (480, 480), (352, 480), (352, 240)]:
            message = (False, "%s x %s not in supported modes" % mode)
        break

    return message
Exemplo n.º 4
0
def select_videostr(inFile, tsn, mime=""):
    vInfo = video_info(inFile)
    if tivo_compatible_video(vInfo, tsn, mime)[0]:
        video_str = int(vInfo["kbps"])
        if vInfo["aKbps"]:
            video_str -= int(vInfo["aKbps"])
        video_str *= 1000
    else:
        video_str = config.strtod(config.getVideoBR(tsn))
        if config.isHDtivo(tsn) and vInfo["kbps"]:
            video_str = max(video_str, int(vInfo["kbps"]) * 1000)
        video_str = int(min(config.strtod(config.getMaxVideoBR(tsn)) * 0.95, video_str))
    return video_str
Exemplo n.º 5
0
def tivo_compatible_video(vInfo, tsn, mime=''):
    message = (True, '')
    while True:
        codec = vInfo.get('vCodec', '')
        is4k = config.is4Ktivo(tsn) and codec == 'hevc'
        if mime == 'video/x-tivo-mpeg-ts':
            if not (is4k or codec in ('h264', 'mpeg2video')):
                message = (False, 'vCodec %s not compatible' % codec)

            break

        if codec not in ('mpeg2video', 'mpeg1video'):
            message = (False, 'vCodec %s not compatible' % codec)
            break

        if vInfo['kbps'] != None:
            abit = max('0', vInfo['aKbps'])
            if (int(vInfo['kbps']) - int(abit) >
                    config.strtod(config.getMaxVideoBR(tsn)) / 1000):
                message = (False,
                           '%s kbps exceeds max video bitrate' % vInfo['kbps'])
                break
        else:
            message = (False, '%s kbps not supported' % vInfo['kbps'])
            break

        if config.isHDtivo(tsn):
            # HD Tivo detected, skipping remaining tests.
            break

        if not vInfo['vFps'] in ['29.97', '59.94']:
            message = (False, '%s vFps, should be 29.97' % vInfo['vFps'])
            break

        if ((config.get169Blacklist(tsn) and not config.get169Setting(tsn)) or
            (config.get169Letterbox(tsn) and config.get169Setting(tsn))):
            if vInfo['dar1'] and vInfo['dar1'] not in ('4:3', '8:9',
                                                       '880:657'):
                message = (
                    False,
                    ('DAR %s not supported ' + 'by BLACKLIST_169 tivos') %
                    vInfo['dar1'])
                break

        mode = (vInfo['vWidth'], vInfo['vHeight'])
        if mode not in [(720, 480), (704, 480), (544, 480), (528, 480),
                        (480, 480), (352, 480), (352, 240)]:
            message = (False, '%s x %s not in supported modes' % mode)
        break

    return message
Exemplo n.º 6
0
def select_videostr(inFile, tsn, mime=''):
    vInfo = video_info(inFile)
    if tivo_compatible_video(vInfo, tsn, mime)[0]:
        video_str = int(vInfo['kbps'])
        if vInfo['aKbps']:
            video_str -= int(vInfo['aKbps'])
        video_str *= 1000
    else:
        video_str = config.strtod(config.getVideoBR(tsn))
        if config.isHDtivo(tsn) and vInfo['kbps']:
            video_str = max(video_str, int(vInfo['kbps']) * 1000)
        video_str = int(
            min(config.strtod(config.getMaxVideoBR(tsn)) * 0.95, video_str))
    return video_str
Exemplo n.º 7
0
def select_videostr(inFile, tsn):
    vInfo = video_info(inFile)
    if tivo_compatible_video(vInfo, tsn)[0]:
        video_str = int(vInfo["kbps"])
        if vInfo["aKbps"]:
            video_str -= int(vInfo["aKbps"])
        video_str *= 1000
    else:
        video_str = config.strtod(config.getVideoBR(tsn))
        if config.isHDtivo(tsn):
            if vInfo["kbps"] != None and config.getVideoPCT(tsn) > 0:
                video_percent = int(vInfo["kbps"]) * 10 * config.getVideoPCT(tsn)
                video_str = max(video_str, video_percent)
        video_str = int(min(config.strtod(config.getMaxVideoBR(tsn)) * 0.95, video_str))
    return video_str
Exemplo n.º 8
0
def select_videostr(inFile, tsn):
    vInfo = video_info(inFile)
    if tivo_compatible_video(vInfo, tsn)[0]:
        video_str = int(vInfo['kbps'])
        if vInfo['aKbps']:
            video_str -= int(vInfo['aKbps'])
        video_str *= 1000
    else:
        video_str = config.strtod(config.getVideoBR(tsn))
        if config.isHDtivo(tsn):
            if vInfo['kbps'] != None and config.getVideoPCT(tsn) > 0:
                video_percent = (int(vInfo['kbps']) * 10 *
                                 config.getVideoPCT(tsn))
                video_str = max(video_str, video_percent)
        video_str = int(
            min(config.strtod(config.getMaxVideoBR(tsn)) * 0.95, video_str))
    return video_str
Exemplo n.º 9
0
def select_maxvideobr(tsn):
    return '-maxrate ' + config.getMaxVideoBR(tsn)
Exemplo n.º 10
0
def select_maxvideobr(tsn):
    return ["-maxrate", config.getMaxVideoBR(tsn)]
Exemplo n.º 11
0
def select_maxvideobr():
    return '-maxrate '+config.getMaxVideoBR()
Exemplo n.º 12
0
def select_maxvideobr(tsn):
    return ['-maxrate', config.getMaxVideoBR(tsn)]