Video Streaming in HME

Discussion in 'Developers Corner' started by wmcbrine, Aug 1, 2008.

  1. jbcooley

    jbcooley New Member

    55
    0
    May 13, 2007

    Advertisements

    Thanks. I had also found the numbers 3x, 15x, and 60x in the music sample. Still only the 3x works smoothly. Of course, this result is only with one video file I didn't encode. So part of the smoothness (or lack of) in fast foward may due to the file.

    In testing fast forward and normal playback, I noticed two new resource status codes - 11 and 12. 11 seems to happen when you near or hit the end of a playing video stream and 12 occurs when you hit or near the end of a video stream while you are fast forwarding. Have you seen these status codes?
     
  2. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    I mentioned 11 in post #4, above. I had not yet noticed 12, but I can confirm it now.
     
  3. Allanon

    Allanon Active Member

    923
    160
    Nov 2, 2005
    I was watching the HD Quicktime version of Systm using the code I posted above. The program plays fine for about 10 minutes then it crashes. When starting it again and then fast forwarding back to the spot it crashed I was able to watch another 10 minutes until it crashed again. Does this happen to others? Do you know the cause?
     
  4. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    New finding: Although the TiVo ignores the MIME type, it pays attention to the file extension in the URL. Bad!

    Edit: ...but you can override that by specifying the MIME type in the CMD_RSRC_ADD_STREAM. It follows that one, just not the one in the HTTP headers.
     
  5. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003

    Advertisements

    I think what you're seeing is the standard HME idle timeout. Try adding this:

    Code:
        def handle_idle(self, idle):
            return True
     
  6. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    OK, here's a slightly better player app, that supports all the trick play commands (except skip to tick), and makes the appropriate sounds. It also sends a lot of debug output to the console. No on-screen status bar yet, though. Requires HME for Python 0.13 or later.
     
  7. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    Very cool stuff indeed and great job on getting this going. I got this working with mpeg2 and some sample h.264 videos. Will be great once a visual position indicator can be added.

    Is there a way to make a graceful left arrow exit out of the vidtest application? I've got to resort to Tivo Central right now to exit, then find my way back to MPP&M screen again.
    EDIT: Never mind I simply added the following to handle the left arrow to exit:
    Code:
        def handle_key_release(self, keynum, rawcode):
            if keynum == hme.KEY_LEFT:
                self.sound('left')
                self.active = False
     
  8. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    Here's a version with a progress bar. (It's more like a YouTube bar then a TiVo bar, but anyway.) I had a hard time with the autoclear, and it's still not quite right. I also added a "Loading" indicator at startup, since I don't yet know how to shorten that delay.

    BTW, as you can see in this program, multiple views can point to the same video stream.
     
  9. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    Very nice improvements. Are you going to be looking at a video file selector at some point (instead of hardcoding a video inside the code itself)? Is the long term plan to integrate this as part of pyTivo or do you see development continuing on this "proof of concept" app? Thanks again for your hard work on this. I'm not familiar at all with Python but I do work with software quite a lot and have dabbled quite a bit with 3rd party apps for ReplayTV and more recently Tivo.
     
  10. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    Something like that...

    No. Although I still want to try to get pyTivo working with MPEG-4, which is a separate issue.

    Here's version 3 -- in the last one, I was exiting on any status code >= 8 (copied from TiVo's SDK doc, although they were referring to MP3), which turned out to be a mistake, since status 9 (complete) is sometimes returned when the stream is finished buffering.
     
  11. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    So, the progress bar in that version wasn't too legible on a light background, even with the shadows. I think this is better (as well as simpler). I also tried to implement frame-by-frame, but it doesn't work very well. (Although it works better than the last one, which crashed if you pressed ff or rewind while paused.)
     
  12. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    I just tried out a couple of HD mpeg2 files (originally recorded on 1 of my S3s) and found that the streaming speed is not fast enough to play in real time and as soon as playback catches up to the buffer this HME app exits (and I'm thrown out to Tivo Central).

    Is there a way to catch that condition and pause playback to allow buffer to build up?

    EDIT: Simple way to force the issue quickly is to FF. As soon as you catch the end of buffer you are thrown out.
     
  13. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    I'm not sure I can distinguish between running out of buffer, and just coming to the end of the stream. Of course you can disable both, by taking out the "self.active = False" line in handle_resource_info().
    ----
    I just got my first TiVo reboot as a result of using this. :(
    ----
    I can't decide if I prefer the white parts of the progress bar transparent or opaque...
     
  14. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    For lack of a better solution right now I implemented a pause in place of "self.active = False" which works pretty well. i.e. Use the following in it's place: self.change_speed(0)
    As a bonus the way the code is right now once you exceed the buffer and enter pause state the progress bar is displayed and updated so you can watch the buffer building up.

    P.S. I also tried implementing such that 'Info' button would display the name of the video file being streamed, but making the info text time out after a few seconds seems harder than it should be. I ended up having to mimic how you are doing it for the progress bar time out (self.send_key(hme.KEY_TIVO) etc).
     
  15. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    - Finally got autohide working right.
    - Adopted moyekj's suggestion -- go to pause when hitting the end of the buffer/stream, and sound the "alert".
    - Slow motion. 1/2, 1/4 and 1/8 all seemed to work (others may, too); I picked 1/8. Anyone know what it is in regular TiVo playback?
    - Experimentally, since I'm not drawing the little triangles, I'm trying color as an indicator of forward/reverse speed. It's red-shift/blue-shift, getting redder the faster you go forward and bluer the faster you rewind. Let me know what you think.
     

    Attached Files:

  16. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    I think the color coding is a good idea. The only big piece missing now is a file browser of sorts built into the HME app so one can select a video file to play. Is that something doable without a monster amount of code? I can take a stab at it but won't bother if you already have something in mind.

    Also, do you use the Java Simulator for testing purposes? It would be nice to have a way to write code and test it away from the Tivos. I think it's possible but just wanted to check with you what you do.
     
  17. wmcbrine

    wmcbrine Well-Known Mumbler

    11,747
    830
    Aug 2, 2003
    Eh, it wouldn't be particularly difficult, but it would be a fair bit of code, yeah. Mainly because I don't have anything like Bananas yet...

    I'm actually more interested in doing a video podcaster. (There's no reason that URL in the Stream() initializer needs to point back to the HME server.)

    I've used it, but not for this. It doesn't support video.
     
  18. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    Gotcha, and yes I realize streaming can be from any URL and not just localhost. I'm intrigued with the idea of using it locally for a bunch of recordings I have on an external drive attached to my PC. One nice feature is that it would be trivial to setup the remote numbers to jump different intervals of time forwards and backwards. It's possible even to program arbitrary skip forwards and back like ReplayTV supported: i.e. "15, ->" would jump 15 minutes ahead and "15, <-" would jump 15 minutes back.

    Perhaps I'll take a look at implementing some kind of rudimentary file browser with perhaps just a single folder as a starting point. Not having any Python experience won't help. Perhaps I might have to look at the Perl HME module as I've got a lot of Perl experience. I'd think I'd rather try it in Python before Java...
     
  19. moyekj

    moyekj Well-Known Member

    12,178
    827
    Jan 23, 2006
    Mission...
    FYI I ended up implementing this using Java. It's still a work in progress but I have rudimentary file browser for video file selection (on local server machine) and of course the video streaming with the trick play functions. I still need to add a progress bar of some sort and a lot of code cleanup. It was nice to take advantage of BList class in bananas toolkit for the file selection portion.
    I'm really loving this video streaming capability*. Very special thanks to wmcbrine for figuring this out!!

    *NOTE: Technically this is not true streaming as one still cannot jump ahead of the buffer in the stream which is possible in true video streaming.
     
  20. AbMagFab

    AbMagFab What happened, TiVo?

    3,638
    0
    Feb 5, 2001
    Any update on this? I'd love to try one that can support file-selection.

    We should be able to get full directory browsing as well now, right? Finally, we might get Tivo to be a real media player after all? Could it be true?
     

Share This Page

spam firewall

Advertisements