Beispiel #1
0
def select_audiocodec(isQuery, inFile, tsn='', mime=''):
    if inFile[-5:].lower() == '.tivo':
        return ['-c:a', 'copy']
    vInfo = video_info(inFile)
    codectype = vInfo['vCodec']
    # Default, compatible with all TiVo's
    codec = 'ac3'
    compatiblecodecs = ('ac3', 'liba52', 'mp2')

    if vInfo['aCodec'] in compatiblecodecs:
        aKbps = vInfo['aKbps']
        aCh = vInfo['aCh']
        if aKbps == None:
            if not isQuery:
                vInfoQuery = audio_check(inFile, tsn)
                if vInfoQuery == None:
                    aKbps = None
                    aCh = None
                else:
                    aKbps = vInfoQuery['aKbps']
                    aCh = vInfoQuery['aCh']
            else:
                codec = 'TBA'
        if aKbps and int(aKbps) <= config.getMaxAudioBR(tsn):
            # compatible codec and bitrate, do not reencode audio
            codec = 'copy'
        if vInfo['aCodec'] != 'ac3' and (aCh == None or aCh > 2):
            codec = 'ac3'
    val = ['-c:a', codec]
    if not (codec == 'copy' and codectype == 'mpeg2video'):
        val.append('-copyts')
    return val
Beispiel #2
0
def select_audiocodec(isQuery, inFile, tsn=""):
    if inFile[-5:].lower() == ".tivo":
        return "-acodec copy"
    vInfo = video_info(inFile)
    codectype = vInfo["vCodec"]
    codec = config.get_tsn("audio_codec", tsn)
    if not codec:
        # Default, compatible with all TiVo's
        codec = "ac3"
        if vInfo["aCodec"] in ("ac3", "liba52", "mp2"):
            aKbps = vInfo["aKbps"]
            if aKbps == None:
                if not isQuery:
                    aKbps = audio_check(inFile, tsn)
                else:
                    codec = "TBD"
            if aKbps != None and int(aKbps) <= config.getMaxAudioBR(tsn):
                # compatible codec and bitrate, do not reencode audio
                codec = "copy"
    copy_flag = config.get_tsn("copy_ts", tsn)
    copyts = " -copyts"
    if (codec == "copy" and codectype == "mpeg2video" and not copy_flag) or (
        copy_flag and copy_flag.lower() == "false"
    ):
        copyts = ""
    return "-acodec " + codec + copyts
Beispiel #3
0
def tivo_compatible_audio(vInfo, inFile, tsn, mime=""):
    message = (True, "")
    while True:
        codec = vInfo["aCodec"]
        if mime == "video/mp4":
            if codec not in ("mpeg4aac", "libfaad", "mp4a", "aac", "ac3", "liba52"):
                message = (False, "aCodec %s not compatible" % codec)

            break

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

            break

        if inFile[-5:].lower() == ".tivo":
            break

        if codec not in ("ac3", "liba52", "mp2"):
            message = (False, "aCodec %s not compatible" % codec)
            break

        if not vInfo["aKbps"] or int(vInfo["aKbps"]) > config.getMaxAudioBR(tsn):
            message = (False, "%s kbps exceeds max audio bitrate" % vInfo["aKbps"])
            break

        audio_lang = config.get_tsn("audio_lang", tsn)
        if audio_lang:
            if vInfo["mapAudio"][0][0] != select_audiolang(inFile, tsn)[-3:]:
                message = (False, "%s preferred audio track exists" % audio_lang)
        break

    return message
Beispiel #4
0
    def __est_size(self, full_path, tsn='', mime=''):
        # Size is estimated by taking audio and video bit rate adding 2%

        vInfo = transcode.video_info(full_path)
        if not mime:
            compat = False
            mimetypes = ['video/x-tivo-mpeg']
            if self.use_ts(tsn, full_path):
                mimetypes = ['video/x-tivo-mpeg', 'video/x-tivo-mpeg-ts']
            
            for mimet in mimetypes:
                compat = transcode.tivo_compatible_video(vInfo, tsn, mimet)[0]
                if compat:
                    break
        else:
            compat = transcode.tivo_compatible_video(vInfo, tsn, mime)[0]
            
        if compat:
            return int(os.path.getsize(unicode(full_path, 'utf-8'))*1.1)
        else:
            # Must be re-encoded
            audioBPS = config.getMaxAudioBR(tsn) * 1000
            #audioBPS = config.strtod(config.getAudioBR(tsn))
            videoBPS = transcode.select_videostr(full_path, tsn)
            bitrate =  audioBPS + videoBPS
            return int((self.__duration(full_path) / 1000) *
                       (bitrate * 1.02 / 8))
