1

嗨我有一个小问题我需要帮助我有一个网页以 json 格式输出实时流,链接看起来像这样

rtmp:\/\/server:port\/camera1.stream

现在,如果我将该链接复制并粘贴到记事本中并将其更改\//我自己,则链接在我拥有的每个媒体播放器中都可以正常播放,并且我可以看到摄像头提要,但是当我使用 php 脚本解码 json 输出时,流不会当通过 echo 输出或添加到生成的 m3u8 文件时完全播放:

下面是我用来获取页面和 json 解码的代码

$stream_id = $_GET["cam"];
// create curl resource
$ch = curl_init();
//set url
curl_setopt($ch, CURLOPT_URL, "http://ip:port/json");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
//close curl resource to free up system resources
curl_close($ch);  
$response = json_decode($output), true);

foreach ($response['cameras'] as $result) {
    if($result['name'] == $stream_id){
        echo $result['cam_stream'];
    }
}
4

0 回答 0