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. Nov 1, 2007 #861 of 5687
    PaulS

    PaulS Member

    674
    1
    Sep 16, 2002
    Southern NH
    Didn't have a lot of time to fool around with pyTivo last night (trick or treating took most of the night), but did manage to get some things done.

    The adjusted ffmpeg2 parameters look good, after a very small amount of viewing. I used settings that are exactly the same as what wgw just posted.

    I could get two pyTivo services to run simultaneously, but only one would be recognized by my S3. So far, I've created two pyTivo directories, one for SD and one for HD. Here are my changes to date, in addition to the transcode.py changes listed in the previous posts :

    SD configs :

    c:\pytivo-201-sd\pyTivo\pyTivo.conf
    port=9032
    ffmpeg=c:\pytivo-201-sd\pyTivo\plugins\video\ffmpeg_mp2.exe
    audio_br=384K
    video_br=5Mi
    width=720
    height=480
    aspect169=true

    [SD-Sources]
    type=video
    path=c:\videos-SD​

    c:\pytivo-201-sd\pyTivo\beacon.py
    guid="123456"​

    c:\pytivo-201-sd\pyTivo\pyTivoService.py
    _svc_name_ = 'pyTivo-SD'
    _svc_display_name_ = 'pyTivo-SD'​


    HD configs :

    c:\pytivo-201-hd\pyTivo\pyTivo.conf
    port=9034
    ffmpeg=c:\pytivo-201-hd\pyTivo\plugins\video\ffmpeg_mp2.exe
    audio_br=384K
    video_br=14Mi
    width=1280
    height=720
    aspect169=true

    [HD-Sources]
    type=video
    path=c:\videos-HD​

    c:\pytivo-201-hd\pyTivo\beacon.py
    guid="654321"​

    c:\pytivo-201-hd\pyTivo\pyTivoService.py
    _svc_name_ = 'pyTivo-HD'
    _svc_display_name_ = 'pyTivo-HD'​


    So, I've changed the service port, service name, the GUID, and paths to ffmpeg and the content. Both services appear in the Windows services list, are automatic, and are started. However, my S3 will only show one service (may be alternating between the two, not sure yet).

    I've just noticed that the add_service() call in pyTivoService.py uses the "port" variable, while the add_service() call in beacon.py uses a hard-coded value of 9032. This doesn't seem right to me.

    Also, should Config.py::def getValidWidths(): be modified to allow for widths of 1280 ? My read of the code seems to lead me to believe that specifying 1280 will actually result in a value of 1440 (the closest to 1280) being passed into ffmpeg. Is this true ?

    I write C code for a living, so I can kinda follow the code paths. However, I really don't grok python, so I'm unsure of how to make the most "clean" changes to the scripts to get these things done.
     
  2. Nov 1, 2007 #862 of 5687
    PaulS

    PaulS Member

    674
    1
    Sep 16, 2002
    Southern NH
    Yes. I'm running 9.2 on my S3, running with pyTivo-201, as you can see in my previous post (above).
     
  3. Nov 1, 2007 #863 of 5687
    Laserfan

    Laserfan New Member

    412
    0
    Apr 25, 2000
    USA
    This is very confusing to me: prior to Tivo Desktop I've been recording ATSC with a MyHD card and HDHomeRun and all the bitrates I see are about 15Mbps. Then I process a .tivo file from my S3 and it's at 18.5Mbps? How does that happen--does the .tivo file include null packets or something to drive the bitrate up that high? And if you just re-process the file to an .mpg and put it back on the Tivo, why wouldn't it play...it CAME FROM the Tivo originally!!! :confused:
     
  4. Nov 1, 2007 #864 of 5687
    bubba1972

    bubba1972 New Member

    195
    0
    Mar 28, 2005
    Is anyone seeing fast forward problems when viewing web downloaded mpeg 2 files that have been pushed back to an S3? I have tried WinAVI, TivoDesktop Plus, and now PyTivo and cannot create an mpeg that the S3 can fastforward through correctly. They all play and fast forward just fine on my S2. On the S3, they will play, but when fast forwarding at 2x or 3x it appears that the time bar is moving faster than the video. When you hit play, the time bar backs up a little as you would expect, but the video jumps much further ahead then where you were when hitting play. Fast forwarding at 1x doesn't seem any faster than real time playback. I forced the pyTivo script to re-encode a 'tivo compatible' mpeg 2 and I get the same results. I can't believe I am the only one seeing this.
     
  5. Nov 1, 2007 #865 of 5687
    MasterCephus

    MasterCephus New Member

    309
    0
    Jan 2, 2005
    Hueytown,...
    Interesting because I am using the exact same version of pyTivo and nothing shows up on my Tivo...

    I do have a series 2 and a series 3...would that make a difference? I wouldn't think so becasue when I run the pyTivo.py file, everything works perfectly...

    EDIT:

    I read somewhere that the Tivo desktop needs to be paused...is that true?
    Any help would be appreciated!
     
  6. Nov 1, 2007 #866 of 5687
    bubba1972

    bubba1972 New Member

    195
    0
    Mar 28, 2005
    Just to add to my post above, I see the ff problems when converting at 720x480 and 704x480. I tried the HD resolution of 1280x720 and the ff and rw behavior was correct. The resolution was the only change made in the config file. Any ideas on what can be done to the SD mpegs to get them to shuffle correctly for me?
     
  7. Nov 1, 2007 #867 of 5687
    cr33p

    cr33p New Member

    644
    0
    Jan 2, 2005
    Ann Arbor MI
    I too have recently loaded pytivo on some additional pc's for friends and even though the service is up and running nothing shows up in the NPL, unless I launch pytivo manually, my existing box still works after all updates since 7.x. I dont understand what the problem is though.
     
  8. Nov 1, 2007 #868 of 5687
    ScottE

    ScottE New Member

    22
    0
    Oct 15, 2001
    San Diego,...
    The problem is that ffmpeg doesn't know HOW to map those channels in the mkv file to AC3. There are probably extra arguments you can give it to tell it what input channel maps to which output, but I don't know then offhand.

    For the 5.1 files that I have (mostly MPEG2 or h264), it seems to map the audio correctly.
     
  9. Nov 1, 2007 #869 of 5687
    ScottE

    ScottE New Member

    22
    0
    Oct 15, 2001
    San Diego,...
    The ffmpeg line I'm using is:

    cmd = [FFMPEG, '-threads', '2', '-i', inFile, '-vcodec', 'mpeg2video', '-r', '29.97'] + select_aspect(inFile, tsn) + ['-comment', 'pyTivo.py', '-acodec', 'ac3', '-ab', AUDIO_BR,'-ar', '48000', '-f', 'vob', '-b_strategy', '1', '-bf', '2', '-coder', 'vlc', '-mbd', 'rd', '-qmin', '1', '-maxrate', '17M', '-bufsize', '1024k', '-b', VIDEO_BR, '-' ]

    This works great for me (~45fps) on my E6600 (Dual core 2.4GHz) running NetBSD. pyTivo.conf contains:

    audio_br=448k
    video_br=8Mi
    width=1280
    height=720

    Depending on your particular system, you might see additional performance increases by adjusting the buffer size used by the pipe that ffmpeg writes to. Just below the "cmd =" line, I changed the ffmpeg call to be:

    ffmpeg = subprocess.Popen(cmd, bufsize=512*1024, stdout=subprocess.PIPE)

    (added the "bufsize=" argument)

    When streaming to Tivo, this reduces the CPU time consumed by the Python interpreter dramatically.

    I've put those two files (my transcode.py and pyTivo.conf) at http://intrepid.warped.com/~scotte/visible/pyTivo/ in case my explanation above doesn't make any sense. :)
     
  10. Nov 1, 2007 #870 of 5687
    PaulS

    PaulS Member

    674
    1
    Sep 16, 2002
    Southern NH
    I finally got both pyTivo services up and running. One service for SD (720x480 @ 5Mpbs) running on the default port 9032, and one for HD (1280x720 @ 14Mbps) running on port 9034. They both appear at the bottom of my Now Playing List, along with the folder for TiVo Desktop. It's starting to get a little busy down there... :)

    The python scripts sometimes use the "port" variable defined in pyTivo.conf, and sometimes they use a hard-coded value of 9032. This is obviously incorrect. I'd like to fix it, but as I said I'm a C code monkey, not a python code monkey. :)

    There may also have been a conflict with the GUID variable. It's possible to assign it in the pyTivo.conf file, but the default file doesn't specify it. I went with the shotgun approach of defining the variable in the config file, as well as modifying the default value in the beacon.py script.

    I'm attaching both the SD and HD sources, should anyone want to use them or make the appropriate changes in the pyTivo sources. There's enough changes that simply listing the diffs would be tedious and error-prone. Anyone who wants to use this set up should just have to overlay the appropriate files, change the paths in my pytivo.conf to their pathing, and plunk in copy of ffmpeg2.exe into the pytivo/plugins/video directory. I didn't enclose it since it's 7MB in size.


    The only issue I'm still seeing now on the 1280x720 transfers is the audio lagging over the course of playback. At the start, audio and video are synched up. Over the course of playback, the audio will slowly slip. At the end of an hour, the audio's probably lagging the video by about a second or so.
     

    Attached Files:

  11. Nov 1, 2007 #871 of 5687
    wgw

    wgw New Member

    217
    0
    May 16, 2007
    Windows Firewall is probably blocking it.

    Start the service by typing pytivoservice.py debug

    A firewall window should popup asking if you want to Keep Blocking or Unblock. Select Unblock.

    Start the service normally thereafter.

    Or you can open Windows Firewall through the Control Panel and allow pythonservice on the Exceptions tab.
     
  12. Nov 2, 2007 #872 of 5687
    wgw

    wgw New Member

    217
    0
    May 16, 2007
    Oh, I see what you mean, it checks config then defaults. I've added "guid = xxxxxx" after the port variable and returned my beacon.py file to original state. Thanks, it's working fine. :up:
     
  13. Nov 2, 2007 #873 of 5687
    MasterCephus

    MasterCephus New Member

    309
    0
    Jan 2, 2005
    Hueytown,...
    That did it...maybe that should be added to the wiki over at the other site so people will know about that...

    I appreciate your help!
     
  14. Nov 2, 2007 #874 of 5687
    russellneufeld

    russellneufeld New Member

    2
    0
    Nov 10, 2002
    Hi all,

    I've upgraded to python 2.5.1 on my Mac and am running pyTivo from pyTivo-201.zip. The video folder I'm sharing shows up in the NPL of my Series3 Tivo, however it's empty. No matter what I do I can't seem to make the videos in that folder show up on the Tivo listing. Any ideas? There are two mpeg-2 file in that directory which I downloaded from the same tivo. They have spaces in their file names. Not sure if that matters.

    I've read through a bunch of the recent posts and didn't see an answer. Sorry if this topic has been discussed ad nauseum.

    Thanks in advance,

    Russ
     
  15. Nov 2, 2007 #875 of 5687
    gibbyscott

    gibbyscott New Member

    15
    0
    Jul 12, 2004

    Yes, for the life of me, I can not find any info on changing positions, etc. There is a map option, but it is for selecting which audio stream to encode, not the actually speaker positions.

    I am really supprised that not more people have complained of this. I guess not many people are trying to transcode .mkv files.

    Just to make sure that I am not crazy, does the same happen to you when you transcode .mkv? I tried it on 2 different pc's and the same thing happens on both.
     
  16. Nov 2, 2007 #876 of 5687
    AnonymousTroll

    AnonymousTroll New Member

    13
    0
    Jan 6, 2007
    pyTivo seems to hold a rather tight lock on the folders that it is publishing. I have found that in order to make any changes in the folder, I have to stop the pyTivo service.
     
  17. Nov 2, 2007 #877 of 5687
    wgw

    wgw New Member

    217
    0
    May 16, 2007
    No problem, glad to help. I had never tried to run the pytivo service until I read about everyone having trouble. So I gave it try myself and found I had the same problem. I don't remember what I typed on the command line to get the options to show up but saw the debug option and gave it a try and it worked. I like to try and solve problems when if I can and got lucky this time.

    Windracer seems to like a puzzle as well. Now that I re-read his post, he even said at the time that guid can be specified in the conf file. I missed that. Thanks bud.

    Cheers!
     
  18. Nov 2, 2007 #878 of 5687
    windracer

    windracer joined the 10k club

    11,580
    3
    Jan 3, 2003
    St. Pete, FL
    I was wondering if anyone was going to remember that. :cool: :up:
     
  19. Nov 2, 2007 #879 of 5687
    mr2828

    mr2828 New Member

    43
    0
    Jun 18, 2007
    After considering running two servers I eventually just decided to run one HD one, and just let all my SD files get upconverted to 1280x720. Sure it takes a while longer to encode and will take up more space on the S3's drive, but well *shrug*. :)

    Regarding audio sync, as an experiment try adding this to your ffmpeg command line: "-async 48000". I'm also experimenting with HD audio sync at the moment, but it is hard because my PC is so old I can't play back the source files properly, and can't tell if any audio sync issues I see on the S3 are due to the transcoding or were in the original source...
     
  20. Nov 2, 2007 #880 of 5687
    mr2828

    mr2828 New Member

    43
    0
    Jun 18, 2007
    One other experiment I want to try is removing the part of the ffmpeg command line where it forces all the output to a framerate of 29.97 fps instead of just leaving it the same as the input file. Many of my input files use ~24 fps. Anyone tried removing this option from the command line?
     

Share This Page