Beispiel #5
0
def select_audiocodec(isQuery, inFile, tsn='', mime=''):
    if inFile[-5:].lower() == '.tivo':
        return ['-c:a', 'copy']
    vInfo = video_info(inFile)
    codectype = vInfo['vCodec']
    # Default, compatible with all TiVo's
    codec = 'ac3'
    compatiblecodecs = ('ac3', 'liba52', 'mp2')

    if vInfo['aCodec'] in compatiblecodecs:
        aKbps = vInfo['aKbps']
        aCh = vInfo['aCh']
        if aKbps == None:
            if not isQuery:
                vInfoQuery = audio_check(inFile, tsn)
                if vInfoQuery == None:
                    aKbps = None
                    aCh = None
                else:
                    aKbps = vInfoQuery['aKbps']
                    aCh = vInfoQuery['aCh']
            else:
                codec = 'TBA'
        if aKbps and int(aKbps) <= config.getMaxAudioBR(tsn):
            # compatible codec and bitrate, do not reencode audio
            codec = 'copy'
        if vInfo['aCodec'] != 'ac3' and (aCh == None or aCh > 2):
            codec = 'ac3'
    val = ['-c:a', codec]
    if not (codec == 'copy' and codectype == 'mpeg2video'):
        val.append('-copyts')
    return val
Beispiel #6
0
def select_audiocodec(isQuery, inFile, tsn=''):
    if inFile[-5:].lower() == '.tivo':
        return '-acodec copy'
    vInfo = video_info(inFile)
    codectype = vInfo['vCodec']
    codec = config.get_tsn('audio_codec', tsn)
    if not codec:
        # Default, compatible with all TiVo's
        codec = 'ac3'
        if vInfo['aCodec'] in ('ac3', 'liba52', 'mp2'):
            aKbps = vInfo['aKbps']
            if aKbps == None:
                if not isQuery:
                    aKbps = audio_check(inFile, tsn)
                else:
                    codec = 'TBD'
            if aKbps != None and int(aKbps) <= config.getMaxAudioBR(tsn):
                # compatible codec and bitrate, do not reencode audio
                codec = 'copy'
    copy_flag = config.get_tsn('copy_ts', tsn)
    copyts = ' -copyts'
    if ((codec == 'copy' and codectype == 'mpeg2video' and not copy_flag) or
        (copy_flag and copy_flag.lower() == 'false')):
        copyts = ''
    return '-acodec ' + codec + copyts
Beispiel #7
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
Beispiel #8
0
def tivo_compatible_audio(vInfo, inFile, tsn, mime=''):
    message = (True, '')
    while True:
        codec = vInfo.get('aCodec', '')

        if codec == None:
            debug('No audio stream detected')
            break

        if mime == 'video/mp4':
            if codec not in ('mpeg4aac', 'libfaad', 'mp4a', 'aac',
                             'ac3', 'liba52'):
                message = (False, 'aCodec %s not compatible' % codec)
                break
            if vInfo['aCodec'] in ('mpeg4aac', 'libfaad', 'mp4a', 'aac') and (vInfo['aCh'] == None or vInfo['aCh'] > 2):
                message = (False, 'aCodec %s is only supported with 2 or less channels, the track has %s channels' % (codec, vInfo['aCh']))
                break

            audio_lang = config.get_tsn('audio_lang', tsn)
            if audio_lang:
                if vInfo['mapAudio'][0][0] != select_audiolang(inFile, tsn)[-3:]:
                    message = (False, '%s preferred audio track exists' %
                                      audio_lang)
            break

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

            break

        if inFile[-5:].lower() == '.tivo':
            break

        if mime == 'video/x-tivo-mpeg-ts':
            if codec not in ('ac3', 'liba52', 'mp2', 'aac_latm'):
                message = (False, 'aCodec %s not compatible' % codec)

            break

        if codec not in ('ac3', 'liba52', 'mp2'):
            message = (False, 'aCodec %s not compatible' % codec)
            break

        if (not vInfo['aKbps'] or
            int(vInfo['aKbps']) > config.getMaxAudioBR(tsn)):
            message = (False, '%s kbps exceeds max audio bitrate' %
                              vInfo['aKbps'])
            break

        audio_lang = config.get_tsn('audio_lang', tsn)
        if audio_lang:
            if vInfo['mapAudio'][0][0] != select_audiolang(inFile, tsn)[-3:]:
                message = (False, '%s preferred audio track exists' %
                                  audio_lang)
        break

    return message
