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

pyTivoX

Discussion in 'TiVo Home Media Features & TiVoToGo' started by Yoav, Dec 10, 2008.

  1. Apr 22, 2009 #461 of 1437
    wmcbrine

    wmcbrine Ziphead

    10,364
    22
    Aug 2, 2003
    It is transcoding, though I'm not sure why. Turn on debug to see the reason.
     
  2. Apr 23, 2009 #462 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    Nah, if you're sticking with the beta (1.2 is the beta branch right now) then you may as well use the latest.

    Ok so for some reason it is failing to generate the list of what movies are available. I'm assuming something goes wrong, and hopefully it prints out some useful info in the log... Can you open up Terminal.app and run
    Code:
     tail -50 /tmp/pyTivoX-SB.log 
    or if you're using the LATEST beta (as of today), run
    Code:
     tail -50 ~/Library/Logs/pyTivoX/streambaby.log 
    Anything interesting in there?
     
  3. Apr 23, 2009 #463 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    (to turn on debug, you'll need to edit the file
    Code:
     <user>/Library/Application Support/pyTivoX/pyTivo.conf 
    and in a new line right after Port=9032, add

    debug=True

    Then exit pyTivoX, and start it again.
     
  4. Apr 23, 2009 #464 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    Have modified conf file to include debug statement and restarted. I am assuming that I would need to draw a movie over and review the log file to see this debug information?
     
  5. Apr 23, 2009 #465 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    Presumably.. Debug lines in the log will start with the word "DEBUG", you're probably looking for some invocation of 'ffmpeg' and information around it as to why it's choosing to transcode.
     
  6. Apr 23, 2009 #466 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    I am attaching log file- was unable to post here due to forum limitation (image references??) See attached txt file.
    Tad
     

    Attached Files:

  7. Apr 23, 2009 #467 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    I believe the following lines from your logs explain why it's transcoding:
    Code:
    DEBUG:pyTivo.video.transcode:TRANSCODE=YES, 59.94 vFps, should be 29.97, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:/Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg is not tivo compatible
    ....
    DEBUG:root:transcoding to tivo model 649 using ffmpeg command:
    
    Looks like the original video is set to 60fps, your tivo series 649 (a S2 directivo) is unable to play that.

    So, either pytivo is misprobing your tivo and assuming it can't play it, or it's probing correctly, in which case the transcoding makes sense.... ?

    Since it's Lost, which comes off
     
  8. Apr 23, 2009 #468 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    Yoav,
    The Tivo is a Serie 2 Standalone unit - no Direct TV.
    I follow you that the the frame rate is off and thereby causing it to kickstart the transcoding. I am just not sure why or if this is resolvable.

    I'm using iTivo in decrypt to pull the content off the tivo and pytivox to feed it back- so I'm not clear on why the frame rates are so out of whack....
     
  9. Apr 23, 2009 #469 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    is part of your post missing here??
     
  10. Apr 24, 2009 #470 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    oops yeah
    I was gonna say that ABC broadcasts in 720p, which is supposedly 60fps. But if you pull it off the tivo and it's a series 2, then it's not an HD recording and therefore that's not the reason.

    Ok, so fwiw, I just tried pulling an SD show off my Series 3, and it is also exhibiting this 'issue'. Notably, the container frame rate is 60 fps, while the actual frame rate of the video is 30 fps. I'm wondering if that's a bad 'ffmpeg', a bad 'tivodecode', or if tivos just do that... and if so, should pyTivo ignore the container and trust the video stream?

    From your log:
    Code:
    Seems stream 1 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (60000/2002)
    Input #0, mpeg, from '/Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg':
      Duration: 01:02:01.53, start: 0.833922, bitrate: 6015 kb/s
        Stream #0.0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
        Stream #0.1[0x1e0]: Video: mpeg2video, yuv420p, 480x480 [PAR 4:3 DAR 4:3], 9000 kb/s, 29.97 tbr, 90k tbn, 59.94 tbc
    Output #0, vob, to 'pipe:':
        Stream #0.0: Video: mpeg2video, yuv420p, 544x480 [PAR 20:17 DAR 4:3], q=2-31, 4096 kb/s, 90k tbn, 29.97 tbc
        Stream #0.1: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
    Stream mapping:
      Stream #0.1 -> #0.0
      Stream #0.0 -> #0.1
    
    Note the source is actually at 30 fps (29.97 tbr,..., 59.94 tbc).. I'm not a codec weenie though, so the question is how pytivo determines if it's 60 or 30 fps.

    wmcbrine?
     
  11. Apr 24, 2009 #471 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    Ok from sitting and looking at the code, I see what's going on:

    transcode.py has the following regexp to figure out the framerate:
    Code:
        rezre = re.compile(r'.*Video: .+, (.+) (?:fps|tb).*')
    
    applied to
    Code:
        Stream #0.1[0x1e0]: Video: mpeg2video, yuv420p, 480x480 [PAR 4:3 DAR 4:3], 9000 kb/s, 29.97 tbr, 90k tbn, 59.94 tbc
    
    since there's both a tbr (correct) and tbc (incorrect) value on that line, the regexp swallows as
    much as it can into the first .+, and then pulls the tbc value into x.group(1). After this
    there is some code to correct for some versions of ffmpeg and a videoredo issue, but nothing
    that would fix this.

    So some code needs to be added to pytivo to address this behavior of the new ffmpeg....
    I'm not sure why it's fps:tb.. but presumably if there's a tbc and tbr value, it should use
    the tbr value... Or there may be a more 'correct fix'. Either way Tad you're gonna
    have to deal with the transcoding for a little while longer :(
     
  12. Apr 24, 2009 #472 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    Yoav,
    I'm glad to have stumbled on to this- knowing the power of pytivox- I would hate for someone new to it to try it and think that the transfer rate is slow. I am constantly amazed at the brain-trust here and am sure that a fix will present itself.

    Tad
     
  13. Apr 24, 2009 #473 of 1437
    wmcbrine

    wmcbrine Ziphead

    10,364
    22
    Aug 2, 2003
    I missed this because I was mostly testing with an S3, which accepts the 59.94 rate without transcoding.

    I have a tentative workaround... only, I like to know what the frak I'm doing, and I can't find actual documentation of "tbr" etc. anywhere. What does it even stand for? Maybe I'll have to consult the ffmpeg source code to figure it out.
     
  14. Apr 24, 2009 #474 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    Well, I'm not much help here either, but from the ffmpeg source, this seems like the relevant code (libavformat/utils.c):
    Code:
        if(st->codec->codec_type == CODEC_TYPE_VIDEO){
            if(st->r_frame_rate.den && st->r_frame_rate.num)
                print_fps(av_q2d(st->r_frame_rate), "tbr");
            if(st->time_base.den && st->time_base.num)
                print_fps(1/av_q2d(st->time_base), "tbn");
            if(st->codec->time_base.den && st->codec->time_base.num)
                print_fps(1/av_q2d(st->codec->time_base), "tbc");
    
    Seems like tbr, tbc and tbn are all computed for video streams, each with a different meaning. Running back through the code it seems that the tbr is 'corrected' based on values later printed out as tbn and tbc (whereas tbn and tbc are associated with the length of a frame according to the codec). So I'm guessing tbr is the 'normal' meaning of frame rate, and the other two are codec/container related values... Just for kicks I looked at what ffmpeg prints out for an mp4 rip I made with handbrake... :

    Code:
    ffmpeg -i /Volumes/External\ Disk/movies/Action/X-Men\ \(2000\).m4v 
    
    Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 59.94 (60000/1001)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/External Disk/movies/Action/X-Men (2000).m4v':
      Duration: 01:44:18.72, start: 0.-100188, bitrate: 2451 kb/s
        Stream #0.0(eng): Video: h264, yuv420p, 720x304, 59.94 tbr, 48k tbn, 47.95 tbc
    
    When I asked mplayer for its opinion of the framerate of that movie, I got:
    Code:
    mplayer  -identify /Volumes/External\ Disk/movies/Action/X-Men\ \(2000\).m4v 
    ...
    ID_VIDEO_FPS=59.940
    ...
    
    So it definitely seems like tbr is the right value to go with (at least in both these cases).

    edit : I also came across this patch for handbrake that seems to point at a new behavior in ffmpeg related to framerates, which may explain why it's happening with the new ffmpeg and wasn't seen before: http://forum.handbrake.fr/viewtopic.php?f=4&t=10108
     
  15. Apr 24, 2009 #475 of 1437
    wmcbrine

    wmcbrine Ziphead

    10,364
    22
    Aug 2, 2003
    Yeah... sort of. I grepped the ffmpeg source myself and found a little more info, but it's still vague.

    Anyway, I've committed my workaround to the repo. It fixes several of my test videos. However, I still have one video (that came from a Series 2 TiVo!) which comes up as 29.97 with an older version of ffmpeg, and 59.94 with 0.5 -- and it doesn't show 29.97 anywhere. I'm wondering now if I should just pass through 59.94 as valid for the Series 2. It's a kludge, but I don't see it going wrong too often -- the only real use of 59.94 is in 720p video, AFAIK, and that would still be flagged to reencode due to the resolution.

    Edit: I went ahead and did that, too. Fingers crossed. :)
     
  16. Apr 24, 2009 #476 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    Updating pyTivoX beta to include your new code changes.. I suppose at worst if 'the kludge' doesn't work, we'll hear about it... :)

    Tad is it working now?
     
  17. Apr 24, 2009 #477 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    Below is the log dump for your review. I brought over LOST again to see if there was a noticeable difference.Video is loading quicker now- certainly faster than before...

    INFO:pyTivo:pyTivo is ready.
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:13:30] "GET /TiVoConnect?Command=QueryContainer&Container=%2F HTTP/1.0" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:13:58] "GET /TiVoConnect?Command=QueryContainer&Container=%2F HTTP/1.0" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:00] "GET /TiVoConnect?Command=QueryFormats&SourceFormat=video%2Fx-tivo-mpeg HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:00] "GET /TiVoConnect?Command=QueryContainer&Container=Our%20Video%20Library&SortOrder=Title&ItemCount=8&Filter=x-tivo-container%2Ftivo-videos,x-tivo-container%2Ffolder,video%2Fx-tivo-mpeg,video%2F* HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:03] "GET /TiVoConnect?Command=QueryFormats&SourceFormat=video%2Fx-tivo-mpeg HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:03] "GET /TiVoConnect?Command=QueryContainer&Container=Our%20Video%20Library%2FTelevision%20Shows&SortOrder=!CaptureDate&ItemCount=8&Filter=x-tivo-container%2Ftivo-videos,x-tivo-container%2Ffolder,video%2Fx-tivo-mpeg,video%2F* HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:05] "GET /TiVoConnect?Command=QueryFormats&SourceFormat=video%2Fx-tivo-mpeg HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:06] "GET /TiVoConnect?Command=QueryContainer&Container=Our%20Video%20Library%2FTelevision%20Shows%2FLost&SortOrder=!CaptureDate&ItemCount=8&Filter=x-tivo-container%2Ftivo-videos,x-tivo-container%2Ffolder,video%2Fx-tivo-mpeg,video%2F* HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:08] "GET /TiVoConnect?Command=QueryFormats&SourceFormat=video%2Fx-tivo-mpeg HTTP/1.1" 200 -
    DEBUG:root:starting ffmpeg, will wait 10 seconds for it to complete
    DEBUG:root:ffmpeg output=FFmpeg version SVN-r18664, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    configuration: --shlibdir=@executable_path --arch=ppc --cpu=G4 --enable-shared --disable-static --enable-pthreads --disable-mmx --enable-gpl --enable-libmp3lame --enable-libfaac --enable-libfaad --enable-libx264 --extra-cflags='-DHAVE_LLRINT -I/Users/yoav/src/lame/include -I/Users/yoav/src/faad2-2.7/include -I/Users/yoav/src/faac-1.28/include -I/Users/yoav/src/x264' --extra-ldflags='-L/Users/yoav/src/lame/libmp3lame/.libs -L/Users/yoav/src/faad2-2.7/libfaad/.libs -L/Users/yoav/src/faac-1.28/libfaac/.libs -L/Users/yoav/src/x264/'
    libavutil 50. 3. 0 / 50. 3. 0
    libavcodec 52.27. 0 / 52.27. 0
    libavformat 52.32. 0 / 52.32. 0
    libavdevice 52. 2. 0 / 52. 2. 0
    libswscale 0. 7. 1 / 0. 7. 1
    built on Apr 22 2009 23:15:53, gcc: 4.0.1 (Apple Inc. build 5484)

    Seems stream 1 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (60000/2002)
    Input #0, mpeg, from '/Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg':
    Duration: 01:02:01.53, start: 0.833922, bitrate: 6015 kb/s
    Stream #0.0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.1[0x1e0]: Video: mpeg2video, yuv420p, 480x480 [PAR 4:3 DAR 4:3], 9000 kb/s, 29.97 tbr, 90k tbn, 59.94 tbc
    At least one output file must be specified

    DEBUG:pyTivo.video.transcode:aFreq=48000; vFps=29.97; container=mpeg; kbps=6015; mapAudio=[('0.0', '[0x1c0]')]; vHeight=480; vCodec=mpeg2video; Supported=True; millisecs=3721530; par=None; aKbps=192; par2=1.33333333333; par1=4:3; mapVideo=0.1; vWidth=480; dar1=4:3; aCodec=mp2
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:TRANSCODE=NO, all compatible, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:TRANSCODE=NO, all compatible, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:08] "GET /TiVoConnect?Command=QueryContainer&Container=Our%20Video%20Library%2FTelevision%20Shows%2FLost&SortOrder=!CaptureDate&ItemCount=1&AnchorItem=%2FOur%2520Video%2520Library%2FTelevision%2520Shows%2FLost%2FLost%2520-%2520Dead%2520Is%2520Dead.mpg&AnchorOffset=-1&Filter=x-tivo-container%2Ftivo-videos,x-tivo-container%2Ffolder,video%2Fx-tivo-mpeg,video%2F* HTTP/1.1" 200 -
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:TRANSCODE=NO, all compatible, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:TRANSCODE=NO, all compatible, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:09] "GET /TiVoConnect?Command=TVBusQuery&Container=Our%20Video%20Library&File=%2FTelevision%20Shows%2FLost%2FLost%20-%20Dead%20Is%20Dead.mpg HTTP/1.1" 200 -
    INFO:pyTivo:192.168.2.3 [24/Apr/2009 22:14:31] "GET /Our%20Video%20Library/Television%20Shows/Lost/Lost%20-%20Dead%20Is%20Dead.mpg HTTP/1.1" 200 -
    DEBUG:root:CACHE HIT! /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:TRANSCODE=NO, all compatible, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    DEBUG:pyTivo.video.transcode:/Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg is tivo compatible
     
  18. Apr 24, 2009 #478 of 1437
    TadK

    TadK New Member

    19
    0
    Oct 19, 2007
    I am constantly amazed by you guys....
     
  19. Apr 24, 2009 #479 of 1437
    Yoav

    Yoav New Member

    1,048
    0
    Jan 12, 2007
    Code:
    DEBUG:pyTivo.video.transcode:TRANSCODE=NO, all compatible, /Volumes/TiVoShows/Television Shows/Lost/Lost - Dead Is Dead.mpg
    
    So at least for this video, it looks like it's now doing the right thing... :)

    Cool, and you can thank wmcbrine for fixing it this quickly...

    -- yoav
     
  20. Apr 25, 2009 #480 of 1437
    wmcbrine

    wmcbrine Ziphead

    10,364
    22
    Aug 2, 2003
    Oh, I knew it worked. My concern was (and is) that it might work "too well", passing through something it shouldn't.
     

Share This Page