当我将视频上传到 Google 云端硬盘时,它会转换为多种质量并可通过 YouTube 播放器播放 我的问题是如何使用 php 获取不同质量的直接视频 url。
到目前为止,我尝试使用播放器页面 file_get_contents 并尝试像这样解析代码
$browser = $_SERVER['HTTP_USER_AGENT'];
$options = array('http' => array('user_agent' => $browser));
$context = stream_context_create($options);
$page= file_get_contents($link, false, $context);
$h= explode('"22|',$page);
$h1=$h[1];
$h2=explode(',',$h1);
$hd=$h2[0];
$hdsrc = str_replace('\u003d', '=', $hd);
$hdsrc = str_replace('\u0026', '&', $hdsrc);
$hdsrc = str_replace('%2C', '&', $hdsrc);
$hdsrc = str_replace('\\', '', $hdsrc);
我得到了长 url xxxxxx.googlevideo .....................
但是玩不了!! 关于如何获得不同质量的直接视频网址的任何想法。
PS:我知道直接下载链接,我想要转换后的质量 URL。
谢谢
最佳答案
链接类型 https://drive.google.com/uc?export=download&id= {FILE_ID} 适用于使用 REST API v2 在 android 中播放流式音频,但在您的谷歌驱动器中,您必须将文件安全性更改为“如果有链接则公开”。希望对您有所帮助。
关于php - 从 Google Drive 流式传输视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33873591/