Beispiel #9
0
def tivo_compatible_audio(vInfo, inFile, tsn, mime=""):
    message = (True, "")
    while True:
        codec = vInfo.get("aCodec", "")

        if codec == None:
            debug("No audio stream detected")
            break

        if mime == "video/mp4":
            if codec not in ("mpeg4aac", "libfaad", "mp4a", "aac", "ac3", "liba52"):
                message = (False, "aCodec %s not compatible" % codec)
                break
            if vInfo["aCodec"] in ("mpeg4aac", "libfaad", "mp4a", "aac") and (vInfo["aCh"] == None or vInfo["aCh"] > 2):
                message = (
                    False,
                    "aCodec %s is only supported with 2 or less channels, the track has %s channels"
                    % (codec, vInfo["aCh"]),
                )
                break

            audio_lang = config.get_tsn("audio_lang", tsn)
            if audio_lang:
                if vInfo["mapAudio"][0][0] != select_audiolang(inFile, tsn)[-3:]:
                    message = (False, "%s preferred audio track exists" % audio_lang)
            break

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

            break

        if inFile[-5:].lower() == ".tivo":
            break

        if mime == "video/x-tivo-mpeg-ts":
            if codec not in ("ac3", "liba52", "mp2", "aac_latm"):
                message = (False, "aCodec %s not compatible" % codec)

            break

        if codec not in ("ac3", "liba52", "mp2"):
            message = (False, "aCodec %s not compatible" % codec)
            break

        if not vInfo["aKbps"] or int(vInfo["aKbps"]) > config.getMaxAudioBR(tsn):
            message = (False, "%s kbps exceeds max audio bitrate" % vInfo["aKbps"])
            break

        audio_lang = config.get_tsn("audio_lang", tsn)
        if audio_lang:
            if vInfo["mapAudio"][0][0] != select_audiolang(inFile, tsn)[-3:]:
                message = (False, "%s preferred audio track exists" % audio_lang)
        break

    return message
Beispiel #10
0
    def __est_size(self, full_path, tsn="", mime=""):
        # Size is estimated by taking audio and video bit rate adding 2%

        if transcode.tivo_compatible(full_path, tsn, mime)[0]:
            return int(os.stat(unicode(full_path, "utf-8")).st_size)
        else:
            # Must be re-encoded
            audioBPS = config.getMaxAudioBR(tsn) * 1000
            # audioBPS = config.strtod(config.getAudioBR(tsn))
            videoBPS = transcode.select_videostr(full_path, tsn)
            bitrate = audioBPS + videoBPS
            return int((self.__duration(full_path) / 1000) * (bitrate * 1.02 / 8))
Beispiel #11
0
    def __est_size(self, full_path, tsn='', mime=''):
        # Size is estimated by taking audio and video bit rate adding 2%

        if transcode.tivo_compatible(full_path, tsn, mime)[0]:
            return os.path.getsize(unicode(full_path, 'utf-8'))
        else:
            # Must be re-encoded
            audioBPS = config.getMaxAudioBR(tsn) * 1000
            #audioBPS = config.strtod(config.getAudioBR(tsn))
            videoBPS = transcode.select_videostr(full_path, tsn)
            bitrate = audioBPS + videoBPS
            return int(
                (self.__duration(full_path) / 1000) * (bitrate * 1.02 / 8))
