首页 / 浏览问题 / 三维GIS / 问题详情
请问RTSP视频投放 WebSocket返回的数据结构有什么规范没有?
2EXP 2021年01月04日

用官网示例来实现rtsp流视频投放:目前官网上提供的示例http://support.supermap.com.cn:8090/webgl/examples/webgl/editor.html#RTSP
是实现不了,没有效果,通过调试代码发现官网通过StreamEdian播放器+webSocket技术来实现视频流的获取和播放

目前调试发现代码
                    Streamedian.player('trailer', {
                        socket: "ws://127.0.0.1/myWebSocket"
                    });
      socket的参数只支持ws || wss格式的请求。

我自己写了一个请求,读取本地的mp4视频,返回bytebuffer,代码断片如下

FileInputStream file = null;
ByteBuffer  btf =  ByteBuffer.allocate(8000);
String path ="C:\\Users\\Administrator.USER-20190906OF\\Desktop\\NewFile4\\big_buck_bunny.mp4";
try {
    file = new FileInputStream(path);
    int size = 8000 ;
    int len =-1;
    byte [] data = new byte[size];
    int num = 0;
    while((len=file.read(data))!=-1) {
        btf =  ByteBuffer.wrap(data);
        BinaryMessage  bMessage = new  BinaryMessage(btf);
        session.sendMessage(bMessage);
        System.out.println(num);
        ++num ;
    }
    file.close();
    file=null;

} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}finally {
}

前端错误 提示data.indexOf is not a function:

1个回答

您好,您那边是本地的视频文件吗?如果是本地的可以参考范例:http://support.supermap.com.cn:8090/webgl/examples/webgl/editor.html#projectionImage;如果是在线的需要您自己去转换成对应得rtsp格式的视频流再到WebGL来对接

6,077EXP 2021年01月04日
RTSP/1.0 200 OK
Session:       1943390576
RTP-Info: url=rtsp://admin:123456@192.168.0.1/h264/ch40/sub/av_stream/trackID=1;seq=21104;rtptime=3308468774
Date:  Tue, Jan 05 2021 10:25:02 GMT
返回的是 这种格式,但是还是没有效果
...