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. Apr 18, 2007 #321 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    This sounds like one of the "known issues" described in the Wiki, and apparently you have a fourth work-around.
     
  2. Apr 18, 2007 #322 of 5683
    mkleiman

    mkleiman New Member

    10
    0
    Mar 8, 2007
    The new subfolders problem with 8.3 is unrelated to the problem you describe, and is not fixed by this behavior. This was already discussed above.
     
  3. Apr 18, 2007 #323 of 5683
    jwreiner

    jwreiner New Member

    82
    0
    Aug 19, 2003
    Connecticut
    My understanding is that pytivo doesn't re-encode what it thinks are TiVo compliant videos. Is there a way to force it to do so?

    I have two reasons for wanting this. One, I have a 540 TiVo which doesn't like 16:9 mpegs, so I'd like pytivo to transcode it to 4:3. Yes, I could do this myself and have a 16:9 version of the file and a 4:3 version, but it would be nice to have just one file and be able to skip the manual conversion step.

    Two, transcoding to a lower bitrate allows streaming to the TiVo more quickly.

    If I am misunderstanding the cause of the problems with the 16:9 file, please let me know. It looks fine on the computer, but on the TiVo, the video is identifiable, but messed up.
     
  4. Apr 19, 2007 #324 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Try this:

    Save a copy of Transcode.py under a different name.

    Edit transcode.py substituting this replacement function:
    Code:
    def tivo_compatable(inFile):
        if (inFile[-5:]).lower() == '.tivo':
            debug_write(['tivo_compatible: ', inFile, ' ends with .tivo\n'])
            return True
        return False
    Warning: Indentation matters -- match the above.

    Now any file that doesn't have the .tivo extension will be re-encoded.

    Of course the settings in pyTivo.conf have bearing on 16:9 aspect, e.g.:
    Code:
    #Output Pixel Width: if you have an HDTV you might want to try 720 or 704
    #Valid: 720, 704, 544, 480, 352
    width=1440
    height=720
    
    ##Per tivo options
    # section named _tivo_TSN with the tsn in all caps
    #[_tivo_2400000DEADBEEF]
    
    #If you want to use 16:9 or 4:3 on this tivo
    #aspect169=true
    I assume width=544 and aspect169=false would apply to your case.

    Good luck! Nothing will explode..... you can always just replace the original files and be no worse off than when you started. :cool:

    Edit -- after trying this myself:

    If the encoding frame size of the mpeg has an aspect ratio less than 4:3 pyTivo will pad the right and left sides of the transcoded mpeg giving you black bars on the sides and an incorrect aspect ratio. My test file was a 480x480 mpeg that originated as a Tivo recording so this happened.

    The logic determining this is in function: def select_aspect(inFile, tsn = ''): in transcode.py. As you can see it's pretty complex. I was able to fix it for the 480x480 case by a "hack" as follows:

    Replace the line:
    Code:
                    if endHeight < TIVO_HEIGHT * 0.99:
    by
    Code:
                    if endHeight < 0:
    However I can't vouch for what will happen for different encoding frame sizes and choices of width and height in the pyTivo.conf file.

    My initial thinking was that the correct way to do this would be if the "type" (codec) of the file is "mpeg2video" and aspect169 is False, just return:
    "-aspect 4:3 -s <width>x<height>" , where <width> and <height> are the values in the pyTivo.conf file. (???). However, if the input mpeg2 is 16:9 display AR this wouldn't be correct -- you would need letterboxing in the encoded file. I think this all gets back to the basic problem that ffmpeg can't tell pyTivo what the display aspect ratio of the input file is, only the encoding frame AR. One approximate approach would be to assume if the encoding frame AR is less than 4:3 and not on of the "magic" 4:3 list, then the correct display AR is made 4:3, which AFAIK is the effect of my hack.

    What about the common case of mpeg2 video captures, which are typically 720x480 encoding with 4:3 display AR ? I believe the current code would end up letterboxing that, no? (Of course the current code would not re-encode that file because it is a compatible one.)

    What size(es) are the mpeg2's you are concerned with and what (display) aspect ratios?
     
  5. Apr 19, 2007 #325 of 5683
    comandercody

    comandercody New Member

    48
    0
    Jun 16, 2002
    First off, thank you for this program.

    Here is my "Config" file:

    [DEFAULT]
    path = <Pick A Path>
    type = video

    ffmpeg=c:\Program Files\pyTivo\plugins\video\ffmpeg_mp2.exe

    [MyTVShows]
    type = video
    path = C:\Program Files\PipKin Technologies\TiVo.Net\Videos

    [Paris]
    type = video
    path = N:\dvd movies\Paris Hilton

    [Server]
    height = 720
    width = 1440
    port = 9032
    ffmpeg = /usr/bin/ffmpeg

    [TIVO Porn]
    type = video
    path = N:\dvd movies\Porn\!!Tivo Porn

    [Howard Stern]
    type = video
    path = N:\dvd movies\Howard Stern on Demand

    beacon = 255.255.255.0
    -----------------------------------------------------------------
    When I look at my NPL, I see the individual folders (TIVO porn, Howard Stern), but when I select them it says "The "blah blah blah" now playing list could not be displayed because of an unknow error"

    Any suggestions?
     
  6. Apr 19, 2007 #326 of 5683
    comandercody

    comandercody New Member

    48
    0
    Jun 16, 2002

    Sorry, I am running Windows XP and have a Series 2 Tivo, 240(two of them, networked, one wirelessly, one directly wired into my router).

    I am also running Tivo desktop 2.3.
     
  7. Apr 19, 2007 #327 of 5683
    jwreiner

    jwreiner New Member

    82
    0
    Aug 19, 2003
    Connecticut
    Thanks for the advice. I didn't know Python was so easy to modify.

    I got it to work by just removing the section in transcode where it compares the file to supported modes. I was working with an mpeg that wasn't a .tivo file ever.

    I suppose the absolute best solution is to check the TSN and if the aspect ratio is 16:9 but the TiVo doesn't support it, to transcode. I'll have to go back and read all the discussion of aspect ratios I didn't really understand the first time through.
     
  8. Apr 19, 2007 #328 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Revisit my original post, I edited it big time after you read it. I suspect very few people completely understand AR and I suspect I'm not one of them.

    I wonder if it would be feasible to have pyTivo also run another program, such as mediaInfo, which does seem to return the display AR in its info ?
     
  9. Apr 19, 2007 #329 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Your problems are due to the built in anti-trash filters of pyTivo, which exclude anything related to porn, Howard Stern or Paris Hilton.

    :D Sorry, just couldn't resist.

    Seriously, your pyTivo.conf file has to have a section called [Server] and the ffmpeg= and beaon= must be in that section, i.e., before any other sections (defined by names in [square brackets]).

    You also need
    port=9032
    in the server section.

    Also, in your [DEFAULT] share, I wouldn't know what to predict pyTivo will do with:
    path = <Pick A Path>
    unless you actually have a folder called "<Pick A Path>" on your root folder. (I suspect you should just delete this share and path.)
     
  10. Apr 19, 2007 #330 of 5683
    Deadpan Science

    Deadpan Science New Member

    22
    0
    Jan 21, 2007
    I'm currently using pyTivo 187, and I'm having a problem with getting a video to be the correct size on my tv screen. I have a normal 4:3 tv.

    these are the config settings for the video portion of the conf file

    Currently when I transfer videos, I get only a small portion of the video(with sound) to display on screen. (Basically the middle-top of the video when played on the computer.)

    What should I do?
     
  11. Apr 19, 2007 #331 of 5683
    jwreiner

    jwreiner New Member

    82
    0
    Aug 19, 2003
    Connecticut
    Based on what I read in the last hour, mpeg2 files have a flag that indicates the display AR. So 720x480 could either be 4:3 or 16:9. You can't tell from the pixel counts. I think ffmpeg probably knows the DAR, then, so I was hoping that if I just give it the original file and tell it I want 4:3, it would do the rest.

    Now that I think about it, my experience with gui4ffmpeg suggests this might not be so. I think I had to select 16:9 -> 4:3 to get it to behave.

    Anyway, my situation is if I rip a 16:9 DVD, and use DVDShrink to combine it into a single mpeg file, I want that to be the end of the manual processing. I gather with many TiVo's, that would be the end. But mine doesn't like 16:9 mpeg files.
     
  12. Apr 19, 2007 #332 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Try:
    width=544
    height=480

    The values you are using are in the file as installed but they would apply only to a super high res HD set -- kind of misleading perhaps.
     
  13. Apr 19, 2007 #333 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
  14. Apr 19, 2007 #334 of 5683
    TreborPugly

    TreborPugly Unreal!

    4,542
    0
    May 2, 2002
    Eastern TN
    commandercody,

    is your drive labeled "N" a networked drive? If so, the pyTivo service might need to be running with an account that can authenticate to that share. I had a similar problem with a NAS drive, and it was corrected when I added guest access to that share, rather than changing the account attached to the pyTivo service.
     
  15. Apr 19, 2007 #335 of 5683
    windracer

    windracer joined the 10k club

    11,580
    3
    Jan 3, 2003
    St. Pete, FL
    Couldn't you have edited that part out? :rolleyes: :D

    TiVo Guy was young ... he needed the money back then and was unfairly exploited. :eek:
     
  16. Apr 19, 2007 #336 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Source Forge program mediaInfo has a CLI version. I've experimented with it and it can be called so as to return just the AR (or whatever else you want). This could be called from pyTivo just as ffmpeg is now. As with ffmpeg it has precompiled windows versions and for Linux you have the same situation as ffmpeg, i.e., regarding getting a version that runs on your box.

    This could be used to get the display AR for mpeg2 inputs and used to setup AR and padding for two cases:
    1. For mpeg2's that are not TiVo compatible (which are already re-encoded).
    2. For mpeg2's that are TiVo compatible but which users such as jwreiner want to force re-encoding anyway.

    It could be set up with a config variable or two that would default to the current functionality.

    If you think this is worth the additional complexity (including adding mediaInfo CLI version to the distribution), I can rough out a version of the code to implement it, which you could then review/modify. Or if someone else wants to do the coding, I can let them know the CL that works. I wonder how many cases of type (1) are encountered and how many users of type (2) ?

    @jwreiner: Even if pyTivo doesn't elect to do this, I may do it just for fun. Maybe it could be structured to ease the pain of editing it into future versions of pyTivo.
     
  17. Apr 19, 2007 #337 of 5683
    jwreiner

    jwreiner New Member

    82
    0
    Aug 19, 2003
    Connecticut
    Does ffmpeg not return or process the frame AR? I read that somewhere, but it seems odd to me.

    I found out that I can get my 540 version tivo to play back 16:9 mpegs if I set the TiVo itself to 16:9 in the settings menu. Just using TiVo Desktop, this works. However, the image is squeezed horizontally just like you would expect. I really wish that TiVo would just fix this bug.
     
  18. Apr 19, 2007 #338 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    ffmpeg does report the frame AR but pyTivo needs to know the display AR to set up proper encoding format. FAR is the digital array size width:height for the encoded data. DAR is the ratio that is supposed to be seen by the eye on the TV. See here for a good discussion. And you're above average if you come away with a firm understanding after reading it!
     
  19. Apr 19, 2007 #339 of 5683
    dlfl

    dlfl Cranky old novice

    6,996
    16
    Jul 6, 2006
    Near...
    Let me see if I can get this straight:
    1. Your mpeg2 is 16:9
    2. You have aspect169 set to true in pyTivo.conf (??)
    3. Your Tivo is set for 16:9
    4. Your TV is 4:3 (??)
    In that case I would expect a squeezed image as you said. If pyTivo was modified to encode mpeg2's using DAR information, you could set aspect169 to false and set your TiVo back to 4:3 and get a letterboxed video that would have the correct aspect ratio on your TV, I believe.
     
  20. Apr 19, 2007 #340 of 5683
    jwreiner

    jwreiner New Member

    82
    0
    Aug 19, 2003
    Connecticut
    If I transfer a 16:9 mpeg2 with TiVo Desktop (not pytivo), and set the TiVo to 16:9, I get a distorted but otherwise acceptable image on my 4:3 TV (I think this is the same result I would get using pytivo regardless of the the aspect169 setting unless transcode.py has been modified).

    If I set aspect169 to false and my TiVo back to 4:3 and force pytivo to re-encode the mpeg2 after hacking transcode.py, I get a less distorted image, but still not right. I'm pretty sure that is because pytivo is assuming a pixel aspect ratio of 1:1 for my 720x480 mpeg2. To get to 4:3, it pads the top and bottom, but not by enough, because the pixel aspect ratio is not 1:1. So the image is stretched vertically.

    If I gave it a 4:3 mpeg2 to process, it would do the same thing, pad the top and bottom, and squeeze the image vertically, when it should do no padding at all.

    Regarding the frame aspect ratio, I was trying to adopt the language from the pytivo wiki, which makes it sound like the frame ratio is the actual width on a TV to the actual height (not the # of pixels). Whatever it is called, I would think that ffmpeg would know and return the intending display type.
     

Share This Page