12

I'm writing a video player in HTML5. I tried to see what Youtube was doing to prevent somebody from just grabbing the source (ie: the .src URL) and then downloading the video file, but it does not seem to be visible.

  • So how do they do it?

  • Have people found a way around it?

  • Is it some complicated DRM implementation?

VC.One
  • 14,790
  • 4
  • 25
  • 57
pratikm
  • 4,034
  • 7
  • 25
  • 23
  • http://www.clipconverter.cc – Rachel Gallen Jul 08 '14 at 15:23
  • 1
    All youtube videos are downloadable. There are loads of browser plugins to do just that without the hassle of looking at the source. – Andy Jul 08 '14 at 15:26
  • 1
    What do you mean, "it does not seem to be visible"? I just inspected the DOM on a YouTube page and the video is right there—it's a ` – Jordan Running Jul 08 '14 at 15:29
  • 3
    for longer clips, they break up each file into many urls with unique addresses, so you can't just grab the whole file in one go, and they can better detect when you try to cheat or download the same thing more than once and stuff (since that url is yours alone). – dandavis Jul 08 '14 at 16:08
  • You need a utility like youtube-dl to save them --- http://rg3.github.io/youtube-dl/ – Tasos Jul 08 '14 at 17:03
  • Does this answer your question: [Prevent HTML5 video from being downloaded (right-click saved)?](https://stackoverflow.com/questions/9756837/prevent-html5-video-from-being-downloaded-right-click-saved) – wuerfelfreak Jan 05 '21 at 08:52
  • @clickbait Is there any extra or specific info you want to add about your own situation to solve? – VC.One Jan 07 '21 at 09:46

2 Answers2

3

As I found on Quora:

The videos posted on YouTube are first encrypted with 128- bit SSL encryption, which is very tough to crack. Also, for longer clips the software breaks up each file into many URLs with unique addresses, which makes it impossible to download the video in one go.This also helps the software to better detect when the video is being downloaded and the identity of the person downloading the video since each URL is uniquely generated.

Also to get to know more about how to break the video into parts check for adaptive streaming formats such as HLS and DASH. Also recommend you to check for HLS Streaming with the file extension of .m3u8.

Also there are companies has services that known as Video on Demand(VoD) that would help you.

If you need a player for your videos I recommend VideoJs which is open source and in my opinion very powerful.

  • 2
    I won't down-vote (because is still useful about VOD etc) but this is a **wrong** understanding of Youtube's video serving method... Things like _"videos posted on YouTube are first encrypted with 128- bit SSL encryption..." and _"...impossible to download the video in one go"_ are not true. It is even possible to parse the direct links to MP4 files from the video page's own source code (with some extract and clean-up effort on certain values in source). I will explain later when time allows. – VC.One Jan 07 '21 at 09:42
  • 1
    Thanks for the note, as I mentioned that was a research but there is no 100% way to prevent downloading videos because they are available in the page source code. Also with VOD there would be a playlist for short files of whole video that by binding them together you'll have the video. – Mehdi Shahamirian Jan 11 '21 at 09:05
3

First and foremost Youtube videos are downloadable There are browser extensions, 3rd party websites and more for downloading from youtube. In fact, any video that can be played on a browser via Internet is downloadable.

However, embedding a video directly using a HTML5 video tag is super easy to download.

Take the e example code from w3schools

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

You can just Right click >Save as the video to download it.

There are other aspects too, which makes this approach of directly embedding video unusable in a service like Youtube. Features like video track selection, used for allowing multiple resolution, streaming the video rather than downloading the whole video before even playing, live streaming are just not possible with this direct approach.

Buffer approach Using this approach, the video element just points to a buffer, where data is pushed dynamically using Javascript. Using this approach allows the features mentioned above which are not possible with the direct approach.

Check out this article on medium to understand about building your own media streaming HTML5 player.

If you use this approach, then users of your website can not Right click> Save on your video to download it. They can, however use a browser plugin to do so.