29
2024
10
23:13:25

【音视频】 zlm的几个代理接口解释

目录

12、/index/api/addStreamProxy

界面上

30、/index/api/addStreamPusherProxy

14、/index/api/addFFmpegSource

24、/index/api/openRtpServer

27、/index/api/startSendRtp

推流列表

参考






12、/index/api/addStreamProxy


拉流代理 : 194上在播放。 而10.30.2.6上加上这个拉流,
意义: 都是可以代理一下,可以着手播放了。如wvp上,就代理配置一下,就可以播放了。因为自己的业务平台播放器只适应自己的播放格式 

{{ZLMediaKit_URL}}/index/api/addStreamProxy?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=live&stream=test&url=rtmp://10.60.100.194:10935/rtp/34010000001180000002_34020000001310000002
返回 : {
    "code": 0,
    "data": {
        "key": "__defaultVhost__/live/test"
    }
}
就可以以: ffplay rtmp://10.30.2.6:10935/live/test  来播放了。


而wvp上的拉流,灵活处在于它可以加其它的zlm 结点作为最终的代理(播放地址)。

 

界面上

操作一个194的流到192上,是这样的

192看到了,并且 ffplay rtmp://10.60.100.192:10935/2222/222 也能放了

推到194上的源流是:

 

 

30、/index/api/addStreamPusherProxy


推流代理 : 就是把本服务上的 已经有的live/test2服务  推到另一台zlm 上去rtmp://10.60.100.196:1935/live/test2
{{ZLMediaKit_URL}}/index/api/addStreamPusherProxy?secret={{ZLMediaKit_secret}}&schema=rtmp&vhost={{defaultVhost}}&app=live&stream=test2&dst_url=rtmp://10.60.100.196:1935/live/test2
返回:
{
    "code": 0,
    "data": {
        "key": "rtmp/__defaultVhost__/live/test2/997524c9d685c835ebe7823fe1c278e1"
    }
}

然后就可以通过 >ffplay rtmp://10.60.100.196:1935/live/test2  来播放了

14、/index/api/addFFmpegSource


ffmpeg推流代理 也是相当于ffmpeg -re -i http://www.login-wifi.com/gmes/11.mp4 -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv rtmp://10.30.2.6:10935/live/test3
只是这个api有点问题
{{ZLMediaKit_URL}}/index/api/addFFmpegSource?secret={{ZLMediaKit_secret}}&src_url= http://www.login-wifi.com/gmes/11.mp4&dst_url=rtmp://127.0.0.1:1935/live/test3&timeout_ms=10000&enable_mp4=0


24、/index/api/openRtpServer

创建好端口后,就允许ffmpeg向此服务器推流。注意我的docker 30040这么大的只开放了udp,所以请使用enable_tcp=0

ffmpeg -re -i 11.mp4 -vcodec h264  -f rtp_mpegts rtp://10.30.2.6:30040

{{ZLMediaKit_URL}}/index/api/openRtpServer?secret={{ZLMediaKit_secret}}&port=0&enable_tcp=0&stream_id=test

返回:

{

    "code": 0,

    "port": 30040

}


可以播放:  ffplay rtsp://10.30.2.6:10554/rtp/test

27、/index/api/startSendRtp

注意它也是将本服务器的流推到另外的服务器

推流列表


 关键点,加入secret才允许;zlm 通过hook让wvp知道,从而就有了推流列表

ffmpeg.exe -f dshow -i audio="麦克风 (Realtek High Definition Audio)" -rtbufsize 1000M -thread_queue_size 1024 -f dshow   -i video="XiaoMi USB 2.0 Webcam"  -vcodec libx264   -acodec aac -f flv rtmp://10.60.100.194:10935/test/live?secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc


参考

MediaServer支持的HTTP API · ZLMediaKit/ZLMediaKit Wiki (github.com)




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/8240.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: