-1

How can you disable downloading a video in HTML5? I Do not understand this and anyway the question doesn't have a satisfactory answer

Community
  • 1
  • 1
javaseaayameradost
  • 119
  • 1
  • 3
  • 12
  • 1
    As it says, you can't, but as an answer also says you can disable right click with `$('#videoElementID').bind('contextmenu',function() { return false; });`. Preventing video download properly is not a simple thing. Maybe you should ask why you care? – Dominic Apr 28 '14 at 14:49
  • 1
    Short answer - you can't. If a user can download/stream your video content to view it, they can also save it. – scunliffe Apr 28 '14 at 14:50
  • @scunliffe You actually can! try user3549636's code man it's AMAZING – javaseaayameradost Apr 28 '14 at 15:22
  • @Quentin Of course there is a simple way check the answer out!! – javaseaayameradost Apr 28 '14 at 15:23
  • @javaseaayameradost — The answer doesn't work. – Quentin Apr 28 '14 at 16:44
  • Hmm, where did my original comment go? This is a duplicate of [Prevent HTML5 video from being downloaded (right-click saved)?](http://stackoverflow.com/questions/9756837/prevent-html5-video-from-being-downloaded-right-click-saved) – Quentin Apr 28 '14 at 16:44
  • @quentin the answer _Does_ Work if you don't agree with user3549636's answer thats your choice, but even **I** can't download the video. I tried all the methods you suggested for finding the url but none work. Please remove your comment at least until you can back it up – javaseaayameradost Apr 28 '14 at 18:51
  • @javaseaayameradost in Chrome, right-click, inspect element, edit attribute, change the size of the overlay div to 1x1. Presto, right-click works again. – David Moles Apr 28 '14 at 19:21
  • @javaseaayameradost — I have backed it up, with screenshots. If that is insufficient, please provide a URL of a test server and I shall demonstrate that it is trivial to bypass by copying the video somewhere. – Quentin Apr 28 '14 at 22:31

1 Answers1

-4

Im not really Sure about your question but from what I understand, you want to stop people from downloading your html5 video. To do so you can Either use this method or mine: make 2 cshtml pages: page and ogvpage (you have tagged your question asp.net). insert this code in page:

var request = UrlData[0];
if(Request.Cookies["allow"] != null){
Response.Redirect(Href("VIDEO PATH", request + ".mp4"));
}

and this in ogvpage:

    var request = UrlData[0];
if(Request.Cookies["allow"] != null){
Response.Redirect(Href("VIDEO PATH", request + ".ogv"));
}

page 1 will serve the mp4 video and 2 will serve ogv. open the page you want video on and replace your video element with this:

    <video>
    <source src="/page/video name without extention" type="video/mp4"/>
    <source src="/ogvpage/video name without extention" type="video/ogv>
    </video>

and finally put this at the top of your page:

    if(Request.Cookies["allow"] == null){
    HttpCookie myCookie = new HttpCookie("allow");
    myCookie.Value = "true";
    myCookie.Expires = DateTime.Now.AddSeconds(5);
    Response.Cookies.Add(myCookie);
}
Community
  • 1
  • 1
DividedByZero
  • 4,333
  • 2
  • 19
  • 33
  • does this code stop download properly? – javaseaayameradost Apr 28 '14 at 15:13
  • THANK YOU!! this code is amazingggg! I've tried all possible ways of downloading a video on my website but not one works! I don't know how to thank you sir! – javaseaayameradost Apr 28 '14 at 15:21
  • try it, it's a 0.5kb page to load that takes less time to load thn the flash player itself – DividedByZero Apr 28 '14 at 15:25
  • Using any proxy/curl/http tools obtaining the video content will be easy. Blocking the saving of web based files is akin to the old idea of hiding the "view source" of your HTML so that people can't copy/steal it. (that failed miserably) – scunliffe Apr 28 '14 at 15:26
  • 2
    @user3549636 — Show me a test server. I'll show you a copy of the video. – Quentin Apr 28 '14 at 15:27
  • as long as it works I guess it should do. because downloading the video by right clicking basically means you'll download a htm file. and viewing the source would show you the path to the redirect page which wont redirect you – DividedByZero Apr 28 '14 at 15:30
  • 2
    @user3549636 — It doesn't work. Developer tools will show you the real video URL. – Quentin Apr 28 '14 at 15:30
  • ive tried dev tools in chrome and firefox – DividedByZero Apr 28 '14 at 15:31
  • 2
    Look at the Network requests, not the DOM. – Quentin Apr 28 '14 at 15:32
  • @Quentin have a look: https://onedrive.live.com/redir?resid=72C581D0FD6C0134!8863&authkey=!ABGYTn_xAVLr6aM&v=3&ithint=photo%2c.png – DividedByZero Apr 28 '14 at 15:38
  • @user3549636 — At the screen grab where you haven't scrolled to the video in the net tab or expanded the view to show its URL? That doesn't show anything relevant. – Quentin Apr 28 '14 at 15:40
  • 1
    Hmm… where did my first comment go? The one that pointed out that this entirely depends on people being too slow to get the video before the cookie expires, and that it was easily bypassed by looking at where the redirect goes to, and pointing out that on a slow connection, the cookie might expire before the video starts loading resulting it being blocked from "legitimate" users. – Quentin Apr 28 '14 at 15:43
  • @Quentin https://onedrive.live.com/redir?resid=72C581D0FD6C0134!8864&authkey=!AAJbRnGKTCKAAqs&v=3&ithint=photo%2c.png – DividedByZero Apr 28 '14 at 15:46
  • That doesn't appear to be loading a video at all. The word "photo" in the URL in the address bar of the screenshot probably has something to do with that. – Quentin Apr 28 '14 at 15:48
  • @quentin even if your internet connection is 250kbps the request will be sent before the cookie expires after which the video may take as long as required – DividedByZero Apr 28 '14 at 15:49
  • 1
    Do you have this code running somewhere so that we can prove it won't stop people downloading the video? – scunliffe Apr 28 '14 at 15:52
  • 1
    IIRC, on iOS devices, the request for the video won't be made until the user clicks Play. So you can't guarantee they will do that within 5 seconds of the page starting to load. (And that is leaving aside issues such as high latency connections, or pages where there is a lot of content before the video). – Quentin Apr 28 '14 at 15:52
  • @quentin This is getting terribly annoying. anyway I hope this satisfies you: https://onedrive.live.com/redir?resid=72C581D0FD6C0134!8868&authkey=!AGt55v8ex-7dZtQ&ithint=folder%2c – DividedByZero Apr 28 '14 at 15:53
  • It doesn't, because we still can't see the Net tab when the request for the video is made. Is the video loading triggered by JS? You need to trigger that before taking the screen grab of the Net tab. – Quentin Apr 28 '14 at 15:54
  • I plan on publishing my video sharing website VividVid in 2 months so you can try it then but I dont have an example yet. – DividedByZero Apr 28 '14 at 15:55
  • 1
    What would really satisfy us would be what we have asked for twice now - a test server where we can attack the protection ourselves. "Look! I, the inventor of this technique, cannot defeat it!" is hardly evidence. You aren't exactly unbiased. – Quentin Apr 28 '14 at 15:55
  • @Quentin well I dont HAVE a test server to offer you! – DividedByZero Apr 28 '14 at 15:57
  • @Quentin the video has started and is on 0:6 secs – DividedByZero Apr 28 '14 at 15:58
  • @Quentin you cant really start a video without sending a request! – DividedByZero Apr 28 '14 at 16:01
  • 1
    @user3549636 — I never made that claim. The two things I pointed out are that (1) It will show up in the Net tab of the developers tools (your screenshot doesn't show it, so the tab can't have been recording when the request was made so it doesn't help with proving that it doesn't reveal the real, unprotected URI of the video) and (2) The request might not be made within 5 seconds of the cookie timeout being set, especially on an iOS device that won't request the video until the user explicitly asks for it by pressing play (unlike desktop browsers which start precaching it on load). – Quentin Apr 28 '14 at 16:04
  • @Quentin looks like you didnt bother look at **Both** screenshots – DividedByZero Apr 28 '14 at 16:06
  • I did look at both. The first one shows the DOM, not the Net so doesn't help. The second one shows the Net, but not the request for the video so also doesn't help. – Quentin Apr 28 '14 at 16:08
  • @Quentin thats the point! It DOESN'T Show the request therefore you cant see the url!!! Are you seriously a programmer? I mean I'm 13 and I understood that! – DividedByZero Apr 28 '14 at 16:10
  • @Quentin since its a redirect It isn't shown in 95% browsers instead the original page is. – DividedByZero Apr 28 '14 at 16:11
  • 1
    When I, using the same browser as you, try to watch an HTML 5 video, it *does* show up in the developer tools: https://www.evernote.com/shard/s3/sh/04d726df-367f-4852-97ca-9360c5e62eb9/ab25c94a107e4720d00c767a54a89737 - if the developer tools didn't show the URL at all, then the Net section would be pretty much useless. – Quentin Apr 28 '14 at 16:17
  • @Quentin One Last Time: **REDIRECTED** Videos are NOT shown In MOST BROWSERS – DividedByZero Apr 28 '14 at 16:19
  • 1
    Browsers show both requests - the 301 and the 200 it redirects to - neither of them are showing up on your screenshots. This suggests you aren't monitoring the network requests when the video loads. – Quentin Apr 28 '14 at 16:19
  • Here's a screenshot to prove it: https://www.evernote.com/shard/s3/sh/ceb117ed-52c1-4a9c-9557-a3e4c92c42c5/3becfcbdc0712367a3e9efe7db33ba5a – Quentin Apr 28 '14 at 16:21
  • And in Chrome: https://www.evernote.com/shard/s3/sh/8f3ab756-45ca-4d83-b45f-5f4a585a7f2b/ecaf1c2c41e3251cb37d8821b89f1714 – Quentin Apr 28 '14 at 16:22
  • @Quentin Alright thats it I **QUIT**! you are ignoring all facts I can show you. – DividedByZero Apr 28 '14 at 16:23
  • 1
    You aren't showing me facts. You are showing me screenshots which are taken at a time when the evidence I'm asking for doesn't exist. I'm showing you screenshots which prove your technique does not work. – Quentin Apr 28 '14 at 16:24
  • 1
    Just to clarify here... if the end result of this question is implementing this solution I hope that there are not ***negative financial implications*** if the end user does copy/save the video. Currently this proposed solution will not stop users that want to save this video. When you get closer to launch if you want to DM me on Twitter (same handle) I can go through the exact details privately if you'd like. – scunliffe Apr 28 '14 at 17:51
  • @scunliffe Thanks for your concern but I have tried using the network sources panel and I don't see any video, instead I see the redirect website. and whilst this is logically not supposed to happen I think I can rely on it happening :P BTW I think you should try the code and see the result – javaseaayameradost Apr 28 '14 at 19:02
  • @Quentin okay last try, https://onedrive.live.com/redir?resid=72C581D0FD6C0134!8869&authkey=!ADcU_n-MBsXrTlg&ithint=video%2c.mp4 a video so you can see it for yourself – DividedByZero Apr 28 '14 at 19:11
  • 1
    @javaseaayameradost I've done web development for over 15 years... to date there has never been a **single file of any type** that I can load in a browser but have not been able to save. **none**. The reality is that **if** the browser can load the content to show it then I can grab it and save it too. – scunliffe Apr 28 '14 at 20:59
  • 1
    The behaviour of the browser in the screenshot does not appear to match any one on my system (which I provided screenshots that showed both the request for the redirector and the video itself in the Net tab). I'd speculate that they don't show up only because they are cached. I'm still convinced that it would take me seconds to bypass it if I was let loose on an actual implementation. (That's how long it took me when I implemented it on my server). – Quentin Apr 28 '14 at 22:35
  • @Quentin the point is, the author of this post wanted a simpler method than http://stackoverflow.com/questions/9756837/prevent-html5-video-from-being-downloaded-right-click-saved which provides the same functionality. Thats exactly what I gave him, now why are you after my life if you being such an experienced programmer already know there is no possible way to stop browser grabbing? – DividedByZero Apr 29 '14 at 12:07
  • 1
    Pointing out that your answer does not solve the problem (which it doesn't) is not the same as going after your life. – Quentin Apr 29 '14 at 12:11
  • @Quentin why did you down-vote my answer? You Yourself admit there is no way to stop browser grabbing so my answer is possibly the most one can do! – DividedByZero Apr 29 '14 at 12:19