YouTube is a social video-sharing website hosting millions of videos, with advanced features like subtitles and annotations, video commenting and more.

Video Formats[edit | edit source]

Videos are usually available in multiple formats, as specified by a numeric format id (fmt).

Format: 34 18 35 22 37 17
Format Name: Standard (360p) Medium High HD (720p) HD (1080p) Mobile
Container: FLV MP4 FLV MP4 MP4 3GP
Video Codec MPEG-4 AVC (H.264) MPEG-4 Part 2
Aspect Ratio 4:3 or 16:9 4:3 16:9 16:9 16:9 11:9
Max Resolution 640x360 480x360 864x480 1280x720 1920x1080 176x144
Average Bitrate (kbit/s) 500 512 900-1200 2000 3500 58
Frame Rate (fps) Unknown 50 25 23.96 11.24
Audio Codec AAC
Channels 2 1
Sampling Rate (Hz) 44100 22050
Average Bitrate (kbit/s) Unknown 128 232 90 20

Downloading a video[edit | edit source]

There are multiple methods used to gather the video's download URL. Most methods contain tokens which are tied to a specific IP address and expire after a short amount of time.

Method 1[edit | edit source]

  1. Get the VIDEO ID
  2. Navigate to and your VIDEO ID.
  3. View the source code and extact the "t" value from inside SWF_ARGS
  4. Copy that t value (without quotes) and paste after

Method 2[edit | edit source]

  1. Get the VIDEO ID
  2. Navigate to and your VIDEO ID.
  3. Split the & key = value string up to find "fmt_url_map", then deocode the URL escaped characters.
  4. Split the string by commas, then find the format you like (the first two numbers in each of the results).
  5. Split by the | character and use the second returned string as the video URL.

Video Annotations[edit | edit source]

YouTube recently introduced annotations, allowing users to create 'links' and other pop-up text in the flash YouTube player. Unfortunatley, as they rely on the flash player you cannot see them when you download it.

But, in any case, the syntax for viewing the XML file where the flash player gets the info of what annotations to put where and when is stored at:<your_video_id>

where obviously you must replace "<your_video_id>" with the actual video id.

Just a note of warning to those trying to do stuff with it, the server may return it in a gzip compressed format, so watch out if so.

I personally don't know much about the format of the files, so if anyone would like to contribute that, it would be appreciated.

Video Subtitles[edit | edit source]

YouTube finally released support for subtitles, and of course, they did it in a nice way for us to use... not really.

Firstly, we have to get the list of subtitles to determine what language the subtitles are in, and what they called them. So open up the url:<your_video_id>&ts=<ts_value>&type=list&tlangs=1

where you put in your video id. The ts value, i'm not quite sure how to get it or what it does - but you can safely leave it empty for now.

This URL should return an XML file with <transcript_list docid="some-number"> as the root element and all the languages YouTube supports. In this file, all subtitle tracks have a self-closing <track> tag with the attributes:

  • id - the subtitle track id
  • name - the name of the subtitle track
  • lang_code - the language ISO 639-21 code of the track
  • lang_original - the name of the language in that language (WARNING! many languages will contain non-ascii text)
  • lang_translated - the name of the language in your language (NOTE: your language is set by the hl parameter in the url. Changing this will translate these to that language and change the default language returned)
  • cantran - true/false - if the track can be translated by the automatic translation engine or not

Using these attributes of your selected track, you can get the subtitles in TimedText XML format by going now to the url:<your_video_id>&ts=<ts_value>&type=track&name=<name>&lang=<lang_code>

where name and lang_code are url escaped versions of the attributes above.

To translate the subtitles to another language, add "&tlang=" and the ISO code of the language to be translated to.

More[edit | edit source]

See for more... (this will eventually be copied over here)

Community content is available under CC-BY-SA unless otherwise noted.