Google Drive - Video Streaming

主宰稳场 提交于 2019-12-17 07:27:53

问题


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.


回答1:


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.




回答2:


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...




回答3:


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



回答4:


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/




回答5:


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>



来源:https://stackoverflow.com/questions/18479155/google-drive-video-streaming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!