Changeset e2bcd2e8e1fa28372559b26d56ab76093b7daf38
- 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
| r2f262c0 |
re2bcd2e |
|
| 11 | 11 | class TivoHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): |
|---|
| 12 | 12 | containers = {} |
|---|
| | 13 | |
|---|
| | 14 | def __init__(self, server_address, RequestHandlerClass): |
|---|
| | 15 | BaseHTTPServer.HTTPServer.__init__(self, server_address, RequestHandlerClass) |
|---|
| | 16 | self.daemon_threads = True |
|---|
| 13 | 17 | |
|---|
| 14 | 18 | def add_container(self, name, type, path): |
|---|
| r1bb8693 |
re2bcd2e |
|
| 4 | 4 | [Video] |
|---|
| 5 | 5 | type=x-container/tivo-videos |
|---|
| 6 | | path=D:\video |
|---|
| | 6 | path=/home/armooo/videos |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | [test] |
|---|
| re250e35 |
re2bcd2e |
|
| 1 | | import beacon, httpserver, ConfigParser, os |
|---|
| | 1 | import beacon, httpserver, ConfigParser, os, sys |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | config = ConfigParser.ConfigParser() |
|---|
| re81510c |
re2bcd2e |
|
| 2 | 2 | |
|---|
| 3 | 3 | SCRIPTDIR = os.path.dirname(__file__) |
|---|
| | 4 | FFMPEG = '/usr/bin/ffmpeg' |
|---|
| 4 | 5 | |
|---|
| 5 | 6 | # XXX BIG HACK |
|---|
| … | … | |
| 27 | 28 | def transcode(inFile, outFile): |
|---|
| 28 | 29 | |
|---|
| 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 | |
|---|
| 32 | 35 | ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
|---|
| 33 | 36 | try: |
|---|
| … | … | |
| 44 | 47 | |
|---|
| 45 | 48 | 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'] |
|---|
| 47 | 50 | 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'] |
|---|
| 49 | 52 | else: |
|---|
| 50 | 53 | settings = [] |
|---|
| 51 | | settings.append('-aspect 16:9') |
|---|
| | 54 | settings.append('-aspect') |
|---|
| | 55 | settings.append('16:9') |
|---|
| 52 | 56 | |
|---|
| 53 | 57 | endHeight = (720*width)/height |
|---|
| … | … | |
| 55 | 59 | endHeight -= 1 |
|---|
| 56 | 60 | |
|---|
| 57 | | settings.append('-s 720x' + str(endHeight)) |
|---|
| | 61 | settings.append('-s') |
|---|
| | 62 | settings.append('720x' + str(endHeight)) |
|---|
| 58 | 63 | |
|---|
| 59 | 64 | topPadding = ((480 - endHeight)/2) |
|---|
| … | … | |
| 61 | 66 | topPadding -= 1 |
|---|
| 62 | 67 | |
|---|
| 63 | | settings.append('-padtop ' + str(topPadding)) |
|---|
| | 68 | settings.append('-padtop') |
|---|
| | 69 | settings.append(str(topPadding)) |
|---|
| 64 | 70 | bottomPadding = (480 - endHeight) - topPadding |
|---|
| 65 | | settings.append('-padbottom ' + str(bottomPadding)) |
|---|
| | 71 | settings.append('-padbottom') |
|---|
| | 72 | settings.append(str(bottomPadding)) |
|---|
| 66 | 73 | |
|---|
| 67 | | return ' '.join(settings) |
|---|
| | 74 | return settings |
|---|
| 68 | 75 | |
|---|
| 69 | 76 | def tivo_compatable(inFile): |
|---|
| … | … | |
| 83 | 90 | |
|---|
| 84 | 91 | def video_info(inFile): |
|---|
| 85 | | cmd = SCRIPTDIR + "\\ffmpeg_mp2.exe -i \"%s\"" % inFile |
|---|
| | 92 | cmd = [FFMPEG, '-i', inFile ] |
|---|
| 86 | 93 | ffmpeg = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE) |
|---|
| 87 | 94 | output = ffmpeg.stderr.read() |
|---|