Blogs
YouTube video url protocol
Posted October 19th, 2008 by paulgI was in search of a way to get good 'ole fashioned YouTube Video URLs into my experimental Flash/AIR video player because I don't always want to use YouTube's player in my Flash/AIR applications. But the method of fetching a YouTube video has changed over time, and it's not as easy as it used to be. Actually, it seems as though there are some who are stuck on this problem. So I went ahead and looked at the protocol that the YouTube flash player uses, and reverse-engineered the protocol. Here it is: First, the YouTube "embed" syntax for any YouTube video is:
http://www.youtube.com/watch?v=[id of the youtube video]
e.g., http://www.youtube.com/watch?v=DFNb1MNFhQg
The "v=DFNb1MNFhQg" is the part that we are interested in. The YouTube flash video player takes this id and sends a get_video_info message to YouTube. The message has the following syntax:
http://www.youtube.com/get_video_info?&video_id=DFNb1MNFhQg&eurl=http%3A%2F%2Feduviews%2Ecom%2Fportal%2Fnode%2F74
where video_id = DFNb1MNFhQg and
where eurl = http%3A%2F%2Feduviews%2Ecom%2Fportal%2Fnode%2F74
Obviously, the eurl parameter is the escaped page address of the page containing the YouTube player, and we should use some good manners by appending the proper referring url whenever we request a YouTube video.
Anyway, upon receiving a get_video_info request, the YouTube website responds to the request (if the video is indeed available) with something that looks like the following:
status=ok&title=TIMSS+1999+Math+-+Australia+Public+Release+Lesson+4&muted=0&avg_rating=0.0&creator=paulgrudnitski&length_seconds=85&fmt_map=&token=OEgsToPDskIHld_uhCmeK1KjI6Dp0PPG&thumbnail_url=http%3A%2F%2Fi1.ytimg.com%2Fvi%2FDFNb1MNFhQg%2Fdefault.jpg&allow_ratings=False&track_embed=0
This response contains all kinds of useful/interesting metadata about the video, and I'll leave it up to you to dissect each parameter's meaning.
The part we are most interested in is the dynamically-generated "token=" part. In the above example, this is:
token=OEgsToPDskIHld_uhCmeK1KjI6Dp0PPG
I think this token is what gets people hung up because it must be included in subsequent requests to YouTube. In turn, the YouTube video player takes the Video ID, the Token, and the Referring URL, and sends a get_video message to YouTube. This looks like the following:
http://www.youtube.com/get_video?video_id=DFNb1MNFhQg&t=OEgsToPDskIVpT7H5xtpR1kfvoixGXpu&eurl=http%3A%2F%2Feduviews%2Ecom%2Fportal%2Fnode%2F74
YouTube will respond with a redirect to the actual video address. In this case, the response is:
http://chi-v152.chi.youtube.com/get_video?video_id=DFNb1MNFhQg&signature=3BB3288DBEE10F1EAE1C4D2846670B4B05963ABA.8F8F76B88706247FDF158C2EFAAF27AA744873F2&ip=24.24.255.17&ipbits=2&expire=1222652846&key=yt4&sver=2
All we need to do is feed the get_video request to any Flash Video Player's source property before the token expires and you've got a valid handle to the YouTube video with video id of DFNb1MNFhQg.
Here's the Flex Source for such a player, plus the php code you need on your server for the proxy.
- paulg's blog
- Login or register to post comments
TIMSS Math Video Case Profiler (with cacheing)
Posted November 14th, 2007 by paulg
What can I say? It's been too long since my last post. But I've been busy...really busy. This post is a follow-up to my previous post which introduced the TIMSS Science Video Case Profiler.
One of the important things that researchers have wanted to do with the TIMSS video cases is present them or discuss them at conferences or meetings. Such presentations must often be done in an environment where Internet connectivity is limited or unavailable. The researchers have mentioned that this can present a big problem because the video files in these video cases are quite large, and presentation of the video cases can be risky or cumbersome - not the sort of thing that a presenter wants to worry about while presenting.
This version of the TIMSS Math Video Case profiler enables cacheing of video case data and video on a case-by-case basis. The cacheing can be done in "batch" mode (all at once), or just through regular browsing of the data in each case. Once a video case is "cached", it can be viewed and presented when entirely disconnected from the Internet. Cacheing also greatly improves video performance. It is a client-side application, based on Adobe's AIR framework that can be downloaded and installed on your PC or Mac.
Similar to the TIMSS Science profiler, this application "packages" eight of the TIMSS Math video cases in such a way that they can be viewed as a collective archive. The TIMSS study was funded, in part, by the NCES, and involves researchers from all over the world with the research based at the LessonLab Research Institute, an independent research arm of Achievement Solutions at Pearson. These video cases may only be used for educational research purposes.
(make sure you download and install the AIR framework first)
Download/Install the TIMSS-R Math Video Profiler
- paulg's blog
- Login or register to post comments
TIMSS Science Video Case Profiler
Posted June 15th, 2007 by paulg
One of the things that I've wanted to do since I left LessonLab (a.k.a., Pearson Achievement Solutions) is to build an application that "packages" the TIMSS Science video cases in such a way that they can be searched and viewed as a collective archive.
As part of their report to the NCES, the amazingly smart researchers at the LessonLab Research Institute produced a beautiful CD set containing the sample video cases from the 5 participating countries. Unfortunately, we never really had the time or budget to produce an online version of the CD set. Furthermore, even an online version wouldn't satisfy the needs of those who want to present the video cases at a conference where internet connectivity can be sketchy.
To solve this problem, I decided (after being prodded by some colleagues) to build what I call the TIMSS Science Video Case Profiler. This application is currently in an Alpha version. It is a client-side application, based on Adobe's AIR framework that can be downloaded and installed on your PC or Mac. The application allows browsing of a portion of the TIMSS Science video case archive. If time permits, I will be adding more cases to the archive, and also adding features such as offline caching in order to support disconnected video case viewing and presentation.
(make sure you download and install the AIR framework first)
Download/Install the TIMSS-R Science Video Case Profiler
- paulg's blog
- Login or register to post comments