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

Video Streaming in HME

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

  1. Aug 1, 2008 #1 of 93
    wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    I mentioned this in the "HME for Python" thread, but it deserves its own.

    With the release of 9.4 software, HME can now do streaming video on Series 3/TiVo HD. TiVo hasn't published specs for this yet, but here's what I've found so far.

    Basically, you create a stream as you would for an MP3, and then set the resource of a view to that stream. Normally you'd use the root view, but you can use any view. The stream is not resized to fit the view, but cropped (i.e., the view acts as a window on the stream). The stream is displayed according to the system's aspect ratio settings, with respect to the full screen (and then the view, if smaller than the screen, takes a portion of this). The stream appears to be displayed at the system's output resolution, not the HME resolution.

    MPEG-4 (as used in the YouTube app) and MPEG-2 (traditional TiVo material), at least, are supported. Since MPEG-2 works, perhaps this feature (although not the YouTube app) will even be available on Series 2's in the future.

    Any kind of HME graphics can be displayed over the video.

    Here's a trivial app to do a video stream using HME for Python:

    Code:
    import hme
    
    TITLE = 'Video Test'
    CLASS_NAME = 'VidTest'
    
    class VidTest(hme.Application):
        def startup(self):
            stream = hme.Stream(self, 'http://%s/vidtest/test.mp4' % 
                                self.context.headers['host'])
            self.root.set_resource(stream)
    
     
  2. Aug 1, 2008 #2 of 93
    jbcooley

    jbcooley New Member

    55
    0
    May 13, 2007
    This is great. Thanks a lot. Look for a new release of my .NET sdk soon.
     
  3. Aug 1, 2008 #3 of 93
    wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    For me it didn't require any updates, although I'll probably update the documentation (and I have a lot of changes to hmeserver, but that's nothing to do with this).
     
  4. Aug 2, 2008 #4 of 93
    wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    Multiple simultaneous streams: Does not work. (I didn't expect it to, but it was worth a try.)

    Completed video streams return a resource status of 11, an undocumented value.

    The TiVo makes a second request for the stream after it's already started playing it, then immediately aborts the second request. I don't know why yet.
     
  5. Aug 2, 2008 #5 of 93
    Allanon

    Allanon Member

    580
    0
    Nov 2, 2005
    Will this work with .tivo files?
     
  6. Aug 2, 2008 #6 of 93
    wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    No. You'll have to unwrap them to plain MPEG-2 first.
     
  7. Aug 2, 2008 #7 of 93
    Allanon

    Allanon Member

    580
    0
    Nov 2, 2005
    Here is my code:
    Code:
    import hme
    
    TITLE = 'Video Test'
    CLASS_NAME = 'VidTest'
    
    class VidTest(hme.Application):
        def startup(self):
            self.stream = hme.Stream(self, 'http://%s/vidtest/test.mp4' % 
                                self.context.headers['host'])
            self.root.set_resource(self.stream)
    
    
        def handle_key_press(self, code, rawcode):
            if code == hme.KEY_PLAY:
                self.stream.play()
            
            if code == hme.KEY_PAUSE:
                self.stream.pause()
    
            if code == hme.KEY_REVERSE:
                self.stream.set_speed(-3)
            
            if code == hme.KEY_FORWARD:
                self.stream.set_speed(3)
    
    The video goes fast forward nice and smooth but rewind is very choppy. Any ideas why? Is my code OK?
     
  8. Aug 3, 2008 #8 of 93
    wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    I see the same thing in the YouTube app. I think it's just what you can expect with MPEG-4. TiVo-sourced MPEG-2 reverses a bit more smoothly.

    And yes, your code looks fine. :)

    Now we just need to figure out how to get it to start up faster (as the YouTube app does), and ideally, how to get rid of the second request (or at least why it's there).
     
  9. Aug 3, 2008 #9 of 93
    jbcooley

    jbcooley New Member

    55
    0
    May 13, 2007
    The youtube app supports three levels of fast forward and three levels of reverse. I can only get speeds of +3 and -3 to work reliably. Any ideas on what value tivo is using for the other speeds?

    Any ideas about the time bar at the bottom? Is this something we have to simulate in the app or is hme providing that in some undiscovered part of the protocol?
     
  10. wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    You'd have to draw the bar yourself; however, the position data is provided in resource info events.
     
  11. jbcooley

    jbcooley New Member

    55
    0
    May 13, 2007
    I was hoping that the bar could be drawn using system styles. I'd received the system events, I just didn't want to have to draw the progress bar.
     
  12. wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    That's not the kind of thing that HME provides.
     
  13. jbcooley

    jbcooley New Member

    55
    0
    May 13, 2007
    I'd say that's only true because it doesn't provide that feature. It does provide the standard sounds. Since it hasn't provided video support in the past, I just wondered if they had added that as a standard UI feature.

    I guess I should have taken the hint from the absence of a standard progress bar for mp3s.
     
  14. s2kdave

    s2kdave New Member

    515
    0
    Jan 27, 2005
    I made a playbar component which does what you want in bananas-plus.
     
  15. jbcooley

    jbcooley New Member

    55
    0
    May 13, 2007
    Thanks for the offer, but I'm going to have to work that out for myself due to licensing and language differences. I've got my own .net hme sdk that I need to get working. I've gotten initial support for streaming video done, but wanted to see if there were any additional known parameters for the streaming video.

    I'll probably come back and do my own take on bananas once I get my application hosting service done.
     
  16. wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    But it doesn't provide any complex (or "themed") visual elements, at all. For the Java people, that's all in the Bananas library, which just copies the system elements (it doesn't access them). A progress bar falls squarely in that area. To add such a thing to HME would, IMHO, be a more radical change than adding video streaming.

    I'm not saying it's a bad idea, just that there's no reason to expect it.
     
  17. perrce

    perrce New Member

    79
    0
    Feb 7, 2007
    For what it's worth, I just noticed that getStream() is being called twice for MP3's as well. I assume it's related.
     
  18. s2kdave

    s2kdave New Member

    515
    0
    Jan 27, 2005
    This is because it's parsing the header info when it's an mp3 file so it can pass the duration with the first request. It immediately closes the stream after that though. it's all done in the Factory class.
     
  19. wmcbrine

    wmcbrine Ziphead

    10,363
    22
    Aug 2, 2003
    According to uk.tivo.com, the regular trick play speeds are 3x, 18x and 60x.
     
  20. perrce

    perrce New Member

    79
    0
    Feb 7, 2007
    Does the support of MPEG-4 video have any implications for the support of MPEG-4 audio (i.e. AAC)? In other words, could AAC audio be played through the MPEG-4 decoder? Or is AAC a whole different issue?
     

Share This Page