How does Google Video let you jump to any part of a video?
February 11, 2008 9:23 AM   Subscribe

How does Google/YouTube manage to allow a user to jump to any part of a video without having it preloaded first? Is it the player they use or maybe how the video file is hosted?

I've got a client with a fairly standard 4-minute demo video they want to put up on their site. They'd like to be able to let a user click on some tabs across the top to jump to various sections. I've got this all working as long as the video has already finished preloading past that point in the video.

I'm not really sure how much it will help, but here's a link to the project.

I'd love to be able to have the same ability that, say, Google video uses where you can link directly to a specific point in the video without needing to have the video preloaded up to that point.

Is there a tutorial or some other resource out there with a good explanation of how to do this?
posted by ssmith to Computers & Internet (8 answers total) 1 user marked this as a favorite
 
there are 2 ways. one is to use a streaming server such as fms or red5. the other, the one that i believe google uses is a random-seek script that allows you to start streaming a file from any position in the file.

since flvs can play if any number of frames are loaded, you don't need anything special to seek in the file randomly.

here's one version
posted by klanawa at 9:35 AM on February 11, 2008


i shoud note that using this system, you can't - afaik - go back. when you seek in the file, you are effectively creating a new flv with the first section cut off.
posted by klanawa at 9:38 AM on February 11, 2008


Flash Video (FLV) files cannot be streamed from the middle directly. For that you need to server the videos using RTMP using Adobe stream server or spend some time hacking the open-source red5. FLV files are sent via simple HTTP just like any other webpage or image.

Google and YouTube let you jump to a specific part of the video by sending a new dynamic FLV file over HTTP that starts very close to the time you wish to jump to. In other words, every time you click on the trackbar and the FLV hasn't loaded that segment yet, it loads a whole new partial FLV starting at that point. The original full FLV has keyframe(time)->byte mapping stored so the SWF player can figure out which position in time means which byte of the FLV to start streaming from.
posted by chime at 9:42 AM on February 11, 2008 [1 favorite]


Response by poster: *sigh* I figured it was something that would be unavailable to mere mortals. Thanks for the explanation.
posted by ssmith at 9:50 AM on February 11, 2008


well since you said you wanted to have predefined tabs across the top sending the user to the different sections of the video, couldn't you treat each section as its own video? when the video gets loaded initially, do a little scripting to have it start preloading the other videos in the background. that way when the user clicks any of the tabs, that portion of the movie is ready to go.

just a thought, not sure if it'll actually work since i haven't actually done any realy flash work since flash5 haha.
posted by hummercash at 9:59 AM on February 11, 2008


Seconding hummercash's suggestion of separate video files. You'd need to segment the progress bar (ideally both logically and visually) so that the right video is displayed, make the next one start when the current one finishes (ideally just before), etc., but it'd work.
posted by malevolent at 10:04 AM on February 11, 2008


chime is right that there is a bit of meta that needs to be in the flv for it to work, but the php script i linked to does that. you do not need a streaming server to use that script.
posted by klanawa at 10:45 AM on February 11, 2008


Decidedly available to mere mortals: check out nginx and lighttpd with mod_flv_streaming.

Gotta make sure your flv's have metadata, but it should work.
posted by Freen at 4:25 PM on February 11, 2008


« Older Metafilm   |   Me Talk Pretty German One Day Newer »
This thread is closed to new comments.