15

How does Google Drive video streaming work ? Internally how does it stream the video, does it use HTTP based streaming or other protocols? I am very new to this, and I was wondering if Google Drive could be used as a demo server to just get a stream of video and display on the webpage. If anyone could give me information about this, it would be very helpful.

metal7
  • 265
  • 1
  • 3
  • 9

5 Answers5

19

OK, I've just managed to get this working as follows -

In google drive I placed the video file in a publicly shared folder then rightclick the file and select share > share..

Google then gives me a link to share that looks like

https://docs.google.com/file/d/0B4BsAbG4atWHQzVfLUU3UnhhZTA/edit?usp=sharing

I've cut what I guessed to be the file ID from the URL -

0B4BsAbG4atWHQzVfLUU3UnhhZTA

And added it to metal7's url to create a src attribute for a source tag

<source src="https://drive.google.com/uc?export=download&id=0B4BsAbG4atWHQzVfLUU3UnhhZTA" type='video/webm'/>

Now I've got a video working with the following html.

<html>
<head>
    <title>Video Test</title>
</head>
<body>
    <video controls="controls">
        <source src="https://drive.google.com/uc?export=download&id=0B4BsAbG4atWHQzVfLUU3UnhhZTA" type='video/webm'/>
    </video>
</body>
</html>

A lot of people seem to be suggesting creating an API app in order to get the file ID, but it looks like you can guess it pretty easy. That said, I'd be interested to see some proper documentation from google on it - I want to use this in production, but feel like I need to do more reading to be confident.

UPDATE

I've done a bit more reading and I'm afraid the video will only play on browsers that are logged into a google account. I spent a lot of time trying to get around this (inc building a google drive app with the api), I'm afraid it looks like there's no way round it.

Don't use google drive to serve up video in html unless you know all your users will be authenticated with google.

Aidan Ewen
  • 13,049
  • 8
  • 63
  • 88
  • As of Aug. 2014, I can stream video (mp4 or webm) from GDrive to many devices (Nexus7, MacBook Air, iPad Air, Windows PC) using any modern browser (Chrome, Firefox, Safari) *without* being logged into a Google account. I play the videos in an HTML5 video element. – devdanke Aug 11 '14 at 08:38
  • @devdanke How can you do that? Can you give some snip code? – Han Tran Oct 23 '14 at 02:14
  • 1
    @devdanke You can do it by just replace your video file id in last of this url given below; https://drive.google.com/uc?export=download&id= – Saeed Afzal Mar 06 '15 at 01:55
  • 1
    Well, if the video file is bigger than the virus scan limit (~25MB) a warning about the file not being scanned therefore may contain virus will be returned instead of the correct video file. This prevents the browser from playing correctly. – Johnson Steward Aug 03 '17 at 06:59
5

Use the URL like this:

https://googledrive.com/host/{YOUR_VIDEO_ID}

e.g. https://googledrive.com/host/01bLAblaBla01BlaBLaBlaBLaBLA

It's works with HTML5 (video tag) and other like videojs, and more...

seq
  • 185
  • 2
  • 6
  • @seq - this with audio tag doesn't work for me can you please take a look at my question here : http://stackoverflow.com/questions/41904057/html5-website-hosted-on-hostinger-playing-an-audio-file-in-google-drive thanks – Kukula Mula Jan 27 '17 at 22:32
  • @KukulaMula Did you find a solution to this? – SeaBass Oct 23 '18 at 19:16
  • Probably Google disabled this opportunity. I had to buy web hosting service. It was almost two years ago. – seq Oct 24 '18 at 20:25
4

None of the these solutions work anymore. This works. The viewer does not need to be logged into their Google account to view the video.

  1. Get the shareable link to your video by clicking on the video in your Google drive, and click on that paper clip-like icon in the top link
  2. Turn link sharing on
  3. Open the link
  4. In the video, click on the three dots icon on the upper right, and then click on 'Embed item'. You'll then have the code you can put into your HTML. It'll look something like this:

<iframe src="https://drive.google.com/file/d/<video id>/preview" width="640" height="480"></iframe>

user2233706
  • 6,148
  • 5
  • 44
  • 86
1

Internally when viewed in Google Drive's web page viewer, Google Drive streams videos over HTTPS/443. There is only one connection made for the video itself and that connection is kept open as long as the video is being streamed from Google Drive to the client.

Google Drive uses an HTTP CONNECT call. Headers look like this:

CONNECT r3---sn-p5qlsu68.c.docs.google.com:443 HTTP/1.1
Host: r3---sn-p5qlsu68.c.docs.google.com
Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)    Chrome/29.0.1547.57 Safari/537.36
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
  • 2
    We can access the video like this in HTML5- . The file-id is available from Google Drive when we click on share video. The file should be shared in order to access the stream. – metal7 Aug 28 '13 at 04:55
  • @metal7 hi do you know a way to get this to work if the file is "too big for a virus scan"? – B''H Bi'ezras -- Boruch Hashem Jan 14 '19 at 05:34
  • 1
    Also I was able to rerieve a link like https://r5---sn-a5meknel.c.docs.google.com/videoplayback?expire=1553697376&ei=IFKbXNqvOZXaugXlirXIAg&ip=76.90.101.113&cp=QVNKVUdfVlNVR1hOOmxfX2NzM2dmclZmcWQ0U1hDaDZqVVhhUGRhMm5VX1BsaU1qTDVLV2NfVTc&id=993b57952e128cec&itag=59&source=webdrive&requiressl=yes&mm=30&mn=sn-a5meknel&ms=nxu&mv=u&pl=20&ttl=transient&susc=dr&driveid=1Cyuh41yNfYZU_zL-MHLf_EPJCYnlT7oJ&app=explorer&mime=video/mp4&...(etc) but when I try to open it in another browser I get a 403 error, any ideas? – B''H Bi'ezras -- Boruch Hashem Mar 27 '19 at 10:42
1

I did some tests myself, and the video is streamable (over HTTP) to public clients so long as the file is shared publicly on Google Drive.

The get the file to play using regular HTTP streaming, you can use the HTML5 video tag like so:

<video controls="controls">
    <!-- Safari -->
    <source src="https://drive.google.com/uc?export=download&id=0B0JMGMGgxp9WMEdWb1hyQUhlOWs" type='video/mp4'/>
    <!-- Chrome and FF -->
    <source src="https://drive.google.com/uc?export=download&id=0B0JMGMGgxp9WMEdWb1hyQUhlOWs" type='video/webm'/>
</video>

This method is explained further over on: http://sourcey.com/html5-video-streaming-from-google-drive/

Kamo
  • 232
  • 2
  • 4
  • 1
    I don't think this method is working anymore unfortunately. On their webpage you linked to, the video doesn't play. And when I test with my own video, its not working for me in chrome. – bmiskie Feb 12 '18 at 21:37
  • Any solution to this? – SeaBass Oct 23 '18 at 19:15