Changeset 303570adb60c9254c17bdf1410bc5ecc1f01c518
- 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
| rb02cc7d |
r303570a |
|
| 1 | | Ver 147 |
|---|
| | 1 | ---Changes |
|---|
| | 2 | - Transfer End Properly |
|---|
| 2 | 3 | |
|---|
| 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. |
|---|
| 6 | 5 | |
|---|
| 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. |
|---|
| 9 | 7 | |
|---|
| 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. |
|---|
| 12 | 9 | |
|---|
| 13 | 10 | ---Description |
|---|
| … | … | |
| 52 | 49 | ---Known Problems |
|---|
| 53 | 50 | |
|---|
| 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 | | |
|---|
| 66 | 51 | - Now Playing List disappears |
|---|
| 67 | 52 | This 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. |
|---|
| … | … | |
| 69 | 54 | |
|---|
| 70 | 55 | ---Notes |
|---|
| 71 | | Most of the work has been done by armooo. Updates in this version were contributed by krkeegan. |
|---|
| | 56 | Most of the work has been done by armooo. With minor updates by KRKeegan. |
|---|
| rb02cc7d |
r303570a |
|
| 29 | 29 | <Title>#echo $escape('.'.join(file.split('.')[:-1])) #</Title> |
|---|
| 30 | 30 | <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> |
|---|
| 33 | 33 | <Duration>$duration($file)</Duration> |
|---|
| 34 | 34 | </Details> |
|---|
| r32e2d9d |
r303570a |
|
| 31 | 31 | |
|---|
| 32 | 32 | def transcode(inFile, outFile): |
|---|
| 33 | | |
|---|
| 34 | | print select_aspect(inFile) |
|---|
| 35 | | |
|---|
| 36 | 33 | cmd = [FFMPEG, '-i', inFile, '-vcodec', 'mpeg2video', '-r', '29.97', '-b', '4096'] + select_aspect(inFile) + ['-comment', 'pyTivo.py', '-ac', '2', '-ab', '192', '-f', 'vob', '-' ] |
|---|
| 37 | 34 | ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
|---|
| … | … | |
| 49 | 46 | |
|---|
| 50 | 47 | d = gcd(height,width) |
|---|
| 51 | | |
|---|
| | 48 | ratio = (width*100)/height |
|---|
| 52 | 49 | rheight, rwidth = height/d, width/d |
|---|
| 53 | 50 | |
|---|
| … | … | |
| 56 | 53 | elif (rheight, rwidth) in [(16, 9), (20, 11), (40, 33), (118, 81), (59, 27)]: |
|---|
| 57 | 54 | 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'] |
|---|
| 59 | 60 | else: |
|---|
| 60 | 61 | settings = [] |
|---|
| 61 | 62 | 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): |
|---|
| 63 | 66 | |
|---|
| 64 | | endHeight = (720*width)/height |
|---|
| 65 | | if endHeight % 2: |
|---|
| 66 | | endHeight -= 1 |
|---|
| | 67 | endHeight = (720*width)/height |
|---|
| | 68 | if endHeight % 2: |
|---|
| | 69 | endHeight -= 1 |
|---|
| 67 | 70 | |
|---|
| 68 | | settings.append('-s') |
|---|
| 69 | | settings.append('720x' + str(endHeight)) |
|---|
| | 71 | settings.append('-s') |
|---|
| | 72 | settings.append('720x' + str(endHeight)) |
|---|
| 70 | 73 | |
|---|
| 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 |
|---|
| 74 | 97 | |
|---|
| 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 |
|---|
| 85 | 104 | |
|---|
| 86 | 105 | def tivo_compatable(inFile): |
|---|
| r0a15a91 |
r303570a |
|
| 53 | 53 | return self.playable_cache[full_path] |
|---|
| 54 | 54 | |
|---|
| | 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 | |
|---|
| 55 | 59 | def VideoFileFilter(file): |
|---|
| 56 | 60 | full_path = os.path.join(path, file) |
|---|
| … | … | |
| 75 | 79 | t.files, t.total, t.start = self.get_files(handler, query, VideoFileFilter) |
|---|
| 76 | 80 | t.duration = duration |
|---|
| | 81 | t.est_size = est_size |
|---|
| 77 | 82 | t.isdir = isdir |
|---|
| 78 | 83 | t.quote = quote |
|---|