Beispiel #12
0
    def __est_size(self, full_path, tsn = ''):
        # Size is estimated by taking audio and video bit rate adding 2%

        if transcode.tivo_compatable(full_path, tsn):
            # Is TiVo-compatible mpeg2
            return int(os.stat(full_path).st_size)
        else:
            # Must be re-encoded
            if config.getAudioCodec(tsn) == None:
                audioBPS = config.getMaxAudioBR(tsn)*1000
            else:
                audioBPS = config.strtod(config.getAudioBR(tsn))
            videoBPS = config.strtod(config.getVideoBR(tsn))
            bitrate =  audioBPS + videoBPS
            return int((self.__duration(full_path) / 1000) *
                       (bitrate * 1.02 / 8))
Beispiel #13
0
    def __est_size(self, full_path, tsn=''):
        # Size is estimated by taking audio and video bit rate adding 2%

        if transcode.tivo_compatable(full_path, tsn):
            # Is TiVo-compatible mpeg2
            return int(os.stat(full_path).st_size)
        else:
            # Must be re-encoded
            if config.getAudioCodec(tsn) == None:
                audioBPS = config.getMaxAudioBR(tsn) * 1000
            else:
                audioBPS = config.strtod(config.getAudioBR(tsn))
            videoBPS = config.strtod(config.getVideoBR(tsn))
            bitrate = audioBPS + videoBPS
            return int(
                (self.__duration(full_path) / 1000) * (bitrate * 1.02 / 8))
Beispiel #14
0
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 =  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 =  video_info(videotest)
            if not akbps == None and int(akbps) <= config.getMaxAudioBR(tsn):
                # compatible codec and bitrate, do not reencode audio
                codec = 'copy'
    else:
        codec = config.getAudioCodec(tsn)
    return '-acodec '+codec
Beispiel #15
0
def select_audiocodec(isQuery, inFile, tsn='', mime=''):
    if inFile[-5:].lower() == '.tivo':
        return '-acodec copy'
    vInfo = video_info(inFile)
    codectype = vInfo['vCodec']
    codec = config.get_tsn('audio_codec', tsn)
    if not codec:
        # Default, compatible with all TiVo's
        codec = 'ac3'
        if mime == 'video/mp4':
            compatiblecodecs = ('mpeg4aac', 'libfaad', 'mp4a', 'aac',
                                'ac3', 'liba52')
        else:
            compatiblecodecs = ('ac3', 'liba52', 'mp2')

        if vInfo['aCodec'] in compatiblecodecs:
            aKbps = vInfo['aKbps']
            aCh = vInfo['aCh']
            if aKbps == None:
                if vInfo['aCodec'] in ('mpeg4aac', 'libfaad', 'mp4a', 'aac'):
                    # along with the channel check below this should
                    # pass any AAC audio that has undefined 'aKbps' and
                    # is <= 2 channels.  Should be TiVo compatible.
                    codec = 'copy'
                elif not isQuery:
                    vInfoQuery = audio_check(inFile, tsn)
                    if vInfoQuery == None:
                        aKbps = None
                        aCh = None
                    else:
                        aKbps = vInfoQuery['aKbps']
                        aCh = vInfoQuery['aCh']
                else:
                    codec = 'TBA'
            if aKbps and int(aKbps) <= config.getMaxAudioBR(tsn):
                # compatible codec and bitrate, do not reencode audio
                codec = 'copy'
            if vInfo['aCodec'] != 'ac3' and (aCh == None or aCh > 2):
                codec = 'ac3'
    copy_flag = config.get_tsn('copy_ts', tsn)
    copyts = ' -copyts'
    if ((codec == 'copy' and codectype == 'mpeg2video' and not copy_flag) or
        (copy_flag and copy_flag.lower() == 'false')):
        copyts = ''
    return '-acodec ' + codec + copyts
