海康大华RTSP转HLS直播

海康RTSP地址:

老版本: 

rtsp://username:password@<ipaddress>/<videotype>/ch<number>/<streamtype>

例子:

DS-9016HF-ST的IP通道01主码流:

rtsp://admin:12345@172.6.22.106:554/h264/ch33/main/av_stream

DS-9016HF-ST的模拟通道01子码流:

rtsp://admin:12345@172.6.22.106:554/h264/ch1/sub/av_stream

DS-9016HF-ST的零通道主码流(零通道无子码流):

rtsp://admin:12345@172.6.22.106:554/h264/ch0/main/av_stream

DS-2DF7274-A的第三码流:

 rtsp://admin:12345@172.6.10.11:554/h264/ch1/stream3/av_stream

新版本:

rtsp://username:password@<address>:<port>/Streaming/Channels/<id>(?parm1=value1&parm2-=value2…)

例子:

DS-9632N-ST的IP通道01主码流:

rtsp://admin:12345@172.6.22.234:554/Streaming/Channels/101?transportmode=unicast

DS-9016HF-ST的IP通道01主码流:

rtsp://admin:12345@172.6.22.106:554/Streaming/Channels/1701?transportmode=unicast

DS-9016HF-ST的模拟通道01子码流:

rtsp://admin:12345@172.6.22.106:554/Streaming/Channels/102?transportmode=unicast  (单播)

rtsp://admin:12345@172.6.22.106:554/Streaming/Channels/102?transportmode=multicast (多播)

rtsp://admin:12345@172.6.22.106:554/Streaming/Channels/102 (?后面可省略,默认单播)

DS-9016HF-ST的零通道主码流(零通道无子码流):

rtsp://admin:12345@172.6.22.106:554/Streaming/Channels/001

DS-2DF7274-A的第三码流:

rtsp://admin:12345@172.6.10.11:554/Streaming/Channels/103

注:前面老URL,NVR(>=64路的除外)的IP通道从33开始;新URL,通道号全部按顺序从1开始。

公司海康型号DS-7104N-SN/P

用 rtsp://admin:12345@192.168.0.113:554/Streaming/Channels/101?transportmode=unicast 测试成功.

1.搭建Nginx

下载地址:https://nginx.org/en/download.html,我用的是nginx/Windows-1.12.2.

 解压后修改nginx\conf\nginx.conf文件:

1.在nginx\conf\nginx.conf中:
  http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    access_log off;
    server {
修改:    
    listen       20000;
        server_name  localhost;
       修改:
        location / {
           root   html;
           index  index.html index.htm;
        }
为了能访问到hls流协议新增:
location /hls {  
types{  
application/vnd.apple.mpegurl m3u8;  
video/mp2t ts;  
}  
root html;  
add_header Cache-Control no-cache;
        add_header Access-Control-Allow-Origin *;
        }  

2.在nginx\conf\mime.types中
为了支持hls流协议新增:

application/vnd.apple.mpegurl or x-mpegURL m3u8;
video/mp2t ts;

3.在命令行中输入即可转换:也可写成脚本的形式运行。<加上-f rtsp -rtsp_transport tcp参数,可以有效防止丢包,默认传输是UDP>

大华:

ffmpeg -f rtsp -rtsp_transport tcp -i "rtsp://admin:ADMIN123@192.168.0.200:554/cam/realmonitor?channel=1&subtype=0" -strict -2 -c:v libx264 -vsync 2 -c:a aac -f hls -hls_time 4 -hls_list_size 5 -hls_wrap 10 E:/live/nginx-1.12.2/nginx-1.12.2/html/test.m3u8

海康:

ffmpeg -f rtsp -rtsp_transport tcp -i "rtsp://admin:12345@192.168.0.113:554/Streaming/Channels/101?transportmode=unicast" -strict -2 -c:v libx264 -vsync 2 -c:a aac -f hls -hls_time 4 -hls_list_size 5 -hls_wrap 10 E:/live/nginx-1.12.2/nginx-1.12.2/html/test.m3u8

4.用CKPlayer自带的demo,部署到nginx/html目录下,启动nginx访问/ckplayer/index.html首页即可。

在m3u8播放地址栏里写入自己的m3u8地址。比如:http://192.168.0.102:20000/test.m3u8.即可查看效果。

5.demo下载

  • 2
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 17
    评论
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

上善若水_厚德载物

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值