thirtythreeforty / neolink

An RTSP bridge to Reolink IP cameras
https://www.thirtythreeforty.net/posts/2020/05/hacking-reolink-cameras-for-fun-and-profit/
GNU Affero General Public License v3.0
893 stars 151 forks source link

Swann DVR #314

Open ghc88uk opened 2 years ago

ghc88uk commented 2 years ago

I have installed neolink and am trying to connect to an old Swann DVR4-4400. Wire Shark identifies the DVR as Reolink so was hoping this would work, and I've seen at least one mention of this working with Swann DVRs. However, I am getting failed to login error message. There is no user/pass set for the DVR, I can't even seem to set one in the old swann viewlink native application... however, I can login and view the feeds this way with any user/pass combination...

Would be amazing to get this working with my Swann DVR as it's exactly what I've been wanting to do for a while and it's annoying there's no way to actually view the streams, other than through the rubbish Swann applications! Would really like to integrate the camera feeds into Home Assistant...

[2022-09-22T23:20:55Z ERROR neolink::rtsp] Error streaming from camera driveway, will retry in 1s: Failed to login to driveway

QuantumEntangledAndy commented 2 years ago

It should work just fine @twistedddx is our Swann expert and neolink seems to work with his cameras.

Their is a default password which I think is

Username: admin Password: 1234 Or Password: 12345 Or Password: 123456 Depending on the model

Try those and see what works.

ghc88uk commented 2 years ago

Thanks for the response. I've tried all of those username/password combinations and no luck... I've also tried them following a reset of the DVR to default settings and still no luck. The Swann View app seems to let me login with any username/password (or none at all), which is strange, and I can't seem to be able to actually set a username/password within the application (it comes back with an error, saying user can't be added).

Ahhh, I feel like I'm so close, it would be so good to get it working as my only other option is to buy new cameras and a DVR, and having to re-route new cables (from BNC probably to ethernet) would be a pain...

ghc88uk commented 2 years ago

After some reading, I figured out that the only way of setting a password was by connecting the DVR to a screen and keyboard. I've done that now and the user/pass setup is working like it should now. However, neolink still can't login... I assume that it just doesn't work with my swann DVR, which is a shame :(

twistedddx commented 2 years ago

Swann stuff goes right back to the legacy BC protocol that is not supported by Neolink.

Do you have a firmware version of the dvr? Swann usually has GA versions like 1.9 or 2.0. The last thing Swann released for BC units was 3.1. Many but not all units got GA 3.1. I have a feeling it was around 3.x that they switched to the modern BC protocol that Neolink supports.

Use the Wireshark dissector and see if it only understands the initial login message. Legacy will not have XML anywhere.

ghc88uk commented 2 years ago

Device type: DVR4-4400 Build No.: build 1507140 Hardware Ver: F2MB04

Config Ver.: v2.0.0.0 Firmware Ver.: blank

I'm very new to wireshark, but I'll look into how to do what you've said. I'm assuming I should start sniffing on wireshark, then connect via the Swann application, and try and capture the contents of the packets to have a look at them. I'm not sure what I'd be looking for to be honest, unless it was plain text, which I'm assuming it's not.

It sounds like it's not (easily anyway) going to be possible to use neolink to connect to it. I think I'm out of ideas on how to retreive the stream data from port 9000, so it might be time for a new CCTV system...

twistedddx commented 2 years ago

150714 is 14th July 2015 and CFG 2.0.0.0 gives me some confidence your device is stuck with legacy only making it too old for Neolink. You need to reach 2016/2017 era firmware I believe.

Wireshark is an advanced tool and you may get in over your head quick but here is a crash course.

Get the dissector here https://github.com/thirtythreeforty/neolink/blob/master/dissector/baichuan.lua

Edit in notepad or similar the TCP port at the bottom of the Lua file to match the port you connect to your dvr.

Put Lua file in the plugins folder of Wireshark. Set Wireshark to capture from your network interface. In the filter text box at the top put ip.addr == 192.168.1.10 where that IP is the dvr IP

Then use official DVR client and watch for baichuan packets.

I imagine straight after the login the dissector will not be able to tell you much about the packets as it will all be legacy. It should swap to modern packets but it will not.

ghc88uk commented 2 years ago

Firstly. thanks for the advice, it's much appreciated. I've made some progress. I setup the BC lua plugin. At first I tried using the native Swann View client, but had no luck at all. However, I then setup a Windows XP VM and used the browser based Active X Swann viewer, and bam, I had loads of Baichuan packets coming through. What's crazy is that the username and password seem to be transmitted in plain text, as I can see them in Wireshark.

I found the following in an old blog (consolecowboys):

_"Some time ago I was looking for ways how to connect to my Swann DVR over internet and skip their ActiveX component. This search got me to this page and somehow inspired to dig deeper, as I wasn't able to anything from the net. Next stop was [BROKEN LINK]. Apparently most of cheap end DVRs are coming from the same place and have same software within. Take away from previous article for me was that network traffic what is happening between ActiveX component and DVR is not encrypted. From my school days I remembered that there is a way to look into TCP traffic going out from your computer. I got myself Wireshark and spent couple of hours reading how TCP works. Basically you just need to get tour Wiresark going and see what kind of a traffic is going from ActiveX component to DVR and what comes back. It appears that there is plain h.264 video stream coming for every channel and you can save/stream/watch it really easily. It takes just connecting to your DVR media port (9000) and sending one TCP packet per channel to initiate the stream. In Wireshark look for the package with length 561 (or 3rd packet in TCP stream flow for every camera). Copy binary format of this packet payload and that is your key in. Simple linux command that worked for me is below (this ugly looking part after echo command is the place where you want to put the payload data you copied before)

