使用php curl播放.m3u8视频

时间:2018-09-06 11:26:37

标签: php curl m3u8 php-curl

我正在尝试使用php curl代理播放.m3u8视频。以下代码似乎有效,尽管它仅返回视频#EXTM3U信息,但不播放视频。

代码:

<?php
//....proxy info
$auth = 'username:password'; 
$proxy_ip = '1.2.3.4.5'; 
$proxy_port = 8080; 
$path = $_GET['link'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth);
curl_exec($ch);
if (curl_error($ch)) {
    $error_msg = curl_error($ch);
    echo $error_msg;
}
curl_close($ch);
if (isset($error_msg)) {
    echo $error_msg;
}
?>

输出:

#EXTM3U #EXT-X-VERSION:3 #EXT-X-INDEPENDENT-SEGMENTS #EXT-X-STREAM-INF:BANDWIDTH=5640800,AVERAGE-BANDWIDTH=5640800,CODECS="avc1.4d4028,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=25.000 index4147.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=2421100,AVERAGE-BANDWIDTH=2421100,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=1280x720,FRAME-RATE=25.000 index2073.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=1566400,AVERAGE-BANDWIDTH=1566400,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=25.000 index1296.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=1002100,AVERAGE-BANDWIDTH=1002100,CODECS="avc1.77.30,mp4a.40.2",RESOLUTION=746x420,FRAME-RATE=25.000 index783.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=774400,AVERAGE-BANDWIDTH=774400,CODECS="avc1.77.30,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=25.000 index576.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=421300,AVERAGE-BANDWIDTH=421300,CODECS="avc1.42c015,mp4a.40.2",RESOLUTION=426x240,FRAME-RATE=25.000 index255.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=476300,AVERAGE-BANDWIDTH=476300,CODECS="avc1.42c01f,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=25.000 index101.m3u8

关于我如何播放视频的任何想法?

0 个答案:

没有答案