TiVo Community
TiVo Community
TiVo Community
Go Back   TiVo Community > Underground Playground > Developers Corner
TiVo Community
Reply
Forum Jump
 
Thread Tools
Old 08-01-2008, 08:38 PM   #1
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
Video Streaming in HME

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)

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-01-2008, 08:49 PM   #2
jbcooley
Registered User
 
Join Date: May 2007
Posts: 54
Quote:
Originally Posted by wmcbrine View Post
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.
This is great. Thanks a lot. Look for a new release of my .NET sdk soon.
jbcooley is offline   Reply With Quote
Old 08-01-2008, 09:36 PM   #3
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
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).
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-02-2008, 08:10 AM   #4
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by wmcbrine : 08-02-2008 at 09:03 AM.
wmcbrine is offline   Reply With Quote
Old 08-02-2008, 10:26 AM   #5
Allanon
Registered User
 
Join Date: Nov 2005
Posts: 521
Will this work with .tivo files?
Allanon is offline   Reply With Quote
Old 08-02-2008, 11:23 AM   #6
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
No. You'll have to unwrap them to plain MPEG-2 first.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-02-2008, 05:18 PM   #7
Allanon
Registered User
 
Join Date: Nov 2005
Posts: 521
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?
Allanon is offline   Reply With Quote
Old 08-03-2008, 10:04 AM   #8
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
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).
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-03-2008, 04:33 PM   #9
jbcooley
Registered User
 
Join Date: May 2007
Posts: 54
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?
jbcooley is offline   Reply With Quote
Old 08-03-2008, 06:05 PM   #10
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
You'd have to draw the bar yourself; however, the position data is provided in resource info events.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-03-2008, 07:04 PM   #11
jbcooley
Registered User
 
Join Date: May 2007
Posts: 54
Quote:
Originally Posted by wmcbrine View Post
You'd have to draw the bar yourself; however, the position data is provided in resource info events.
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.
jbcooley is offline   Reply With Quote
Old 08-03-2008, 08:11 PM   #12
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
That's not the kind of thing that HME provides.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-03-2008, 08:52 PM   #13
jbcooley
Registered User
 
Join Date: May 2007
Posts: 54
Quote:
Originally Posted by wmcbrine View Post
That's not the kind of thing that HME provides.
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.
jbcooley is offline   Reply With Quote
Old 08-03-2008, 09:53 PM   #14
s2kdave
Registered User
 
Join Date: Jan 2005
Posts: 515
Quote:
Originally Posted by jbcooley View Post
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.
I made a playbar component which does what you want in bananas-plus.
s2kdave is offline   Reply With Quote
Old 08-03-2008, 10:40 PM   #15
jbcooley
Registered User
 
Join Date: May 2007
Posts: 54
Quote:
Originally Posted by s2kdave View Post
I made a playbar component which does what you want in bananas-plus.
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.
jbcooley is offline   Reply With Quote
Old 08-04-2008, 06:58 AM   #16
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
Quote:
Originally Posted by jbcooley View Post
I'd say that's only true because it doesn't provide that feature. It does provide the standard sounds.
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-04-2008, 02:24 PM   #17
perrce
Registered User
 
Join Date: Feb 2007
Posts: 79
Quote:
Originally Posted by wmcbrine View Post
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.
For what it's worth, I just noticed that getStream() is being called twice for MP3's as well. I assume it's related.
perrce is offline   Reply With Quote
Old 08-04-2008, 03:27 PM   #18
s2kdave
Registered User
 
Join Date: Jan 2005
Posts: 515
Quote:
Originally Posted by perrce View Post
For what it's worth, I just noticed that getStream() is being called twice for MP3's as well. I assume it's related.
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.
s2kdave is offline   Reply With Quote
Old 08-05-2008, 10:18 PM   #19
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
Quote:
Originally Posted by jbcooley View Post
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?
According to uk.tivo.com, the regular trick play speeds are 3x, 18x and 60x.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-06-2008, 02:55 PM   #20
perrce
Registered User
 
Join Date: Feb 2007
Posts: 79
Quote:
Originally Posted by wmcbrine View Post
MPEG-4 (as used in the YouTube app) and MPEG-2 (traditional TiVo material), at least, are supported.
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?
perrce is offline   Reply With Quote
Old 08-06-2008, 10:19 PM   #21
jbcooley
Registered User
 
Join Date: May 2007
Posts: 54
Quote:
Originally Posted by wmcbrine View Post
According to uk.tivo.com, the regular trick play speeds are 3x, 18x and 60x.
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?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbcooley is offline   Reply With Quote
Old 08-07-2008, 12:02 AM   #22
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
Quote:
Originally Posted by jbcooley View Post
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?
I mentioned 11 in post #4, above. I had not yet noticed 12, but I can confirm it now.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-07-2008, 12:35 AM   #23
Allanon
Registered User
 
Join Date: Nov 2005
Posts: 521
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?
Allanon is offline   Reply With Quote
Old 08-07-2008, 09:36 AM   #24
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by wmcbrine : 08-09-2008 at 12:28 PM.
wmcbrine is offline   Reply With Quote
Old 08-07-2008, 09:46 AM   #25
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
Quote:
Originally Posted by Allanon View Post
The program plays fine for about 10 minutes then it crashes.
I think what you're seeing is the standard HME idle timeout. Try adding this:

Code:
    def handle_idle(self, idle):
        return True

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 08-08-2008, 07:24 PM   #26
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by wmcbrine : 08-10-2008 at 01:38 PM.
wmcbrine is offline   Reply With Quote
Old 08-10-2008, 01:55 AM   #27
moyekj
Registered User
 
Join Date: Jan 2006
Location: Mission Viejo, CA
Posts: 9,055
Quote:
Originally Posted by wmcbrine View Post
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.
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

__________________
Roamio Pro, Elite, Premiere
Cox - Motorola CableCards & TAs
Slingbox 350 via TiVo Mini & TiVo Stream for remote viewing

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by moyekj : 08-10-2008 at 02:39 AM.
moyekj is offline   Reply With Quote
Old 08-10-2008, 11:39 AM   #28
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by wmcbrine : 08-10-2008 at 01:38 PM.
wmcbrine is offline   Reply With Quote
Old 08-10-2008, 01:17 PM   #29
moyekj
Registered User
 
Join Date: Jan 2006
Location: Mission Viejo, CA
Posts: 9,055
Quote:
Originally Posted by wmcbrine View Post
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.
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.
__________________
Roamio Pro, Elite, Premiere
Cox - Motorola CableCards & TAs
Slingbox 350 via TiVo Mini & TiVo Stream for remote viewing

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
moyekj is offline   Reply With Quote
Old 08-10-2008, 01:37 PM   #30
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,011
Quote:
Originally Posted by moyekj View Post
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)?
Something like that...

Quote:
Is the long term plan to integrate this as part of pyTivo
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by wmcbrine : 08-12-2008 at 07:44 PM.
wmcbrine is offline   Reply With Quote
Reply
Forum Jump




Thread Tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Advertisements

TiVo Community
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
vBulletin Skins by: Relivo Media

(C) 2013 Magenium Solutions - All Rights Reserved. No information may be posted elsewhere without written permission.
TiVoŽ is a registered trademark of TiVo Inc. This site is not owned or operated by TiVo Inc.
All times are GMT -5. The time now is 06:39 AM.
OUR NETWORK: MyOpenRouter | TechLore | SansaCommunity | RoboCommunity | MediaSmart Home | Explore3DTV | Dijit Community | DVR Playground |