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.



19 Responses to “ “A Deep Dive Into YouTube FLV Video”

  1. Timbob says:

    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 says:

    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. Jaime Macias says:

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

    JM

  4. perde says:

    good text thank you

  5. Ozgur Uksal says:

    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 says:

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

  7. idleboy says:

    that gr8 post and sue full information

    thanks

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

  9. plastik kart says:

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

  10. Perde says:

    Interesting. Curious if i can get the same using ffmpeg.

  11. perde says:

    Thanks I’ve been developing a flv player that will play directly youtube videos, so your article was quite helpful for me:)

    I will be referencing your article from my web site.

    Thanks again.

  12. Thank you very much for this useful post……..

  13. Tül Perde says:

    Thanks I’ve been developing a flv player that will play directly youtube videos, so your article was quite helpful for me:)

  14. medyum says:

    good text thank you

  15. Thanks I’ve been developing a flv player that will play directly youtube videos, so your article was quite helpful for me. I wish you continued success.

  16. senao says:

    thanks I’ve been developing a flv player that will play directly youtube videos, so your article was quite helpful for

  17. Akupunktur says:

    Was a very good expression. Pictures are very clear and beautiful. thank you.

Leave a Reply