海康大华RTSP转HLS直播

海康RTSP地址:

老版本: 

rtsp://username:password@//ch/

例子:

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

rtsp://admin:[email protected]:554/h264/ch33/main/av_stream

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

rtsp://admin:[email protected]:554/h264/ch1/sub/av_stream

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

rtsp://admin:[email protected]:554/h264/ch0/main/av_stream

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

 rtsp://admin:[email protected]:554/h264/ch1/stream3/av_stream

新版本:

rtsp://username:password@
:/Streaming/Channels/(?parm1=value1&parm2-=value2…)

例子:

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

rtsp://admin:[email protected]:554/Streaming/Channels/101?transportmode=unicast

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

rtsp://admin:[email protected]:554/Streaming/Channels/1701?transportmode=unicast

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

rtsp://admin:[email protected]:554/Streaming/Channels/102?transportmode=unicast  (单播)

rtsp://admin:[email protected]:554/Streaming/Channels/102?transportmode=multicast (多播)

rtsp://admin:[email protected]:554/Streaming/Channels/102 (?后面可省略,默认单播)

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

rtsp://admin:[email protected]:554/Streaming/Channels/001

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

rtsp://admin:[email protected]:554/Streaming/Channels/103

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

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

用 rtsp://admin:[email protected]: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:[email protected]: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:[email protected]: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下载

你可能感兴趣的:(硬件编程)