views:

103

answers:

4

Basically I'm trying to replicate YouTube's ability to begin video playback from any part of hosted movie. So if you have a 60 minute video, a user could skip straight to the 30 minute mark without streaming the first 30 minutes of video. Does anyone have an idea how YouTube accomplishes this?

+2  A: 

Video is a series of frames, played at a frame rate. That said, there are some rules about the order of what frames can be decoded.

Essentially, you have reference frames (called I-Frames) and you have modification frames (class P-Frames and B-Frames)... It is generally true that a properly configured decoder will be able to join a stream on any I-Frame (that is, start decoding), but not on P and B frames... So, when the user drags the slider, you're going to need to find the closest I frame and decode that...

This may of course be hidden under the hood of Flash for you, but that is what it will be doing...

dicroce
+1  A: 

I don't know how YouTube does it, but if you're looking to replicate the functionality, check out Annodex. It's an open standard that is based on Ogg Theora, but with an extra XML metadata stream.

Annodex allows you to have links to named sections within the video or temporal URIs to specific times in the video. Using libannodex, the server can seek to the relevant part of the video and start serving it from there.

ctford
+1  A: 

If I were to guess, it would be some sort of selective data retrieval, like the Range header in HTTP. that might even be what they use. You can find more about it here.

Bevin
+3  A: 

Well the player opens the HTTP resource like normal. When you hit the seek bar, the player requests a different portion of the file.

It passes a header like this:

RANGE: bytes-unit = 10001\n\n

and the server serves the resource from that byte range. Depending on the codec it will need to read until it gets to a sync frame to begin playback

Byron Whitlock
Thanks Byron, this is exactly what I was looking for.
Jon Biddle