Google Drive 视频流是如何工作的?在内部它如何流式传输视频,它是使用基于 HTTP 的流式传输还是其他协议?我对此很陌生,我想知道 Google Drive 是否可以用作演示服务器来获取视频流并在网页上显示。如果有人可以给我这方面的信息,那将非常有帮助。
5 回答
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.
像这样使用 URL:
https://googledrive.com/host/ {YOUR_VIDEO_ID}
例如https://googledrive.com/host/01bLAblaBla01BlaBLaBlaBlaBLA
它适用于 HTML5(视频标签)和其他类似 videojs,等等......
这些解决方案都不再有效。这行得通。观看者无需登录其 Google 帐户即可观看视频。
- 通过单击 Google 驱动器中的视频获取视频的可共享链接,然后单击顶部链接中的回形针状图标
- 开启链接分享
- 打开链接
- 在视频中,单击右上角的三个点图标,然后单击“嵌入项目”。然后,您将拥有可以放入 HTML 的代码。它看起来像这样:
<iframe src="https://drive.google.com/file/d/<video id>/preview" width="640" height="480"></iframe>
我自己做了一些测试,只要文件在 Google Drive 上公开共享,视频就可以(通过 HTTP)流式传输到公共客户端。
使用常规 HTTP 流获取要播放的文件,您可以video
像这样使用 HTML5 标记:
<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>
此方法进一步解释:http: //sourcey.com/html5-video-streaming-from-google-drive/
在内部,当在 Google Drive 的网页查看器中查看时,Google Drive 通过 HTTPS/443 流式传输视频。视频本身只有一个连接,只要视频从 Google Drive 流式传输到客户端,该连接就会保持打开状态。
Google Drive 使用 HTTP CONNECT 调用。标头如下所示:
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