Beispiel #16
0
def select_audiocodec(isQuery, inFile, tsn='', mime=''):
    if inFile[-5:].lower() == '.tivo':
        return '-acodec copy'
    vInfo = video_info(inFile)
    codectype = vInfo['vCodec']
    codec = config.get_tsn('audio_codec', tsn)
    if not codec:
        # Default, compatible with all TiVo's
        codec = 'ac3'
        if mime == 'video/mp4':
            compatiblecodecs = ('mpeg4aac', 'libfaad', 'mp4a', 'aac', 'ac3',
                                'liba52')
        else:
            compatiblecodecs = ('ac3', 'liba52', 'mp2')

        if vInfo['aCodec'] in compatiblecodecs:
            aKbps = vInfo['aKbps']
            aCh = vInfo['aCh']
            if aKbps == None:
                if vInfo['aCodec'] in ('mpeg4aac', 'libfaad', 'mp4a', 'aac'):
                    # along with the channel check below this should
                    # pass any AAC audio that has undefined 'aKbps' and
                    # is <= 2 channels.  Should be TiVo compatible.
                    codec = 'copy'
                elif not isQuery:
                    vInfoQuery = audio_check(inFile, tsn)
                    if vInfoQuery == None:
                        aKbps = None
                        aCh = None
                    else:
                        aKbps = vInfoQuery['aKbps']
                        aCh = vInfoQuery['aCh']
                else:
                    codec = 'TBA'
            if aKbps and int(aKbps) <= config.getMaxAudioBR(tsn):
                # compatible codec and bitrate, do not reencode audio
                codec = 'copy'
            if vInfo['aCodec'] != 'ac3' and (aCh == None or aCh > 2):
                codec = 'ac3'
    copy_flag = config.get_tsn('copy_ts', tsn)
    copyts = ' -copyts'
    if ((codec == 'copy' and codectype == 'mpeg2video' and not copy_flag)
            or (copy_flag and copy_flag.lower() == 'false')):
        copyts = ''
    return '-acodec ' + codec + copyts
Beispiel #17
0
def tivo_compatible_audio(vInfo, inFile, tsn, mime=''):
    message = (True, '')
    while True:
        codec = vInfo.get('aCodec', '')
        if mime == 'video/mp4':
            if codec not in ('mpeg4aac', 'libfaad', 'mp4a', 'aac', 
                             'ac3', 'liba52'):
                message = (False, 'aCodec %s not compatible' % codec)

            break

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

            break

        if inFile[-5:].lower() == '.tivo':
            break

        if mime == 'video/x-tivo-mpeg-ts' and codec not in ('ac3', 'liba52'):
            message = (False, 'aCodec %s not compatible' % codec)
            break

        if codec not in ('ac3', 'liba52', 'mp2'):
            message = (False, 'aCodec %s not compatible' % codec)
            break

        if (not vInfo['aKbps'] or
            int(vInfo['aKbps']) > config.getMaxAudioBR(tsn)):
            message = (False, '%s kbps exceeds max audio bitrate' %
                              vInfo['aKbps'])
            break

        audio_lang = config.get_tsn('audio_lang', tsn)
        if audio_lang:
            if vInfo['mapAudio'][0][0] != select_audiolang(inFile, tsn)[-3:]:
                message = (False, '%s preferred audio track exists' % 
                                  audio_lang)
        break

    return message
