Changeset 089c57291222ea76b1dc0f1aad6c1145989be648

Show
Ignore:
Timestamp:
01/30/08 20:50:23 (10 months ago)
Author:
wgw <tjm1100@gmail.com>
git-committer:
wgw <tjm1100@gmail.com> 1201747823 -0600
git-parent:

[b76b923df63b9dc67520a3d051ec38582ba156c3]

git-author:
wgw <tjm1100@gmail.com> 1201747823 -0600
Message:

test patch using audio codec copy

On HD Tivo, uses -acodec copy if liba52 and file is mkv,
or audio bitrate is tivo compatible

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • config.py

    rb76b923 r089c572  
    169169        else: 
    170170            return '192k' 
    171  
    172 def getAudioCodec(tsn = None): 
    173     #check for HD tivo and return compatible audio parameters 
    174     if tsn and tsn[:3] in getHDtivos(): 
    175         return '-acodec ac3 -ar 48000' 
    176     else: 
    177         return '-acodec mp2 -ac 2 -ar 44100' 
    178171 
    179172def getVideoBR(tsn = None): 
  • plugins/video/transcode.py

    r6299a29 r089c572  
    4747    settings = {} 
    4848    settings['audio_br'] = config.getAudioBR(tsn) 
    49     settings['audio_codec'] = config.getAudioCodec(tsn) 
     49    settings['audio_codec'] = select_audiocodec(inFile, tsn) 
    5050    settings['video_br'] = config.getVideoBR(tsn) 
    5151    settings['max_video_br'] = config.getMaxVideoBR() 
     
    6363    except: 
    6464        kill(ffmpeg.pid) 
    65         
     65 
     66def select_audiocodec(inFile, tsn = ''): 
     67    #check for HD tivo and return compatible audio parameters 
     68    type, width, height, fps, millisecs, kbps, akbps, acodec =  video_info(inFile) 
     69    if tsn and tsn[:3] in config.getHDtivos(): 
     70        if acodec == 'liba52': 
     71            if (inFile[-4:]).lower() == '.mkv': 
     72                return '-acodec copy' 
     73            elif not akbps == None and \ 
     74                 int(akbps) <= config.getMaxAudioBR(tsn): 
     75                return '-acodec copy' 
     76            else: 
     77                return '-acodec ac3 -ar 48000' 
     78        else: 
     79            return '-acodec ac3 -ar 48000' 
     80    else: 
     81        return '-acodec mp2 -ac 2 -ar 44100' 
     82 
    6683def select_aspect(inFile, tsn = ''): 
    6784    TIVO_WIDTH = config.getTivoWidth(tsn) 
    6885    TIVO_HEIGHT = config.getTivoHeight(tsn) 
    6986     
    70     type, width, height, fps, millisecs, kbps, akbps =  video_info(inFile) 
     87    type, width, height, fps, millisecs, kbps, akbps, acodec =  video_info(inFile) 
    7188 
    7289    debug_write(['tsn:', tsn, '\n']) 
     
    213230def tivo_compatable(inFile, tsn = ''): 
    214231    supportedModes = [[720, 480], [704, 480], [544, 480], [480, 480], [352, 480]] 
    215     type, width, height, fps, millisecs, kbps, akbps =  video_info(inFile) 
    216     #print type, width, height, fps, millisecs, kbps, akbps 
     232    type, width, height, fps, millisecs, kbps, akbps, acodec =  video_info(inFile) 
     233    #print type, width, height, fps, millisecs, kbps, akbps, acodec 
    217234 
    218235    if (inFile[-5:]).lower() == '.tivo': 
     
    261278 
    262279    if (inFile[-5:]).lower() == '.tivo': 
    263         info_cache[inFile] = (mtime, (True, True, True, True, True, True, True)) 
     280        info_cache[inFile] = (mtime, (True, True, True, True, True, True, True, True)) 
    264281        debug_write(['video_info: ', inFile, ' ends in .tivo.\n']) 
    265         return True, True, True, True, True, True, True 
     282        return True, True, True, True, True, True, True, True 
    266283 
    267284    cmd = [FFMPEG, '-i', inFile ]  
     
    276293    if ffmpeg.poll() == None: 
    277294        kill(ffmpeg.pid) 
    278         info_cache[inFile] = (mtime, (None, None, None, None, None, None, None)) 
    279         return None, None, None, None, None, None, None 
     295        info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None)) 
     296        return None, None, None, None, None, None, None, None 
    280297 
    281298    output = ffmpeg.stderr.read() 
     
    287304        codec = x.group(1) 
    288305    else: 
    289         info_cache[inFile] = (mtime, (None, None, None, None, None, None, None)) 
     306        info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None)) 
    290307        debug_write(['video_info: failed at codec\n']) 
    291         return None, None, None, None, None, None, None 
     308        return None, None, None, None, None, None, None, None 
    292309 
    293310    rezre = re.compile(r'.*Video: .+, (\d+)x(\d+)[, ].*') 
     
    297314        height = int(x.group(2)) 
    298315    else: 
    299         info_cache[inFile] = (mtime, (None, None, None, None, None, None, None)) 
     316        info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None)) 
    300317        debug_write(['video_info: failed at width/height\n']) 
    301         return None, None, None, None, None, None, None 
     318        return None, None, None, None, None, None, None, None 
    302319 
    303320    rezre = re.compile(r'.*Video: .+, (.+) (?:fps|tb).*') 
     
    306323        fps = x.group(1) 
    307324    else: 
    308         info_cache[inFile] = (mtime, (None, None, None, None, None, None, None)) 
     325        info_cache[inFile] = (mtime, (None, None, None, None, None, None, None, None)) 
    309326        debug_write(['video_info: failed at fps\n']) 
    310         return None, None, None, None, None, None, None 
     327        return None, None, None, None, None, None, None, None 
    311328 
    312329    # Allow override only if it is mpeg2 and frame rate was doubled to 59.94 
     
    351368        debug_write(['video_info: failed at akbps\n']) 
    352369 
    353     info_cache[inFile] = (mtime, (codec, width, height, fps, millisecs, kbps, akbps)) 
    354     debug_write(['video_info: Codec=', codec, ' width=', width, ' height=', height, ' fps=', fps, ' millisecs=', millisecs, ' kbps=', kbps, ' akbps=', akbps, '\n']) 
    355     return codec, width, height, fps, millisecs, kbps, akbps 
     370    #get audio codec of source for tivo compatibility test. 
     371    rezre = re.compile(r'.*Audio: ([^,]+),.*') 
     372    x = rezre.search(output) 
     373    if x: 
     374        acodec = x.group(1) 
     375    else: 
     376        acodec = None 
     377        debug_write(['video_info: failed at acodec\n']) 
     378 
     379    info_cache[inFile] = (mtime, (codec, width, height, fps, millisecs, kbps, akbps, acodec)) 
     380    debug_write(['video_info: Codec=', codec, ' width=', width, ' height=', height, ' fps=', fps, ' millisecs=', millisecs, ' kbps=', kbps, ' akbps=', akbps, ' acodec=', acodec, '\n']) 
     381    return codec, width, height, fps, millisecs, kbps, akbps, acodec 
    356382 
    357383def supported_format(inFile):