1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

pyTivo - Transcoding server

Discussion in 'TiVo Home Media Features & TiVoToGo' started by armooo, Nov 25, 2006.

  1. May 6, 2007 #441 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    I wouldn't be too quick to blame it on pyTivo. Take one of the longer VOB's, rename it with a .mpg extension and see if it will go back using Tivo-go-back, i.e., not using pyTivo. You could also try it without renaming, just to see what happens.

    From your debug file I can see that pyTivo is identifying it as tivo-compatible and should be just directly transfering it without transcoding. (Of course it has to be showing on the NPL, and selected for viewing, before this can happen.) Thus I suspect the problem is the TiVo's choking on VOB files. (AFAIK it doesn't say anywhere that VOB's are TiVo-compatible.) This will show during a go-back transfer too.

    Where were the errors thrown? (Tivo or PC?) Did They occur before you even selected a file from NPL to view?
     
  2. May 6, 2007 #442 of 5683
    Tobashadow

    Tobashadow Read over there --->

    2,339
    0
    Nov 11, 2006
    Neither machine would even show a folder with even one .vob file in it.

    But renaming it to mpeg the tivo compatatible one worked.
     
  3. May 6, 2007 #443 of 5683
    1up

    1up New Member

    11
    0
    Apr 22, 2007
    dlfl, ocntscha & Tobashadow: Thanks for your replies everyone, they're much appreciated.

    I've been trying to post a reply for the past half an hour now, but can't because I keep getting the following error message when trying to post anything:
    But I have no image calls nor any links in my post. I do have a bunch of windows paths from the error logs (but I don't even know what's the offending item!). I've tried enclosing all periods (.) in brackets [], but that didn't work. Aggravating :mad:
     
  4. May 6, 2007 #444 of 5683
    1up

    1up New Member

    11
    0
    Apr 22, 2007
    I'm using pyTivo v1.91. I know that transcoding isn't required for the video portion of a vob, but I thought it was required for the audio portion (if I'm correct in thinking that the audio portion of DVD vob files are encoded as AC3 and my non-DVD Series 2 Tivo needs it to be encoded as mpeg-1 layer-2). Whether I'm correct or not, as you say, pyTivo should be either transcoding (if required) or simply streaming whichever .vob file I try to play from my Tivo. The 2 lines from my debug.txt file that would point me to a solution seem to be:
    Code:
    Must supply at least one output file
     
    video_info: Bug in VideoReDo
    Like you all said, it should be working...

    I just joined the vob files into one large mpg and tried again, but I got the same error messages in the debug log. The file plays fine in VLC, Windows Media Player, & PowerDVD.
     
  5. May 6, 2007 #445 of 5683
    1up

    1up New Member

    11
    0
    Apr 22, 2007
    Here's some error info from the Windows/DOS command window after getting the error message on the Tivo. (I don't have pyTivo starting automatically as a service, so pyTivo.py starts in a command window.)
    Code:
    Exception happened during processing of request from ('10.0.0.10', 1743)
    Traceback (most recent call last):
      File "C:\Program Files\Python25\lib\SocketServer.py", line 464, in process_request_thread
        self.finish_request(request, client_address)
      File "C:\Program Files\Python25\lib\SocketServer.py", line 254, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "C:\Program Files\Python25\lib\SocketServer.py", line 522, in __init__
        self.handle()
      File "C:\Program Files\Python25\lib\BaseHTTPServer.py", line 316, in handle
        self.handle_one_request()
      File "C:\Program Files\Python25\lib\BaseHTTPServer.py", line 310, in handle_one_request
        method()
      File "C:\Program Files\pyTivo\httpserver.py", line 36, in do_GET
        plugin.SendFile(self, container, name)
      File "C:\Program Files\pyTivo\plugins\video\video.py", line 36, in SendFile
        transcode.output_video(container['path'] + path[len(name)+1:], handler.wfile, tsn)
      File "C:\Program Files\pyTivo\plugins\video\transcode.py", line 41, in output_video
        shutil.copyfileobj(f, outFile)
      File "C:\Program Files\Python25\lib\shutil.py", line 24, in copyfileobj
        fdst.write(buf)
      File "C:\Program Files\Python25\lib\socket.py", line 262, in write
        self.flush()
      File "C:\Program Files\Python25\lib\socket.py", line 249, in flush
        self._sock.sendall(buffer)
    error: (10054, 'Connection reset by peer')
    
     
  6. May 6, 2007 #446 of 5683
    1up

    1up New Member

    11
    0
    Apr 22, 2007
    dlfl, thanks for the tips. The errors were originally thrown on both the Tivo & the PC. The Tivo said there was a problem & wouldn't show any of the files in the folder that contained the vobs. I then checked the PC & found the errors I posted above. After I joined the vobs into one large .mpg file and moved it into it's own directory, it showed up in the Tivo NPL (technically, just showing as available on the PC Server), but after trying to watch it I got an error on the Tivo. The PC showed the same error messages in the debug file as posted above.

    BTW, as I said, this worked fine earlier this week with Tivo.net. It not only showed the vobs, but I could even watch them on the Tivo without a problem. So I'm pretty sure this is a problem with pyTivo.
     
  7. May 6, 2007 #447 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    OK, here's a theory:
    The reason these files work on TDN is because it IS transcoding them. Although the specs used by pyTivo to define a TiVo compatible file are all met, there is still something about the VOB's that chokes the Tivo, so they need ffmpeg to re-encode (transcode) them.

    So, let's test this -- if you're willing to insert three lines of code into transcode.py:

    Code:
    def tivo_compatable(inFile):
        suportedModes = [[720, 480], [704, 480], [544, 480], [480, 480], [352, 480]]
        type, width, height, fps, millisecs =  video_info(inFile)
        #print type, width, height, fps, millisecs
    [COLOR=Blue]
        if (inFile[-4:]).lower() == '.vob':
            debug_write(['tivo_compatible: ', inFile, ' is .vob, will transcode\n'])
            return False[/COLOR]
    
        if (inFile[-5:]).lower() == '.tivo':
            debug_write(['tivo_compatible: ', inFile, ' ends with .tivo\n'])
            return True
    The additional three lines are shown in blue. This is in function tivo_compatable () and I've included the lines before and after so you can orient yourself. Warning: Indentation is of critical importance in Python. The inserted "if" line should be indented exactly like the next "if" line. The two lines following the "if" line should be indented equally, i.e., 4 spaces more.

    This will force pyTivo to transcode any file with a .vob extension. If my theory is correct, this will make your .vob's work OK with pyTiVo. (If not I'll give you a complete refund :rolleyes: ).
     
  8. May 6, 2007 #448 of 5683
    hakukaji

    hakukaji New Member

    9
    0
    Dec 6, 2004
    I have to say I love pyTivo. Im a HUGE fan of both python and Tivo :) I was wondering if you want/need any help. I've been programming in python for a few years now. I could try creating a gui in wxpython if you are interested. :D AWESOME JOB THOUGH! :eek:
     
  9. May 7, 2007 #449 of 5683
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Help is always graciously accepted. Anything you want to contribute is more than welcome.

    Kevin
     
  10. May 7, 2007 #450 of 5683
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Help is always appreciated. Anything you want to contribute would be graciously accepted.

    Kevin
     
  11. May 7, 2007 #451 of 5683
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    I think I am 95% finished with a solution to the 8.3 issues. So far I have been able to craft a solution that allows browsing through as many folders as you like without any major functionailty changes. The only difference is that each folder may take an additional half second to load.

    Tonight I was able to browse 7 levels deep into a folder and come back with no problems.

    The only remaining issue is that if I try and play any files in a subfolder TiVo restarts :eek: . Not exactly a highly requested feature. I think this is just a small problem that can be solved tomorrow, but I am just too tired to keep dealing with the 5 minute restart of my TiVo any more tonight.

    Hopefully tomorrow I will have it completed. **Fingers Crossed**

    Kevin
     
  12. May 7, 2007 #452 of 5683
    Tobashadow

    Tobashadow Read over there --->

    2,339
    0
    Nov 11, 2006
    Thanks for the effort!

    As slow as my tivo's reboot i can only imagine the pain of multiple's in one day.

    Heck i almost shipped back my first one becasue it had to restart 3 times during setup and each one was a 5-10 min affair. Then that same evening i got a upgrade and it took a hour.
     
  13. May 7, 2007 #453 of 5683
    ScaryMike

    ScaryMike New Member

    205
    0
    Aug 23, 2002
    Madison, WI
    Hey, I just wanted to put a big thank you out there as well. It is really appreciated.

    -Mike
     
  14. May 7, 2007 #454 of 5683
    1up

    1up New Member

    11
    0
    Apr 22, 2007
    Works great! Thanks dlfl.

    Maybe you (or anyone else) can help me with one other thing: pyTivo isn't padding the top & bottom of transcoded video enough. My TV is a 4:3 and the vob I'm watching is 720x480. Parts of the left & right sides of the video are beyond the TV screen with just a little bit of black padding at the top & bottom of the screen. I've tried playing with the settings in transcode.py and the settings in pyTivo.conf, but without success.
    4:3 ratio = 1.333333
    640*480 ratio = 1.333333
    16:9 ratio = 1.777777
    720*480 ratio = 1.5
    In the pyTivo.py command window:
    Code:
    Seems stream 0 codec frame rate differs from container frame rate: 29.97 (30000/1001) -> 59.94 (60000/1001)
    Input #0, mpeg, from 'Z:\avi/broken.vob':
      Duration: 02:14:27.2, start: 0.280633, bitrate: 6418 kb/s
      Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x480, 9800 kb/s, 59.94 fps(r)
      Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5:1, 448 kb/s
      Stream #0.2[0x81]: Audio: ac3, 48000 Hz, 5:1, 384 kb/s
      Stream #0.3[0x20]: Subtitle: dvdsub
    [B]Output[/B] #0, vob, to 'pipe:':
      Stream #0.0: Video: mpeg2video, yuv420p, [B]704x480[/B], q=2-31, 3072 kb/s, 29.97 fps(c)
      Stream #0.1: Audio: mp2, 44100 Hz, stereo, 192 kb/s
    The debug.txt file shows:
    Code:
    aspect169: False 
    select_aspect: File= Z:\avi/broken.vob  Type= mpeg2video  width= 720  height= 480  
    fps= 29.97  millisecs= 8067200  ratio= 150  rheight= 2  rwidth= 3 
    select_aspect: File is wider than 4:3 padding top and bottom
     -aspect 4:3 -s 704x426 -padtop 26 -padbottom 28 
    [B]transcode: ffmpeg[/B] command is  c:\Program Files\pyTivo\plugins\video\ffmpeg_mp2.exe
    -iZ:\avi/broken.vob-vcodecmpeg2video-r29.97-b3072K
    [B]-aspect4:3-s704x426-padtop26-padbottom28[/B]-commentpyTivo.py-ac2-ab192K-ar44100-fvob-
    In pyTivo.conf I tried changing aspect169 to true & then to false and also tried changing the width= to 640 & height= to 480, but no joy. I think I probably need to alter the transcode.py file, but can't quite figure it out (not a programmer). Specifically, the section with
    Code:
                else: #this is a 4:3 file or 16:9 output not allowed
                    settings.append('-aspect')
                    settings.append('4:3')
                    endHeight = int(((TIVO_WIDTH*height)/width) * multiplier4by3)
                    if endHeight % 2:
                        endHeight -= 1
    I don't know how the "if endHeight % 2:" is interpreted, but I think that's the key to the problem. Any ideas on how to pad the top & bottom more for videos that are 720*480 so that I can see the entire 720 width of the video?
     
  15. May 7, 2007 #455 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    1up,

    Glad the .vob fix worked! (It's nice to have a theory confirmed now and then!)

    You have now encountered the infamous "Aspect Ratio" issue. If you search this thread for "aspect", you will see it's not a new one. First I believe there is a relatively simple solution (involving a few more lines added to transcode.py) but I won't be able to do it until a few hours from now.

    Basically, there is "Display AR" (DAR) and encoding AR or frame AR (FAR). If they are the same, the pixels are said to be square (pixel AR or PAR = 1:1). In general pixels are NOT square for mpegs (or vobs). Typically a 720x480 FAR will be used in all cases but displayed as either 640x480 (4:3) or 853x480 (16:9). There is a value in the mpeg (vob) file that tells the display system what the DAR (or equivalently the PAR) is so it knows how to stretch or shrink the pixels horizontally.

    Unfortunately there is no way to get DAR or PAR from ffmpeg, which pyTivo uses to get info about a video file. Thus pyTivo makes the assumption of square pixels, i.e., DAR = FAR (at least in most cases). The input video was 720x480 (FAR) and you had your config AR (actually it is the DAR) set to 4:3. pyTivo assumes square pixels so your desired DAR is 1.5:1. To get that DAR it must put in the padtop and padbottom parameters you see in the debug file ffmpeg command line. The calculation is based on a 640 display width, so a height of 2/3 of 640 or 426 pixels is needed. If you subtract your top and bottom paddings from 480 that is what you get, and what you see in the -s (size) option of the ffmpeg command line.

    I think the fix is just to put an if statement near the top of function select_aspect () to detect the file extension of ".vob" (just like my previous patch) and just set the aspect to whatever you have selected (4:3 or 16:9) and set the width and height to whatever you have in your config file (or the defaults) , called TIVO_WIDTH and TIVO_HEIGHT in this function.

    For TiVo compatible mpeg2's this issue doesn't arise because they are not re-encoded with ffmpeg and thus this function isn't even called.
     
  16. May 7, 2007 #456 of 5683
    hakukaji

    hakukaji New Member

    9
    0
    Dec 6, 2004
    Awesome, well im about to wrap up a project, and when that's done, Im going to try and craft up some sweet gui action. :eek:
     
  17. May 7, 2007 #457 of 5683
    johnkfisher

    johnkfisher New Member

    18
    0
    May 7, 2006
    I think we can all live with that :D

    Heh, details, details.

    As ws said by someone else earlier, great news, can't thank you enough :)
     
  18. May 7, 2007 #458 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Try this mod to transcode.py in the select_aspect function:

    Code:
        d = gcd(height,width)
        ratio = (width*100)/height
        rheight, rwidth = height/d, width/d
    
        debug_write(['select_aspect: File=', inFile, ' Type=', type, ' width=', width, ' height=', height, ' fps=', fps, ' millisecs=', millisecs, ' ratio=', ratio, ' rheight=', rheight, ' rwidth=', rwidth, '\n'])
    [COLOR=Red]    
        if (inFile[-4:]).lower() == '.vob':
            if aspect169:
                debug_write(['select_aspect: File is VOB, using 16:9 based on config\n'])
                return ['-aspect', '16:9', '-s', str(TIVO_WIDTH) + 'x' + str(TIVO_HEIGHT)]
            else:
                debug_write(['select_aspect: File is VOB, using 4:3 based on config\n'])
                return ['-aspect', '4:3', '-s', str(TIVO_WIDTH) + 'x' + str(TIVO_HEIGHT)][/COLOR] 
    
        multiplier16by9 = (16.0 * TIVO_HEIGHT) / (9.0 * TIVO_WIDTH)
        multiplier4by3  =  (4.0 * TIVO_HEIGHT) / (3.0 * TIVO_WIDTH)
    (Mods in red.) Be sure your config is set for the AR you want.
     
  19. May 7, 2007 #459 of 5683
    1up

    1up New Member

    11
    0
    Apr 22, 2007
    dlfl, thanks for taking the time to help out & for writing the detailed instructions, but your suggestion didn't quite work. After your mod, the video is taking up the full height of the TV screen (480), but the video is still coming out of pyTivo as 704 pixels in height. I think I want 720x426 (instead of 704x426) - both of which are later padded to be 7--x480.

    The main thing I wanted was to get the entire 720 width, but it's still coming out as 704 pixels - actually, I think it might really be less than that on the TV screen. Debug log:
    Code:
    video_info: Bug in VideoReDo
    video_info: Codec= mpeg2video  width= 720  height= 480  
    fps= 29.97  millisecs= 8067200 
    tivo_compatible:  Z:\avi/broken.vob  is .vob, will transcode
    output_video:  Z:\avi/broken.vob  is not tivo compatible
    video_info:  Z:\avi/broken.vob  cache hit! 
    tsn: 5400001707D0BF8 
    aspect169: False 
    select_aspect: File= Z:\avi/broken.vob  Type= mpeg2video  width= 720  
    height= 480  fps= 29.97  millisecs= 8067200  ratio= 150  rheight= 2  rwidth= 3 
    select_aspect: File is VOB, using 4:3 based on config
    transcode: ffmpeg command is  c:\Program Files\pyTivo\plugins\video\ffmpeg_mp2.exe
    -iZ:\avi/broken.vob-vcodecmpeg2video-r29.97-b3072K-aspect4:3-s704x480-commentpyTivo.py-ac2-ab192K-ar44100-fvob- 
    pyTivo.py command window:
    Code:
    Seems stream 0 codec frame rate differs from container frame rate: 29.97 (30000/1001) -> 59.94 (60000/1001)
    Input #0, mpeg, from 'Z:\avi/broken.vob':
      Duration: 02:14:27.2, start: 0.280633, bitrate: 6418 kb/s
      Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x480, 9800 kb/s, 59.94 fps(r)
      Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5:1, 448 kb/s
      Stream #0.2[0x81]: Audio: ac3, 48000 Hz, 5:1, 384 kb/s
      Stream #0.3[0x20]: Subtitle: dvdsub
    Output #0, vob, to 'pipe:':
      Stream #0.0: Video: mpeg2video, yuv420p, 704x480, q=2-31, 3072 kb/s, 29.97 fps(c)
      Stream #0.1: Audio: mp2, 44100 Hz, stereo, 192 kb/s
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #0.1 -> #0.1
    No accelerated IMDCT transform found
    I then spent the last few hours trying to play with the transcode settings (without your latest mod), but without success. The part I specifically kept playing with was:
    Code:
                else: #this is a 4:3 file or 16:9 output not allowed
                    settings.append('-aspect')
                    settings.append('4:3')
                    endHeight = int(((TIVO_WIDTH*height)/width) * multiplier4by3)
                    if endHeight % 2:
                        endHeight -= 1
                    if endHeight < TIVO_HEIGHT * 0.99:
                        settings.append('-s')
                        settings.append(str(TIVO_WIDTH [B][COLOR=Red]+ 16[/COLOR][/B]) + 'x' + str(endHeight[B][COLOR=Red]-20[/COLOR][/B]))
    
                        topPadding = ((TIVO_HEIGHT - endHeight)/2)
                        if topPadding % 2:
                            topPadding -= 1
                        
                        settings.append('-padtop')
                        settings.append(str(topPadding[B][COLOR=Red]+10[/COLOR][/B]))
                        bottomPadding = (TIVO_HEIGHT - endHeight) - topPadding
                        settings.append('-padbottom')
                        settings.append(str(bottomPadding[B][COLOR=Red]+10[/COLOR][/B]))
                    else:   #if only very small amount of padding needed, then just stretch it
                        settings.append('-s')
                        settings.append(str(TIVO_WIDTH) + 'x' + str(TIVO_HEIGHT))
                    debug_write(['select_aspect: File is wider than 4:3 padding top and bottom\n', ' '.join(settings), '\n'])
    
    I was able to get the output to be 720 pixels, but it made no difference on the TV screen, it still didn't show the complete width of the actual DVD video. :confused: Here's the result I got with the last set of mods:
    Code:
    aspect169: False 
    select_aspect: File= Z:\avi/broken.vob  Type= mpeg2video  width= 720  
    height= 480  fps= 29.97  millisecs= 8067200  ratio= 150  rheight= 2  rwidth= 3 
    select_aspect: File is wider than 4:3 padding top and bottom
     -aspect 4:3 -s 720x406 -padtop 36 -padbottom 38 
    transcode: ffmpeg command is  c:\Program Files\pyTivo\plugins\video\ffmpeg_mp2.exe
    -iZ:\avi/broken.vob-vcodecmpeg2video-r29.97-b3072K-aspect4:3-s720x406-padtop36-padbottom38-commentpyTivo.py-ac2-ab192K-ar44100-fvob- 
    kill: killing pid= 1356 
    As you can tell, I don't know what I'm talking about here! :D Any other ideas?
     
  20. May 7, 2007 #460 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    1up,
    I infer that from the 704 width in the ffmpeg output stream that you had width=704 in your pyTivo.conf file, correct? If so, try the transcode.py with my mods but with width set to 544, or just delete the width= line. Using width=720 may also work but try 544 first.

    Other than that, I can see no possible problem with the video and audio output streams from ffmpeg. In fact the 704 width does not cause a width problem on my S2 DT. My only thought is that I see from your tsn (540xxxx....) that this was going to your S2 and it's possible it doesn't handle the 704 width correctly. Different models will handle a different subset of the recommended widths in the distributed pyTivo.conf file comments. 544 was determined by experimentation to be most compatible with most tivo models.

    When you use a width that is compatible with your TiVo model (whether it is 480, 544, 720 or whatever), the TiVo knows from the (Display) AR encoded in the file (4:3 in this case) that that width needs to be spread across the full width of your screen (corresponding to a 640x480 display in this case).

    Good luck. Other than this, I can't think of anything else for the moment.
     

Share This Page