Beispiel #18
0
def select_audiocodec(isQuery, inFile, tsn="", mime=""):
    if inFile[-5:].lower() == ".tivo":
        return ["-c:a", "copy"]
    vInfo = video_info(inFile)
    codectype = vInfo["vCodec"]
    # Default, compatible with all TiVo's
    codec = "ac3"
    if mime == "video/mp4":
        compatiblecodecs = ("mpeg4aac", "libfaad", "mp4a", "aac", "ac3", "liba52")
    else:
        compatiblecodecs = ("ac3", "liba52", "mp2")

    if vInfo["aCodec"] in compatiblecodecs:
        aKbps = vInfo["aKbps"]
        aCh = vInfo["aCh"]
        if aKbps == None:
            if vInfo["aCodec"] in ("mpeg4aac", "libfaad", "mp4a", "aac"):
                # along with the channel check below this should
                # pass any AAC audio that has undefined 'aKbps' and
                # is <= 2 channels.  Should be TiVo compatible.
                codec = "copy"
            elif not isQuery:
                vInfoQuery = audio_check(inFile, tsn)
                if vInfoQuery == None:
                    aKbps = None
                    aCh = None
                else:
                    aKbps = vInfoQuery["aKbps"]
                    aCh = vInfoQuery["aCh"]
            else:
                codec = "TBA"
        if aKbps and int(aKbps) <= config.getMaxAudioBR(tsn):
            # compatible codec and bitrate, do not reencode audio
            codec = "copy"
        if vInfo["aCodec"] != "ac3" and (aCh == None or aCh > 2):
            codec = "ac3"
    val = ["-c:a", codec]
    if not (codec == "copy" and codectype == "mpeg2video"):
        val.append("-copyts")
    return val
Beispiel #19
0
def tivo_compatible_audio(vInfo, inFile, tsn, mime=''):
    message = (True, '')
    while True:
        codec = vInfo.get('aCodec', '')

        if codec == None:
            debug('No audio stream detected')
            break

        if inFile[-5:].lower() == '.tivo':
            break

        if mime == 'video/x-tivo-mpeg-ts':
            if codec not in ('ac3', 'liba52', 'mp2', 'aac_latm'):
                message = (False, 'aCodec %s not compatible' % codec)

            break

        if codec not in ('ac3', 'liba52', 'mp2'):
            message = (False, 'aCodec %s not compatible' % codec)
            break

        if (not vInfo['aKbps']
                or int(vInfo['aKbps']) > config.getMaxAudioBR(tsn)):
            message = (False,
                       '%s kbps exceeds max audio bitrate' % vInfo['aKbps'])
            break

        audio_lang = config.get_tsn('audio_lang', tsn)
        if audio_lang:
            if vInfo['mapAudio'][0][0] != select_audiolang(inFile, tsn)[-3:]:
                message = (False,
                           '%s preferred audio track exists' % audio_lang)
        break

    return message
Beispiel #20
0
def tivo_compatible_audio(vInfo, inFile, tsn, mime=''):
    message = (True, '')
    while True:
        codec = vInfo.get('aCodec', '')

        if codec == None:
            debug('No audio stream detected')
            break

        if mime == 'video/mp4':
            if codec not in ('mpeg4aac', 'libfaad', 'mp4a', 'aac', 'ac3',
                             'liba52'):
                message = (False, 'aCodec %s not compatible' % codec)
                break
            if vInfo['aCodec'] in ('mpeg4aac', 'libfaad', 'mp4a',
                                   'aac') and (vInfo['aCh'] == None
                                               or vInfo['aCh'] > 2):
                message = (
                    False,
                    'aCodec %s is only supported with 2 or less channels, the track has %s channels'
                    % (codec, vInfo['aCh']))
                break

            audio_lang = config.get_tsn('audio_lang', tsn)
            if audio_lang:
                if vInfo['mapAudio'][0][0] != select_audiolang(inFile,
                                                               tsn)[-3:]:
                    message = (False,
                               '%s preferred audio track exists' % audio_lang)
            break

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

            break

        if inFile[-5:].lower() == '.tivo':
            break

        if mime == 'video/x-tivo-mpeg-ts':
            if codec not in ('ac3', 'liba52', 'mp2', 'aac_latm'):
                message = (False, 'aCodec %s not compatible' % codec)

            break

        if codec not in ('ac3', 'liba52', 'mp2'):
            message = (False, 'aCodec %s not compatible' % codec)
            break

        if (not vInfo['aKbps']
                or int(vInfo['aKbps']) > config.getMaxAudioBR(tsn)):
            message = (False,
                       '%s kbps exceeds max audio bitrate' % vInfo['aKbps'])
            break

        audio_lang = config.get_tsn('audio_lang', tsn)
        if audio_lang:
            if vInfo['mapAudio'][0][0] != select_audiolang(inFile, tsn)[-3:]:
                message = (False,
                           '%s preferred audio track exists' % audio_lang)
        break

    return message