Changeset e2bcd2e8e1fa28372559b26d56ab76093b7daf38

Show
Ignore:
Timestamp:
11/26/06 22:08:54 (2 years ago)
Author:
Jason Michalski <armooo@armooo.net>
git-committer:
Jason Michalski <armooo@armooo.net> 1164600534 +0000
git-parent:

[2f262c09f2bf3a40e98bfa749b3458ec1e4304ed]

git-author:
Jason Michalski <armooo@armooo.net> 1164600534 +0000
Message:

pyTivo
- Linux suport added (need to change the ffmpeg path)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • httpserver.py

    r2f262c0 re2bcd2e  
    1111class TivoHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): 
    1212    containers = {} 
     13     
     14    def __init__(self, server_address, RequestHandlerClass): 
     15        BaseHTTPServer.HTTPServer.__init__(self, server_address, RequestHandlerClass) 
     16        self.daemon_threads = True 
    1317 
    1418    def add_container(self, name, type, path): 
  • pyTivo.conf

    r1bb8693 re2bcd2e  
    44[Video] 
    55type=x-container/tivo-videos 
    6 path=D:\video 
     6path=/home/armooo/videos 
    77 
    88[test] 
  • pyTivo.py

    re250e35 re2bcd2e  
    1 import beacon, httpserver, ConfigParser, os 
     1import beacon, httpserver, ConfigParser, os, sys 
    22 
    33config = ConfigParser.ConfigParser() 
  • transcode.py

    re81510c re2bcd2e  
    22 
    33SCRIPTDIR = os.path.dirname(__file__) 
     4FFMPEG = '/usr/bin/ffmpeg' 
    45 
    56# XXX BIG HACK 
     
    2728def transcode(inFile, outFile): 
    2829 
    29     cmd = SCRIPTDIR + "\\ffmpeg_mp2.exe -i \"%s\" -vcodec mpeg2video -r 29.97 -b 4096 %s -ac 2 -ab 192 -f vob -" % (inFile, select_aspect(inFile)) 
    30     # subprocess is busted in my python 2.5 when run without a console. Setting all to PIPE fixes it. 
    31     # but now we get this nice select loop to dump the stderr data 
     30    cmd = "%s -i \"%s\" -vcodec mpeg2video -r 29.97 -b 4096 %s -ac 2 -ab 192 -f vob -" % (FFMPEG, inFile, select_aspect(inFile)) 
     31    cmd = [FFMPEG, '-i', inFile, '-vcodec', 'mpeg2video', '-r', '29.97', '-b', '4096'] + select_aspect(inFile)  +  ['-ac', '2', '-ab', '192', '-f', 'vob', '-' ]    
     32 
     33    print cmd 
     34  
    3235    ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE) 
    3336    try: 
     
    4447 
    4548    if (rheight, rwidth) in [(4, 3), (10, 11), (15, 11), (59, 54), (59, 72), (59, 36), (59, 54)]: 
    46         return '-aspect 4:3 -s 720x480' 
     49        return ['-aspect', '4:3', '-s', '720x480'] 
    4750    elif (rheight, rwidth) in [(16, 9), (20, 11), (40, 33), (118, 81), (59, 27)]: 
    48         return '-aspect 16:9 -s 720x480' 
     51        return ['-aspect', '16:9', '-s', '720x480'] 
    4952    else: 
    5053        settings = [] 
    51         settings.append('-aspect 16:9') 
     54        settings.append('-aspect') 
     55        settings.append('16:9') 
    5256       
    5357        endHeight = (720*width)/height 
     
    5559            endHeight -= 1 
    5660 
    57         settings.append('-s 720x' + str(endHeight)) 
     61        settings.append('-s') 
     62        settings.append('720x' + str(endHeight)) 
    5863 
    5964        topPadding = ((480 - endHeight)/2) 
     
    6166            topPadding -= 1 
    6267         
    63         settings.append('-padtop ' + str(topPadding)) 
     68        settings.append('-padtop') 
     69        settings.append(str(topPadding)) 
    6470        bottomPadding = (480 - endHeight) - topPadding 
    65         settings.append('-padbottom ' + str(bottomPadding)) 
     71        settings.append('-padbottom') 
     72        settings.append(str(bottomPadding)) 
    6673             
    67         return ' '.join(settings) 
     74        return settings 
    6875 
    6976def tivo_compatable(inFile): 
     
    8390 
    8491def video_info(inFile): 
    85     cmd = SCRIPTDIR + "\\ffmpeg_mp2.exe -i \"%s\"" % inFile 
     92    cmd = [FFMPEG, '-i', inFile ]  
    8693    ffmpeg = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE) 
    8794    output = ffmpeg.stderr.read()