A Deep Dive Into YouTube FLV Video

In my last post I did a quick comparison of Jing screencast video in lossless swf vs lossy flv hosted on YouTube. After seeing the rendered results embedded in a web page I quickly became a bit more curious about YouTube’s flv files and set out to discover some more info.

First, using Safari’s Activity monitor, find and retrieve the flv served up by YouTube:

Safari Activity Monitor

Save the file url to disk and give it a .flv file extension. To discover a little bit more about the YouTube video we’ll need to take a look at its metadata and for that we’ll use a neat little Ruby app Flvtool2 (if you need a primer on using flvtool2 check here and here).

YouTube flv metadata

From the above we can see that YouTube flv files are short on conventional metadata, but interestingly each keyframe’s time, in seconds, and location, in bytes, is stored. This keyframe metadata is likely there for future deep tagging, to assist seeking logic, or waiting for advertising event logic–any way its a cool idea.

We still haven’t officially been able to see the flv’s width and height so it’s time to use flvtool2 to inject some additional metadata into the file and save the result with a new name (utube.flv). Here’s a look at how to accomplish this.

flvtool2 inject metadata

Running flvtool2, once again to read back the new flv file with additional metadata gives us the following:

YouTube flv with additional metadata

It’s clear the file is 320 x 240 and it’s also possible to verify that YouTube is still using the Sorenson Spark .h263 codec by looking at the “videocodecid” attribute that flvtool2 inserted. If you check the Flash file format specification you can see that “2″ is the id corresponding to .h263.

Flash file format spec. video codec id

Pretty interesting stuff–in the future maybe I’ll try to discover some information about Brightcove’s flv media.

7 Comments

  1. Timbob
    Posted July 27, 2007 at 10:16 am | Permalink

    Interesting, but in the future it’d be cool to be more objective with your analysis instead of just assuming stuff. Saying the keyframe time “could” be used for advertising hooks may technically be true, but it’s like me saying your website “could” be used for porn advertisement or scamming (after all, they use HTML for that, don’t they? And this site also uses HTML).

    Don’t get me wrong, it’s a nice look at the flv format, but this is the kind of stuff that will have people typically spamming “omg look youtube has video advertisement features! that’s it I’m moving to *random_video_website*!!” if they don’t read the article carefully.

    Since the frame time is also associated to frame byte count, that metadata is probably used to make the seeking bar more accurate; if you have a flv file with a varying data rate (for example, if there’s a video with some static white text on black background, followed by full-motion video) the time position/duration isn’t equivalent to loaded/total bytes - 50% of the bytes isn’t necessarily half the video time - so you’d need data like that to find out how much of the video was loaded in *time*.

  2. James L
    Posted July 27, 2007 at 11:11 am | Permalink

    A great writeup on your findings. I’ll have to take a look at flvtool2 and see how our internally encoded video differs from our outsourced stuff.

    @Tim
    You seem to have gone off the deep end, m’friend. There was absolutely nothing in the post to spark your beginning comments. Looking at the metadata through the lense of objectivity would lead me to think that a social video portal owned by google might have hooks built into it to trigger advertisements. Google does make most of its revenue through ads, and there isn’t anything wrong about it.

  3. Posted August 31, 2007 at 12:51 pm | Permalink

    The interesting thing would be to know what Rouxbe.com is using. They have the best looking FLVs Ive seen.

    JM

  4. Posted September 20, 2007 at 8:48 am | Permalink

    good text thank you

  5. Ozgur Uksal
    Posted January 29, 2008 at 7:00 pm | Permalink

    I used to wonder about how youtube plays flvs in a good quality. I am impressed about the way you discovered things about youtube flvs. Thank you for sharing your ideas.

  6. Stephan
    Posted February 6, 2008 at 10:43 am | Permalink

    Hey I just stumbled upon this post. Why would Youtube use Metadata and not just cuePoints?

  7. Posted March 13, 2008 at 10:34 am | Permalink

    that gr8 post and sue full information

    thanks

One Trackback

  1. By And He Blogs » links for 2008-03-29 on March 29, 2008 at 1:30 pm

    [...] Brooks Andrus » Blog Archive » A Deep Dive Into YouTube FLV Video (tags: youtube flv video flash) [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*