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. Mar 16, 2007 #161 of 5684
    dlfl

    dlfl Cranky old novice

    6,997
    18
    Jul 6, 2006
    Near...
    As I understand it (those are weasel words so you can't blame me if I'm wrong) some mpeg4 formats (e.g., Xvid, frequently found in an AVI container) have an aspect ratio specifier in the file and this may need to be changed to 4:3.

    Try mpeg4modifier, a little (30kB) free program that can do things like change the aspect ratio. It will be quick -- you are not re-encoding the file.

    I've experienced this encoding to AVI/XVID using AutoMKV but I didn't use mpeg4modifier to fix it. I just re-encoded using the feature in AutoMKV that allows you to specify the Xvid AR you want. Another handy small free program is mediaInfo. With it installed you can right click on a video and it will tell you the properties, including the AR in an Xvid video.
     
  2. Mar 16, 2007 #162 of 5684
    sabu

    sabu New Member

    17
    0
    Jan 29, 2002
    Harrisburg, PA
    Okay, both versions of ffmpeg convert that into a 16:9 aspect ratio file that plays fine on the PC.
     
  3. Mar 16, 2007 #163 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Ok give me a few minutes, let me see if I can encode something with those specs and figure out what is going on.

    Kevin
     
  4. Mar 16, 2007 #164 of 5684
    CheezWiz

    CheezWiz ReplayTV->S3 Tivo

    211
    0
    Dec 29, 2006
    Middle...
    Sabu,

    Are you playing to a 4:3 or 16:9 TV?
    The reason I ask is that I too have come across an XVID that does exactly what yours is doing on a 4:3 TV , but works fine going to my 16:9 TV.

    Here is what I am seeing:
    Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/2733) -> 23.98 (2997/125)
    Input #0, avi, from 'R:\Video\/Movies/Jackass.Number.Two.UNRATED..XviD.avi':
    Duration: 01:33:28.7, start: 0.000000, bitrate: 1042 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 624x336, 23.98 fps(r)
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
    Output #0, vob, to 'pipe:':
    Stream #0.0: Video: mpeg2video, yuv420p, 720x480, q=2-31, 4096 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
    Press [q] to stop encoding
     
  5. Mar 16, 2007 #165 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    hmm it should still play fine on a 4:3 tv.

    I made a new update. There is a minor fix to an error in the code i doubt it was causing your problem.

    More importantly I added a debug feature. This will write a file in the base directory called debug.txt. I would not leave this on as it slows down pyTivo a lot and will make a huge file in on your drive.

    To Activate debuging in version 174 and up:
    Add the following line under the [Server] Block
    debug=True

    To deactivate debugging:
    Delete that ENTIRE LINE

    Sorry there is a mistake in my programming and if the option debug exists it will debug, so to stop it you must remove the line completely. Future versions will fix this.

    SABU
    if you could:
    1. update to this version.
    2. enable debugging as described above
    3. start pytivo
    4. try and load your video
    5. stop pyTivo
    6. post debug.txt from base folder to here
    7. REMOVE debug line from pyTivo.conf
    8. restart pytivo

    Thanks
     
  6. Mar 17, 2007 #166 of 5684
    dlfl

    dlfl Cranky old novice

    6,997
    18
    Jul 6, 2006
    Near...
    Please review my prior post about handling 59.94 fps reported by ffmpeg for tivo compatible mpegs. The patch that is still in transcode.py in ver. 174 has two problems:

    1. It doesn't work for the currently used build of ffmpeg (8047).
    2. I don't believe it will work even for the build it was targeted at (7215) because the regular expression will not match 29.97. Am I wrong here?

    Anyway, I would suggest at least removing or fixing the current patch, and why not use the patch I gave in the post, which covers both builds? I've been using it and it works fine. There are four VideoReDo-edited files in my archive that are allowed to transfer without re-encoding with this patch.
     
  7. Mar 17, 2007 #167 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Whoa, easy there. Sorry I thought this problem had already been solved, no need to get upset.

    Armooo added the following line:
    rezre = re.compile(r'.*film source: (\d+).*')

    I assumed this fixed your problem. You are right it does only return 29 and not 29.97. I will do my best to fix this in the next update.
     
  8. Mar 17, 2007 #168 of 5684
    jacques

    jacques Member

    353
    0
    Jun 2, 2000
    Victor, NY USA
    I just wanted to post a thank you.

    Thank you!

    This is just the coolest thing for watching my MythTV recordings on my TiVo. I'm a linux newbie and getting it working on my KnoppMyth box was simple.

    Thanks again!
     
  9. Mar 17, 2007 #169 of 5684
    sabu

    sabu New Member

    17
    0
    Jan 29, 2002
    Harrisburg, PA
    Here is the debug.txt file. The TiVo is a Dual Tuner SA attached to a 4:3 standard res TV and set to 4:3 output.

    I found a 4:3 aspect ratio file and it transferred and played without any problems.

    Thanks for all your help on this!
     

    Attached Files:

  10. Mar 17, 2007 #170 of 5684
    dlfl

    dlfl Cranky old novice

    6,997
    18
    Jul 6, 2006
    Near...
    Couple of small suggested edits to your first post to make life easier for newcomers:

    1. Make it clear there is a Wiki (I know the link is there but there is nothing to indicate it is a Wiki link.)

    2. Correct the typo in: "type = vidwo"

    Thanks
     
  11. Mar 17, 2007 #171 of 5684
    dlfl

    dlfl Cranky old novice

    6,997
    18
    Jul 6, 2006
    Near...
    I just added an item to the "Known Issues" section of the Wiki describing a NPL problem and a work-around. If this is happening to other TiVo models, the wording could be made more general. Or maybe other/better work-arounds could be added/substituted.

    Anyway, take a look and have at it!
     
  12. Mar 17, 2007 #172 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
  13. Mar 17, 2007 #173 of 5684
    inthewoods

    inthewoods New Member

    12
    1
    Feb 21, 2005
    I have the display problem where the screen gets whacked like every other scanline is shifted and the picture ends up in 3 interlaced sections. Very strange looking.

    I solved the problem on my Series-2 540 by changing from 720x480 to 544x480.

    I also tried the newest ffmpeg I could find, r8310, but it still was screwing up. Only switching to 544 fixed it for me. I've had this problem in the past using Videora and VLC, so maybe it is a bug or hardware problem in some of the Series 2s.

    Thanks for all the work on pyTivo, I like how clever yet simple it is! The code is a great intro to Python for me. I've been making some minor source code tweaks and I'd like to donate them to the cause.

    Specifically:
    * Configurable broadcast address to address beacon problems on multi-homed machines
    * Configurable output resolution
    * Uses "k" suffix for audio bitrate (needed for newer ffmpeg)

    Where do I post patches?

    -Tony
     
  14. Mar 17, 2007 #174 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Yeah I am starting to think there may be some minor differences out there with TiVo's.

    Sabu I think this is where your problem is. I relooked over the code for 16:9 videos and how it functions. pyTivo is sending a 16:9 video to your TiVo even though your TiVo can only support 4:3. For the rest of us the TiVo just fixes this. A good way to test this out is change your TiVo settings to 16:9, all 16:9 videos that have been transfered will now be stretched vertically. But 4:3 videos will still look fine.

    Sabu, I think the problem is possibly that your version of TiVo doesn't handle 16:9 gracefully like most of us. Don't worry though. I think pipakin solved this by allowing users to preselect their aspect ratios. I am working on recoding transcode.py to send files only in their preselected format. I am hoping this will solve your problems.

    You can post them here. And thanks for your help.

    Kevin
     
  15. Mar 17, 2007 #175 of 5684
    CheezWiz

    CheezWiz ReplayTV->S3 Tivo

    211
    0
    Dec 29, 2006
    Middle...
    I just set my S2DT that is on my HD TV to 4:3 and set the Tivo's resolution to 4:3 and played the same file mentioned earlier and the results are the same. The right 1/3 of the movie is missing.

    Upon setting the Tivo to 16:9 but leaving the TV in 4:3 I do see the expected results of tall and skinny, but all is there.

    The question I have is, can pyTivo determine which of my two Tivos is requesting the file and select aspect ratio appropriately? Or does the requester never ID itself to pyTivo?

    Also, is all this protocol documented somewhere or have you guys just figured it out through trial and error?

    ps, thanks to everyone involved with this!
     
  16. Mar 17, 2007 #176 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Cool, i think that means I am on the right track. I almost have a dramtically changed transcode.py file ready for anyone having aspect issues to try.

    F, hmm, I had not thought of this issue. Umm no in its first iteration the setting will be the same as TivodotNet, which is a global setting of 16:9 or 4:3. The TiVo does identify itself when it requests files, but this will require two additional mods, 1. Add code to pull the TSN from the request, 2. Add code to the conf file to allow you to choose which TiVo gets what.

    Umm like much of the TiVo development a lot of it comes from looking at TiVo's software and reverse engineering it. Armooo did 99% of the hard work and started this thing. I think he just watched packets from TiVo Desktop. I can say that when I had to solve the transfer error problem I had to purchase TiVo Desktop 2.4 and do some packet sniffing while it was running to solve the issue.

    So the answer is no, not to my knowledge. TiVo has not released an SDK since the HMO/HME days and has not expanded either of those since then. I know a few developers, namely the developer for galleon, have been quite upset about this.
     
  17. Mar 17, 2007 #177 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    - I made some major changes to how select_aspect() works. Unless you specify in the conf file that you want to allow 16:9 aspect ratio all files will be sent to TiVo in the 4:3 format. Additionally the code for padding of videos has been updated to be more accurate. A circle should indeed be a circle on the TV now. And Sabu I hope this fixes your issue.

    Read about how this works AspectRatio

    Hmm, my brain is dead and I can't figure this out right now. When I pad the left and right, do I need to pad with distorted pixels?? Can someone play a video which is skinnier than 4:3 and tell me if it looks distorted at all on TV. We might only need to pad with true pixels on left and right.

    - A new conf file has been provided, but to allow 16:9 files set the following option in the conf file:
    aspect169=true

    Even if you allow 16:9 videos files which are 4:3 or lower aspect(very skinny) will still be sent in 4:3 format and your TV can handle them however you normally handle 4:3 broadcast images.

    - The debug code had been simplified. To create a debug.txt file in the base directory of what transcode.py is doing set the following option in the conf file:
    debug=true

    Leave it set to off(debug=false, or delete the line) unless you want to slow pyTivo down and create a wasted file in your base directory.

    - I also added dlfl's code for the fps issue he was having.

    Later Updates:
    Cheezwiz Sorry buddy the aspect setting is global, I will work on a per TiVo setting later.
     
  18. Mar 18, 2007 #178 of 5684
    dlfl

    dlfl Cranky old novice

    6,997
    18
    Jul 6, 2006
    Near...
    Results of an experiment (not sure what you will make of it):

    I used a tivo-compatible mpeg2 file (a tivo file edited by VideoReDo and saved as mpeg2). It has 480x480 (encoding) resolution.

    I changed tivo_compatable() so if would return False for this file, i.e., forcing a re-encode, and looked at the ffmpeg command line for that transcode.

    I'm 4:3 all the way (tivo settings, TV and aspect169 = false).

    The encoding -s option was 540x480 and left and right pads were both 90, bringing it to 720x480. The -aspect option was 4:3. (The 540 obviously is the 9/8 ratio times 480.)

    The TV picture was squeezed horizontally and had black bands left and right.

    Obviously some pixel distortion (PAR not 1:1) is needed. However, if tivo is sent the original (not-transcoded) 480x480 mpeg it will do the scale up to 4:3 aspect for display.

    My guess is (at least for this case) the -s should be 720x480 and left and right pads should be 0. I think this is what you call padding "with distorted pixels" (?)

    Like you said in your Wiki addtion, PAR is the "annoying one". :D

    As I see it, the basic problem is ffmpeg doesn't give enough information. It gives you the encoded dimensions but not the frame (or display) dimensions intended for the video. (Or equivalently, it doesn't give you the PAR.) Even worse, this information is probably not even available in some video file formats (?). You have to assume target display dimensions based on 4:3 or 16:9. For 4:3, it seems unlikely (but not impossible) that the intended display AR would be less that 4:3 --- which seems to imply you should pad with distorted pixels for those cases -- but then ..... yep, it's annoying!.
    Thanks. I'm assuming (hoping?) this will help OP too. :)
     
  19. Mar 18, 2007 #179 of 5684
    KRKeegan

    KRKeegan Im lost and confused

    215
    0
    Jul 20, 2004
    Los Angeles, CA
    Exactly, I am hoping that Armooo, list of possible PAR ratios will catch files that have non 1:1 PAR.

    But yes ffmpeg does not return enough information for me to know what the PAR is. I think for most computer files a PAR of 1:1 will work, AVIs i think are pretty much always in 1:1. The problem is going to come in with MPGs, some of them as dlfl demonstrated have nonsquare pixels.
     
  20. Mar 18, 2007 #180 of 5684
    sabu

    sabu New Member

    17
    0
    Jan 29, 2002
    Harrisburg, PA
    Yes, the 16:9 ratio file now transfers and plays with the content centered!

    One alternative option for how to specify the 16:9 setting would be on a share by share basis instead of a TiVo by TiVo basis. That way it would be easy to try the variations of the flag going forward as new versions of the TiVo software are released. Just a thought.

    Thanks again for all your efforts! This is a great little program.
     

Share This Page