php 获取网络视频截图,100521 php取视频截图

本文介绍了如何使用PHP获取来自Youku、Ku6和Tudou视频网站的视频截图,并利用这些截图制作动态视频显示。通过getVideoInfo函数实现不同网站的视频编码识别和截图URL提取,适用于10-05-21测试通过。
摘要由CSDN通过智能技术生成

8511d4b059757cb7904c14706024c884.png

需要截图类似qq 空间 那样的 图片 作为视频显示,点击以后再做处理插入flash播放器

最新可用获得 土豆 酷6 youku 视频网站相关视频截图的PHP 代码,10-05-21日测试通过

$link = ‘http://v.youku.com/v_show/id_XMTczMDk5Nzcy.html’;

$host = ‘youku.com’;

$link =”http://v.ku6.com/show/UGLUGb7WYGokx2KU.html“;

$host = ‘ku6.com’;

$link =”http://www.tudou.com/playlist/playindex.do?lid=8615533&iid=51711411&cid=22“;

$host =”tudou.com”;

var_dump( getVideoInfo($link, $host));

$returninfo=getVideoInfo($link, $host);

$img=$returninfo[‘imageurl’];

echo $img;

function getVideoInfo($link, $host) {

$return = array();

if(‘youku.com’ == $host) {

//分析视频网址,获取视频编码号

preg_match_all(“/id\_(\w+)[\=|.html]/”, $link, $matches);

if(!empty($matches[1][0])) {

$return[‘flashvar’] = $matches[1][0];

}

//获取视频页面内容,存与$text中

$text=file_get_contents($link);

//获取视频标题

preg_match(“/

(.*?) – (.*)/”,  $text, $title);

//获取优酷网上某一视频对应的视频截图,经分析,视频的截图的图片地址在该视频页面html代码里以

标记里的最后一个http://vimg….

//例如http://vimg20.yoqoo.com/0100641F4649B9D27344B00131FBB6AFDF5175-7D35-930B-E43C-99C59F918E00

preg_match_all(“/

/”,$text,$match2);

preg_match(“/http:\/\/(.*)ykimg.com(.*)\|\”\>/”,$match2[1][0],$imageurl);

/**

var_dump($imageurl);

$html = ob_get_contents(); //读取缓冲区数据

wlog($html);

echo “
”;

*/

if (!empty($imageurl[1])) {

$return[‘imageurl’] = ‘http://g1.ykimg.com’.$imageurl[2];

}

if (!empty($title)) {

$return[‘title’] = $title[1];

}

} elseif(‘ku6.com’ == $host) {

// http://v.ku6.com/show/bjbJKPEex097wVtC.html

// http://v.ku6.com/special/index_3628020.html

//对于酷6网,末尾以index_开头的地址需要另外分析其视频编码

$text=file_get_contents($link);

preg_match_all(“/\/([\w\-]+)\.html/”, $link, $matches);

if(1 > preg_match(“/\/index_([\w\-]+)\.html/”, $link) && !empty($matches[1][0])) {

$return[‘flashvar’] = $matches[1][0];

}else{

preg_match_all(“/refer\/(.*)\/v.swf/”,$text,$videourl);

$return[‘flashvar’] = $videourl[1][0];

}

preg_match(“/

(.*?) – (.*)/”,  $text, $title);

//经分析,酷六的视频截图地址在视频页面的(.*)/”,$text,$imageurl);

if (!empty($imageurl[1][0])) {

$return[‘imageurl’] = $imageurl[1][0];

}

if (!empty($title)) {

$return[‘title’] = $title[1];

}

}elseif (‘tudou.com’ == $host){

//http://www.tudou.com/programs/view/_ke1lzCnBYw/

$tudou = file_get_contents($link);

preg_match_all(“/view\/([\w\-]+)\//”, $link, $matches);

if(!empty($matches[1][0])) {

$return[‘flashvar’] = $matches[1][0];

}

preg_match(“/

(.*?) – (.*)/”,  $tudou, $title);

preg_match_all(“/(.*)/”,$tudou,$imageurl);

if (!empty($imageurl[1][0])) {

$return[‘imageurl’] = $imageurl[1][0];

}

if (!empty($title)) {

$return[‘title’] = $title[1];

}

}

return $return;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值