68

I'm developing an application that displays youtube videos. I want to store the video id's in a database, but because there are going to be a lot of videos, I want to minimize the required space, so does anyone know the maximum length of a video id on youtube?

3 Answers 3

95

It's almost certainly going to stay at 11 characters. The individual characters come from a set of 64 possibilities (A-Za-z0-9_-).

64^11 is somewhat more than 2^64. (10 characters would not be enough.) So basically each youtube ID is actually a 64bit number. And I quite doubt they will ever run out of those.

If you want to save space in your database you could theoretically convert the IDs to 64bit numbers then convert them back later. But you would need to know how youtube does the conversion so it's not practical. (Since 64^11 is more than 2^64 you can't store all possibilities, so you need to know which ones are impossible and google doesn't say.)

It takes 66 bits to store all possibilities. So you could actually store a 64bit number plus a 2 bit number and save some space that way. Or more practically store 9 8bit values - you would save only 2 bytes per record though over storing it as text, so it's probably not worth it.

15
  • 5
    FYI to all those wondering (like me): see Jeffrey's answer (Google API team), there is no commitment by Google regarding this size. groups.google.com/forum/?fromgroups=#!topic/youtube-api-gdata/…
    – TheZuck
    Jan 17, 2013 at 10:50
  • 38
    @TheZuck I know they didn't commit to it, but I'm comfortable with saying it's not going to change because there is no reason for them to change it: 64 bits is enough for each human on earth to upload 2 billion videos.
    – Ariel
    Jan 18, 2013 at 10:13
  • 15
    @Ariel I love stats like that. I plan to fill my quota.
    – andyface
    Feb 19, 2013 at 9:50
  • 9
    @Ariel Your comment is extremely naive and assumes that the only reason to change the video identifier is due to running out of space. There are numerous other factors, and in google's case the biggest likely secondary factor is PAYING CUSTOMERS. I wouldn't be surprised if at some point they allow youtube "partners" to purchase short URL identifiers. When Google says they won't confirm your suspicion, its because they are reserving the right for such changes in the future if desired one day. I'm not saying they will do this, but pointing out that you can't say they won't.
    – BenSwayne
    Aug 12, 2014 at 21:41
  • 10
    @BenSwayne First I never said "they won't", I said "almost certainly". Second I'm not in the slightest worried - if they would change it they would break many sites, which they won't do unless forced, and running out of space is the only thing that would force them, and that's not a concern. If they added premium ID's it would be via a different letter (i.e. not v= but something else).
    – Ariel
    Aug 13, 2014 at 2:16
20

The video ID of a YouTube video is currently 11 characters in length. Here are a few links that I found:

http://drupal.org/node/175482

http://snipplr.com/view/19232/retrieve-youtube-video-id-from-a-yt-url/

However, while this is the current standard, there is no official stance on how long the video ID can be. Here is a posting to that effect from a team member at YouTube:

http://osdir.com/ml/youtube-api-gdata/2009-10/msg00237.html

-7

I've found this video id jCJ7pHxKlEM1youtube that has a video id of 12 characters.

1
  • 45
    Youtube actually crops the video to 11 characters. You can provide the jCJ7pHxKlEMxxxxxxxxxxxxxxx and will still get the video with id jCJ7pHxKlEM.
    – Vestalis
    Feb 9, 2017 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.