echo '0000000000000000000001000000030f0000000000000000000068000000010000001000000001000000010000000061646d696e00000000000000010000000100e3194000446d00000000602bc21c6e6f72383474000030732a14a01e0000a8440000020000000050dc7efcb4d713000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' | xxd -r -p | nc 192.168.1.244 9000 > cam1.h264

This script will keep writing pure h.264 stream into the file. In case you want to have some remote viewing application built on top you probably want to create some named pipe and send stuff there. Then take ffmpeg, convert the stream into something else and do what ever you need to do with it. "_

Unfortunately, I can't work out what packet they are talking about as I can't find one that has a length of 561 and I'm not sure what is meant by "third packet", as I follow the TCP stream and have lots of long hex streams. I feel like I'm close to being able to grab the stream using this method. If I have any success then I'll report back and try and help others. Any further advice on how to extract the correct packet(s) to initiate the video stream would be greatly appreciated.

ghc88uk commented 2 years ago

Bingo, got it.. well, kind of. My attempts to keep trying different packets didn’t work, so I took the whole stream and used that.. and it works! Well, mostly… It comes back with all four camera feeds kind of spliced into one, alternating between each so I’ll need to find a way of either working out how to return only one feed at a time or demuxing them. I have no idea which part of the stream was the part it needed to initiate returning the video feed, so I’ll need to do more investigating so I can understand how I’ve actually got it working :)

RyanTheTide commented 2 years ago

Wonder how different the DVR4-4400 is from the DVR4-1580. Trying to get the cameras into home assistant too (see issue #284) and was hoping to get all four at full 720p. Have a look at my issue if you haven't yet and see if anything is relevant. In fairness however I have gotten further just crashes when more than two of the cameras are tried at the full resolution (mainStream).

ghc88uk commented 2 years ago

I saw your issue which is what gave me some hope I could get neolink working with mine, but I can't get neolink to connect to my swann DVR at all. Looking at pictures of your DVR, it looks very similar, the physical unit is near identical other than a slightly different looking casing. Your firmware version looks later than mine, so they must have changed something to do with how the DVR communicates. Wireshark is identifying packets at BC though, so I don't suspect it changed that much. Life/the day job keeps getting in the way but I made progress last night in that I can now send a command to port 9000 on the DVR and get it to feed back the raw h264 streams, which I'm capturing into a file. I need to work out exactly what part of the TCP stream I sent that's actually made it work, figure out how to split the four video streams, and then if I can do that I'll find a way of feeding it into HA - probably via an RTSP stream. I'll let you know how I get on and post the solution if I get there, as it might be another option for you. Perhaps have a look at what's going on between your client on your DVR using wireshark, I had to use the active X web client (I used an existing VM running XP as it needs internet explorer) as the Windows SwannView client doesn't seem to use TCP at all...

QuantumEntangledAndy commented 2 years ago

Could you screen shot the packets you get in wireshark, maybe it would be helpful to see if it is modern or legacy format. We also have some docs in the repo that show how the modern packets are layed out which might help you figure out which packet belong to which stream.

ghc88uk commented 2 years ago

Here's a couple of screen shots:

screenshot1 screenshot2

Through lots of trial and error, by sending the following via nc, it fully captures one of the camera streams to a file. The file won't open straight away in VLC, it plays fine using ffmpeg. By using ffmpeg to convert it, I am then able to play it in VLC no problem. As I built up the TCP stream through trial and error, picking things from wireshark, I don't fully understand why it's working, and therefore don't know how to get it to feedback the video stream from my other camera! I'll take a closer look at the neolink docs and see if I can get my head around the protocol a bit more, and then hopefully I'll be able to work out how to get it to feed the other camera stream back as well.

echo 'f0debc0a0100000028070000000000000000000032313233324632393741353741354137343338393441304534413830314643000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007062000000000000e6070000090000001c0000000f000000030000002100000000000000f0debc0a03000000100000000700000035002d000100000026030a000000000000000000f0debc0a3600000024220000080000000000000036000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' | xxd -r -p | nc 192.168.50.26 9000 > cam1.h264

ghc88uk commented 2 years ago

I've got it! So, I now have the two commands working, and can therefore capture both camera feeds seperately, to seperate .h624 files using the netcat commands, I now need to figure out how I can relay this output via an RTSP server. I'm wondering what the easiest way doing this would be. Now I have the required TCP streams to initiate the feeds, do you think it would be doable for me to try and use neolink, modifying the neolink code to essentially hardcode what tcp stream to send to the media 9000 port? The only other thing I can think of doing is setting up an RTSP server in parallel, to try and relay the files as they are being populated by netcat. However, I'm not sure how practical/realistic that is, as I guess it could get messy in terms of timing and read/write access to the h264 file? Also noting the video will only play in VLC following running it through ffmpeg, I guess there might be a need for some processing in between capturing it using netcat and sending it out over RTSP, I'm not sure how flexible RTSP is as it might not recognise it as video without the correct headers etc...

ghc88uk commented 2 years ago

Well, that was easier than I thought... I downloaded and started rtsp-simple-server. Then I simply ran the following command:

ffmpeg -re -stream_loop -1 -i C:\path\to\captured_stream.h264 -c copy -f rtsp rtsp://localhost:8554/mystream

Added the camera to home assistant and seems to work perfectly well. The overall solution is obviously relatively messy as I need to have three things running to stream one camera (netcat capturing the video, rtsp-server running, ffmpeg streaming the video via RTSP server). I don't think I'm keen to host these directly on my home assistant RPi4, especially for two video feeds, as I imagine it takes quite a bit of processing power. A seperate machine/RPi4 is probably what I'll need to use...

Thanks for the help, especially regarding using Wireshark to figure out what I needed to send to the DVR media port to get it relaying video back.