Use c#.net core to develop gb28181 sip+streaming media service to complete the video surveillance example tutorial and experience the process in person

       At present, C# .net core is used to realize the national standard gb28181 standard camera playback, ptz pan/tilt control, video playback and other video monitoring functions. The project can run in the linux/docker/.net core environment, which is also very rare at present to achieve millisecond level The national standard gb28181 public network video transmission case is also a rare complete open source SIP project that can simultaneously have playback, ptz pan-tilt control, and video playback functions.

Usage plan: sip(GB28181.Solution c# .net core) + streaming media server (srs/ZLMediaKit)

Use scenarios: live broadcast, community video surveillance, video AI analysis, and other scenarios that need to use the camera from inside and outside to the outside network for access

     It is also difficult to find a complete tutorial on the entire network. I started buying a camera in 2017 and came back to research for a while, but no results. Recently, because the company needs to use it, after more than half a year of data collection and continuous learning trial and error, I found the correct one. The road, lest everyone take detours. Share for everyone, and then surprise the developers of c#, and contribute to the development of c# together!

1. My preparation for realization:

1. Buy a ces server centos 7 system on Taobao as a streaming media tester, with a low configuration of 2 cores and 2M, more than 1200 a year, or about 300 a month on a monthly basis

2. Purchase equipment: Need to see clearly that supports gb28181, more than 700 yuan for a Haikang PTZ camera

3. During the debugging, debug on the local windows, and then deploy to linux, download the c# open source project I am currently involved in

https://gitee.com/GB28181/GB28181.Solution

Used as a sip server service, you can perform related operations on the camera through signaling, the compilation environment vs2019 (in the open source project, the WeChat in the document, you can enter the project open source group, and contribute to this project together, it is recommended to join)

4. Download srs4.0, github address on centos 7 server: 

https://github.com/winlinvip/srs   (develop branch)

5. Download the sip capture tool wireshark  

Download link: https://www.wireshark.org/#download

Comes with a solution to the large memory usage that may occur during the use of wireshark and the card machine

https://blog.csdn.net/qq_16005627/article/details/105603395

 

2. Implementation steps

Configure the srs server address and port through GB28181.Solution , the wintool of the project is running, click to play the video, you can see that the rtp stream has been pushed up on the srs server, you can achieve rmtp, webrtc (low latency measured within 2 seconds ), flv, hls (m3u8) output

Then play through vlc

1. Open the GB28181.WinTool project and configure Config/gb28181.xml to configure the following:

<LocalID>34020000002000000001</LoclID>SIP服务器ID 34020000002000000001

<LocalIP>127.0.0.1</LocalIP> The local IP 127.0.0.1 (or my local IP 192.168.197.108)

<LocalPort>5061</LocalPort> local service port 5061

 <RemotePort>5060</RemotePort> device port

<MediaIP>47.115.1.118</MediaIP> Streaming media server address (srs)

<MediaPort>9000</MediaPort>Streaming media server port (srs)

 

 

2. The configuration corresponding to the camera is as follows:

è¾å¥å¾ç说æ

 

3. Check the running method of srs in the github of srs, and run srs. The following are simple and understandable instructions compiled by me

------------------------------------------

Step1: Pull the git code and switch to the development branch

git clone https://gitee.com/winlinvip/srs.oschina.git srs &&

cd srs/trunk &&

git remote set-url origin https://github.com/ossrs/srs.git &&

git pull

Step2: Switch to the development branch

git checkout develop &&

./configure --with-gb28181 &&

make clean && make

------------------------------------------------

After installing the above srs, modify the two configurations

Open trunk/conf/push.gb28181.conf

auto_create_channel on;//The original off was changed to on

 host 47.XX.XXX.118;//The original $CANDIDATE is changed to your server ip

----------------------------------------------

run

./objs/srs -c conf/push.gb28181.conf

4. Then start the project GB28181.WinTool 

è¾å¥å¾ç说æ

è¾å¥å¾ç说æ

 

 

5. At this point, the push is successful

We open the srs test http://ossrs.net/players/srs_gb28181.html  interface interface, which can realize rmtp, webrtc (low-latency measured within 1 second), flv, hls (m3u8) output, and enter the srs server IP for playback

 

 

Everyone’s attention : the last paragraph of the play address childxxxx (ssrc) is different for each channel, so how to associate the play address with the device so that the play address can be saved to the database? The solution is as follows, customize the ssrc value of rtp, then The playback address will also change accordingly. If you want to connect to other streaming media platforms, this ssrc value is also used as the playback address:

6. Play

Play steps

A very rare case of public network video transmission that can achieve millisecond delay in the national standard gb28181

è¾å¥å¾ç说æ

 

Three, use gb28181.server server + api method to deploy

The above is the use of wintool tool to test the push streaming method, if it is used in the development or production environment , you need to use the server + grpc to api to perform

Run gb28181.Server

See that a device is registered

Call access api

Check srs and see that rtp is pushed up, you can start playing, and the playback process is the same as point 5 above

-------------------------------------------------- ---------------------End---------------------------- ---------------------------------------

There are related operation steps above, I am hungry. In the follow-up of this article, I still have a lot of content that needs to be supplemented and detailed and updated. For more information, please refer to the https://gitee.com/GB28181/GB28181.Solution project to introduce the content. "WeChat" in China joins the open source group, the group owner WeChat

Students who feel good, remember to like it!

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_16005627/article/details/105714572