Changeset 303570adb60c9254c17bdf1410bc5ecc1f01c518

Show
Ignore:
Timestamp:
03/02/07 20:23:37 (2 years ago)
Author:
KRKeegan <KRKeegan>
git-committer:
KRKeegan <KRKeegan> 1172888617 +0000
git-parent:

[0a15a91bd6ea5f7bad6b35396fc28935c1da77db]

git-author:
KRKeegan <KRKeegan> 1172888617 +0000
Message:

- Added file size estimation
- Added stretch to ratio if within range
- Added left and right padding for videos that are too tall

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • README

    rb02cc7d r303570a  
    1 Ver 147 
     1---Changes 
     2- Transfer End Properly 
    23 
    3 ---Changes 
    4 - Duration has been added 
    5 so now the green bar on the bottom of the screen is accurate.  I thought this would help the deleting problem but it didn't. 
     4- File Sizes are estimated now. Sending 6gig estimates for a 400meg file caused TiVo to unnecessarily dump shows for space. New estimation will generally still be over but by a reasonable amount now. 
    65 
    7 - Single form of code 
    8 so now this works with no changes on linux and windows 
     6- Ratios are altered.  Filed that are almost 4:3 or 16:9 will be crammed into those formats, looks better on TV and streching image by less than 1% is not noticable. 
    97 
    10 - ffmpeg entry in config file 
    11 allows you to move ffmpeg and allows a single version of code for multiple platforms 
     8- Padding for videos that have a lower ratio than 4:3 is added. This allows for black bars on left and right for oddly shaped movies. 
    129 
    1310---Description 
     
    5249---Known Problems 
    5350 
    54 - Only one pyTivo server per network 
    55 GUID in beacons hardcoded. So only 1 server per network. This will be fixed soon. 
    56  
    57 - Max MPEG size 
    58 The max mpeg2 output size is 6000000000 bytes (hard coded in container.tmpl).  
    59 It seems that unlike sending photos and music when sending video the tivo needs to know the size of video before hand. So we lie and tell the tivo that it is 6000000000 bytes. The tivo will stop downloading when it hits this size. If the download stops before it it reaches what it thinks is the end it will try resuming the download (HTTP Range header). I return a 404 when the tivo trys to resume and it will give up. You may see an error when you reach the end of the file. 
    60  
    61 - Files delete before you watch them 
    62 Currently the only way to end a stream to the TiVo involves sending a 404. This is true for all transcoders currently.  Some people will see an error at the end of all of their streamed videos which says "Transfer Interrupted" this is only becuase TiVo thinks the file is larger than it is. 
    63 As a side effect of this some peoples videos will also delete before they watch them.  As far as I can tell the only way to keep a file is to play it all the way to the end as it is streaming to you.  If the file finishes streaming and you are not watchin it, it will delete itself before you watch it.   
    64 My only suggestion is to either pause the stream on the TiVo and turn off the TV and come back and watch it.  Or get a wired connection so that you can watch the streams live. 
    65  
    6651- Now Playing List disappears 
    6752This seems to be an error with the TiVo software.  But what happens is that the NPL is replaced with the directory listing of your pyTivo server.  Very odd. 
     
    6954 
    7055---Notes 
    71 Most of the work has been done by armooo.  Updates in this version were contributed by krkeegan. 
     56Most of the work has been done by armooo.  With minor updates by KRKeegan. 
  • plugins/video/templates/container.tmpl

    rb02cc7d r303570a  
    2929            <Title>#echo $escape('.'.join(file.split('.')[:-1])) #</Title> 
    3030            <ContentType>video/x-tivo-mpeg</ContentType> 
    31             <SourceFormat>video/x-tivo-mpeg</SourceFormat> 
    32             <SourceSize>6000000000</SourceSize> 
     31            <SourceFormat>video/x-ms-wmv</SourceFormat> 
     32            <SourceSize>$est_size($file)</SourceSize> 
    3333                <Duration>$duration($file)</Duration> 
    3434        </Details> 
  • plugins/video/transcode.py

    r32e2d9d r303570a  
    3131 
    3232def transcode(inFile, outFile): 
    33          
    34     print select_aspect(inFile) 
    35      
    3633    cmd = [FFMPEG, '-i', inFile, '-vcodec', 'mpeg2video', '-r', '29.97', '-b', '4096'] + select_aspect(inFile)  +  ['-comment', 'pyTivo.py', '-ac', '2', '-ab', '192', '-f', 'vob', '-' ]    
    3734    ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE) 
     
    4946     
    5047    d = gcd(height,width) 
    51  
     48    ratio = (width*100)/height 
    5249    rheight, rwidth = height/d, width/d 
    5350 
     
    5653    elif (rheight, rwidth) in [(16, 9), (20, 11), (40, 33), (118, 81), (59, 27)]: 
    5754        return ['-aspect', '16:9', '-s', '720x480'] 
    58 #    elif rwidth > rheight: 
     55    #If video is nearly 4:3 or 16:9 go ahead and strech it 
     56    elif ((ratio <= 141) and (ratio >= 125)): 
     57        return ['-aspect', '4:3', '-s', '720x480'] 
     58    elif ((ratio <= 185) and (ratio >= 169)): 
     59        return ['-aspect', '16:9', '-s', '720x480'] 
    5960    else: 
    6061        settings = [] 
    6162        settings.append('-aspect') 
    62         settings.append('16:9') 
     63        settings.append('4:3') 
     64        #If video is wider than 4:3 add top and bottom padding 
     65        if (ratio > 133): 
    6366       
    64         endHeight = (720*width)/height 
    65         if endHeight % 2: 
    66             endHeight -= 1 
     67            endHeight = (720*width)/height 
     68            if endHeight % 2: 
     69                endHeight -= 1 
    6770 
    68         settings.append('-s') 
    69         settings.append('720x' + str(endHeight)) 
     71            settings.append('-s') 
     72            settings.append('720x' + str(endHeight)) 
    7073 
    71         topPadding = ((480 - endHeight)/2) 
    72         if topPadding % 2: 
    73             topPadding -= 1 
     74            topPadding = ((480 - endHeight)/2) 
     75            if topPadding % 2: 
     76                topPadding -= 1 
     77             
     78            settings.append('-padtop') 
     79            settings.append(str(topPadding)) 
     80            bottomPadding = (480 - endHeight) - topPadding 
     81            settings.append('-padbottom') 
     82            settings.append(str(bottomPadding)) 
     83                 
     84            return settings 
     85        #If video is taller than 4:3 add left and right padding, this is rare 
     86        else: 
     87            endWidth = (480*width)/height 
     88            if endWidth % 2: 
     89                endWidth -= 1 
     90 
     91            settings.append('-s') 
     92            settings.append(str(endWidth) + 'x480') 
     93 
     94            leftPadding = ((720 - endWidth)/2) 
     95            if leftPadding % 2: 
     96                leftPadding -= 1 
    7497         
    75         settings.append('-padtop') 
    76         settings.append(str(topPadding)) 
    77         bottomPadding = (480 - endHeight) - topPadding 
    78         settings.append('-padbottom') 
    79         settings.append(str(bottomPadding)) 
    80              
    81         return settings 
    82 #    else: 
    83         #hope for the best 
    84 #        return ['-aspect', '4:3', '-s', '720x480'] 
     98            settings.append('-padleft') 
     99            settings.append(str(leftPadding)) 
     100            rightPadding = (720 - endWidth) - leftPadding 
     101            settings.append('-padright') 
     102            settings.append(str(rightPadding))             
     103            return settings 
    85104 
    86105def tivo_compatable(inFile): 
  • plugins/video/video.py

    r0a15a91 r303570a  
    5353            return self.playable_cache[full_path] 
    5454 
     55        def est_size(file): 
     56            #Size is estimated by taking audio and video bit rate adding 2% 
     57            return int((duration(file)/1000)*((4288 * 1.02 * 1000)/8)) 
     58 
    5559        def VideoFileFilter(file): 
    5660            full_path = os.path.join(path, file) 
     
    7579        t.files, t.total, t.start = self.get_files(handler, query, VideoFileFilter) 
    7680        t.duration = duration 
     81        t.est_size = est_size 
    7782        t.isdir = isdir 
    7883        t.quote = quote