从一台服务器到另一台服务器的流式视频


Streaming video from one server thru another

我的脚本需要帮助,我花了很长时间才弄清楚它出了什么问题,但我什么都找不到。

基本上在我的第一台服务器上我包含视频文件,在我的第二台服务器上,我流式传输这些文件。要从第一台服务器获得文件,你必须使用来自第二台服务器的IP(基本上我只允许我的服务器与第一台服务器连接)

所以为了获得这些文件,我使用cURL功能,因为所有视频都将通过服务器二。

我做到了:

$url = "111.111.111.111/example.flv";
                                    $ch = curl_init();
                                    $timeout = 0;
                                    curl_setopt ($ch, CURLOPT_URL, $url);
                                    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
                                    $video = curl_exec($ch);
                                    curl_close($ch);
                                    // output to browser
                                    header("Content-type: video/x-flv");
                                   echo ' <a href="'.$video.'" style="display:block;width:920px;height:600px" id="player"> 
    </a> 
    <script>
        flowplayer("player", "flowplayer-3.2.16.swf");
    </script>';

所以我所做的是:1.我在$url中有一个视频链接2.我使用cURL打开新连接3.我从链接中获取数据。4.然后我把这个视频保存在$video中5.我试着打开它。

但是它不起作用。。。当我打开这个网站是显示给我这个:

FLV���  �����ÖY��������
onMetaData����metadatacreator�3Yet Another Metadata Injector for FLV - Version 1.8�hasKeyframes�hasVideo�hasAudio�hasMetadata�canSeekToEnd�duration�@Ļj◊
=p§�datasize�AĽ≥i����   videosize�A∂ąęZ���� framerate�@9�70Ō'�
videodatarate�@|<GłÕŰĢ�videocodecid�@�������width�@Ą�������height�@v@������ audiosize�AĒ8»,����
audiodatarate�@Xsöł¶@ű�audiocodecid�@$�������audiosamplerate�@�������audiosamplesize�?ū�������stereo�filesize�AĽ≥Óv����
lasttimestamp�@Ļj◊
=p§�lastkeyframetimestamp�@Ļj◊
=p§�lastkeyframelocation�AĽ≥Ób����  keyframes�
filepositions

所以我得到字符串中的数据。。。

你知道我要做什么吗,流式传输这个文件??

您不能同时输出HTML和FLV数据。我建议使用以下代码创建一个单独的PHP文件:

$url = "111.111.111.111/example.flv";
header("Content-type: video/x-flv");
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_exec($ch);
curl_close($ch);

然后你可以把你的玩家代码放在其他任何地方,比如:

<a href="/path/to/first/file.php" style="display:block;width:920px;height:600px" id="player">