我需要帮助我的脚本,我花了很多时间来解决它的错误,但我找不到任何东西。
基本上在我的第一台服务器上我包含视频文件,在我的第二台服务器上我传输这些文件。要从第一台服务器获取文件,您必须使用服务器2中的IP(基本上我只允许我的服务器连接第一台服务器)
因此,要获取这些文件,我使用cURL函数,因为所有视频都将通过服务器2。
我这样做了:
$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.我从链接中获取数据。 然后我将这段视频保存在$ video中 我试着打开它。
但是它不起作用......当我打开这个网站时,请告诉我:
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
所以我在字符串中获取数据......
你知道我要做什么,流传输这个文件吗?
答案 0 :(得分:0)
您无法同时输出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">