海康&大華&DSS視頻拉流-RTSP轉RTMP多媒體播放技術


 海康&大華&DSS獲取RTSP

實時流

海康:
rtsp://[username]:[password]@[ip]:[port]/[codec]/[channel]/[subtype]/av_stream
說明:
username: 用戶名。例如admin。
password: 密碼。例如12345。
ip: 為設備IP。例如 192.0.0.64。
port: 端口號默認為554,若為默認可不填寫。
codec:有h264、MPEG-4、mpeg4這幾種。
channel: 通道號,起始為1。例如通道1,則為ch1。
subtype: 碼流類型,主碼流為main,輔碼流為sub。

栗子:

IPC

rtsp://admin:123456@192.168.18.105:554/h264/ch1/main/av_stream

NVR
rtsp://admin:123456@192.168.18.106:554/Streaming/Channels/101

說明:

101,第一個1代表通道,最后一個1代表麻溜。

大華:

rtsp://[username]:[password]@[ip]:[port]/cam/realmonitor?channel=1&subtype=0
說明:
username: 用戶名。例如admin。
password: 密碼。例如admin。
ip: 為設備IP。例如 10.7.8.122。
port: 端口號默認為554,若為默認可不填寫。
channel: 通道號,起始為1。例如通道2,則為channel=2。
subtype: 碼流類型,主碼流為0(即subtype=0),輔碼流為1(即subtype=1)。

栗子:

rtsp://admin:admin@192.168.18.107:554/cam/realmonitor?channel=2&subtype=1

 

回放流
海康:
rtsp://[username]:[password]@[ip]:[port]/Streaming/tracks/101?starttime=20120802t063812z&endtime=20120802t064816z

說明:

101:1,表示通道1;01,表示以單播形式回放指定設備的通道中的錄像文件

starttime:開始時間

endtime:結束時間

時間范圍是starttime到endtime,其中starttime和endtime的格式要符合ISO 8601。

具體格式是YYYYMMDD”T”HHmmSS.fraction”Z” ,Y是年,M是月,D是日,T是時間分格符,H是小時,M是分,S是秒,Z是可選的、表示Zulu (GMT) 時間。

大華:

rtsp://[username]:[password]@[ip]:[port]/cam/playback?channel=1&subtype=0&starttime=2017_01_10_01_00_00&endtime=2017_01_10_02_00_00

說明:

username: 用戶名。例如admin。
password: 密碼。例如admin。
ip: 為設備IP。
port: 端口號默認為554,若為默認可不填寫。
channel: 通道號,起始為1。例如通道2,則為channel=2。
subtype: 碼流類型,主碼流為0(即subtype=0),輔碼流為1(即subtype=1)。

starttime:開始時間

endtime:結束時間

大華DSS:

rtsp://[ip]:[port]/dss/monitor/params?cameraid=設備編號%24通道號&substream=碼流類型

說明:

[ip]:[port]:來自大華DSS媒體網關MGW

設備編號:平台上設備編號,例如1000004
通道號:設備下通道,從0(通道一)開始。
碼流類型:1代表主碼流,2代表輔碼流

栗子:

rtsp://192.168.19.102:9090/dss/monitor/params?cameraid=1000112$0&substream=1

RTSP轉RTMP實戰

一、下載nginx-rtmp-ffmpeg集合

https://download.csdn.net/download/yiyu1/10829669

二、修改Nginx/conf文件夾下nginx.conf文件:

worker_processes 1;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
chunk_size 4000;
# TV mode: one publisher, many subscribers
application mylive {
live on;

}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 20000;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

 

三、啟動Nginx

四、通過dos命令執行腳本

D:\ffmpeg\bin\ffmpeg.exe -re -rtsp_transport tcp -i "rtsp://192.168.19.102:9090/dss/monitor/params?cameraid=1000112$0&substream=1" -f flv -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 "rtmp://localhost:1935/mylive/1"

 

五、通過HTML訪問rtmp

<!DOCTYPE html>
<html lang="en">
<head>

<title>Video.js | HTML5 Video Player</title>
<!-- <link href="video-js-6.2.0/video-js.css" rel="stylesheet">
<script src="video-js-6.2.0/videojs-ie8.min.js"></script> -->

<link href="http://vjs.zencdn.net/5.20.1/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/5.20.1/videojs-ie8.min.js">>
</head>
<body>

<video id="example_video_1" class="video-js vjs-default-skin" controls preload="auto" width="1280" height="720" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<!-- <source src="1.mp4" type="video/mp4"> -->
<source src="rtmp://localhost:1935/mylive/1" type="rtmp/flv">
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video>
<script src="http://vjs.zencdn.net/5.20.1/video.js">>
</body>

</html>

 

注:需要運行flash

————————————————————

推薦閱讀:

老王講架構:負載均衡

支付寶系統架構內部剖析

大數據Spark與Storm技術選型

【贊】用Python實現Zabbix-API 監控

程序員怎么留住健康?

大數據智慧平台技術方案

大數據聚合平台解決方案

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM