高分在线等求助 php解析视频地址,在线播放问题

西門冠希 2018-02-17 10:10:20
<?php
error_reporting(0);
$beginUrl='';
if($_POST['url']){
$url=$_POST['url'];
$beginUrl=$url;
$ip=rand(10,200).'.'.rand(10,200).'.'.rand(10,200).'.'.rand(10,200);
$headers=array(
'CLIENT-IP:'.$ip,
'X-FORWARDED-FOR:'.$ip,
);
$urlRes=curl_get($url,$headers);

$urlRule="/(?<=\<source\ssrc\=\").*(?=\"\stype\=\'video)/";
preg_match($urlRule,$urlRes,$url);
$url=$url['0'];
}

function curl_get($url,$headers){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
if($headers){
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8" />
<title>视频解析</title>
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport" />
<style>
.clear{clear:both;}
form{width:90%;margin:120px auto;}
.down{width:90%;margin:20px auto;}
.key{width:80%;height:40px;outline: none;font-size:20px;text-indent:10px;float:left;}
.submit{height:44px;line-height:44px;padding-left:20px;padding-right:20px;background:#ff9735;border:none;color:#fff;float:left;margin-left:15px;font-size:20px;cursor:pointer;text-decoration:none;}
.down textarea{width:85%;height:40px;}
.foot{width:100%;position: fixed;bottom: 0;text-align:center;border-top:1px solid #e7e7e7;color:#999;font-size:14px;}
.foot .container{margin:0 auto;}
.foot .container a{color:#337ab7;text-decoration:none;}
</style>
</head>
<body>



<form action="../api/index.php" method="post">
<input class="key" placeholder="输入视频链接" name="url" type="text" value="<?php echo $beginUrl; ?>">
<button type="submit" class="submit">采集</button>
</form>
<div class="clear"></div>
<div class="down">
<input class="key" placeholder="下载地址" type="text" value="<?php echo $url; ?>">
<a target= _blank class="submit" href="<?php echo $url; ?>" download="a">立即下载</a>
</div>
</body>
</html>

首先祝各位新年好!

因为直接调用mp4视频地址,长时间以后视频地址会过期。
所以用这个PHP文件,来解析视频mp4地址,<?php echo $url; ?>这个参数是解析后的视频MP4地址。
根据以上的代码,求教各位高手,怎么用http://bbs.csdn.net/index.php?url=视频链接mp4地址播放呢
...全文
842 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
深圳phper 2018-02-22
  • 打赏
  • 举报
回复
在代码首行加入: set_time_limit(0); ini_set("memory_limit", 1024);

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