Hikvision DS-2DE3304W-DE and Raspberry Pi4B install guide for noob's like me #84
Replies: 3 comments 1 reply
-
Thanks very much for this - I really really appreciate it! Question for you, if you have a minute... I'm experiencing really choppy video regardless of the source; the bunny video and a few different RTSP cameras. This is the same behavior I was experiencing when I tried using my Mac Mini as the host for the proxy. Got any good generic troubleshooting tips for a beginner like me? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I've managed to connect the same Hikvision Camera to my UDMP Protect and I'm able to see a first picture. However when opening the video stream it doesn't seem to work. The console is flooded with "HikvisionCam[1] INFO Connecting to motion events API" Number 1: File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code Number 2: root-unifi-proxy-1-1 | 2022-06-01 11:40:46 HikvisionCam[1] WARNING Previous ffmpeg process for video1 died. Any Ideas? Two things that are different in my setup:
|
Beta Was this translation helpful? Give feedback.
-
Update 2023-08-15, for n00bs like me also.The above doesn't work anymore, here's how I got it working. This is a complete guide assuming a very inexperienced user. Quick Tip: commands can be copied and then pasted into PuTTY using right-click. RaspberryPi OS InstallUsing a Raspberry Pi 4 (may work on 3 also), no keyboard, mouse or screen. Ethernet connection recommended (rather than WiFi). Put the card in the raspberryPi and power on. Connect it to your network with a cable. Update
The raspberryPi will reboot. In 2 mins, reconnect with PuTTY in the same way as before. Python and PipCheck it's installed...it will be
For reference, Python 3.9.2-3 is working fine for me. I'm sure any python3 will be fine.
mkdircreate a directory for your docker-compose and navigate into it.
Generate certificateGenerate the client certificate in this new directory
This returns
Check the result:
should show that you have Create the docker-compose file.This provides (literally) all of the instructions to download environment, prerequisites and files, create and image and containerise it.
Type out the following file. Indentations are double-space....I've read they're tab, but that causes an error. Perhaps tab is legacy.
Ctrl+X then 'Y' and Enter to save. Adoption tokenLogin to the CloudKey (or whatever) in a browser. Once you're in make sure you've opened/accessed the 'protect' application, then change the browser address to:
replacing Install DockerThis is where I've encountered problems using a 32-bit OS here, use a 64bit
Get docker to work without root privelidges with:
test with:
returns start the service
the hello-world should download and run without error.
Test it worksLogin using PuTTY
This parses docker-compose.yaml and tries to containerise all the instructions and launch. Unifi protect will prompt you that a new camera has been connected (if all goes well). Leave it running for ten mins to check for issues. Monitor in unifi protect. Once debugged, get it running from startupTo ensure it'll start automatically after power failure:
...will set the docker service to run once the user has logged in.
switch -d will run the the container in the background (no screen printing).
Choose option: 1 System Options DONE |
Beta Was this translation helpful? Give feedback.
-
Quick Start For Public share Unifi-cam-proxy on 8_22_21.pdf
(See attachment for directions with pictures)
Requirements and setup:
Raspberry Pi4B 4 or 8GB computer with USB C power supply or POE module
16GB MicroSD card Class 10 or better - Use a good quality card.
Monitor, Keyboard, Mouse and power for the Pi4B
Network connection for the Pi4B
Network connection for UDMP or UNVR
Network connection to desktop computer MAC in this example below.
Your Unifi account access to the UniFi equipment.
Camera - Please review the cameras listed on the unifi-cam-proxy Github resource.
All devices must be on the same network, Subnet and VLAN example: UDMP 192.168.1.1 , Pi4B 192.168.1.34 , non-unifi camera: 192.168.1.65
Unifi-Cam-Proxy program by Keshav Varma and all credit goes to the author:
https://github.com/keshavdv/unifi-cam-proxy
Install Raspberry Pi4B OS and unifi-cam-proxy steps:
Install clean new Raspberry Pi Buster O/S on 16GB card from a MAC or PC.
Go to Youtube link for help: https://www.youtube.com/watch?v=O_0w5EvEmD4
Install your new card into Pi 4B 4GB computer.
Connect Pi 4B to monitor, mouse keyboard and power.
Boot Pi ==> Configure Pi ==> Go to Raspberry Pi Configuration ==> Interfaces ==> SSH enabled
Reboot. Wait a for the Pi4B to complete boot on your network.
Record your Pi4B IP address to connect remotely through Puty on your PC or VSSH on your MAC
Connect remotely via VSSH on MAC. Connect to the correct IP address of the new Raspberry Pi4B on your network.
Use tools like Angry IP Scanner to find the Pi4B on your network.
A connected Pi4B boot should look like this on your remote SSH (MAC/PC) session.
From here you can cut and paste actions in the command line.
Commands are listed in green font from here on.
Update/upgrade your Raspberry Pi4B OS (will take a while).
Run these 3 commands via SSH:
sudo apt update
sudo apt full-upgrade
sudo reboot

Install Python 3.7 via SSH command:
sudo apt install python3
Check Python version
python3 --version
Should show: Python 3.7.3

Set Pi4B to default to Python 3.7.3
See example: https://www.youtube.com/watch?v=_DI0jgnrDVc
sudo nano ~/.bashrc (move cursor to bottom of code to paste command at the bottom)
Paste: alias python='/usr/bin/python3' Ctl O , ENTER then Ctl X
Run: source ~/.bashrc
python --version
Install ffmpeg
Help: https://www.bitpi.co/2015/08/19/how-to-compile-ffmpeg-on-a-raspberry-pi/
sudo apt update
sudo apt upgrade
https://snapcraft.io/install/ffmpeg/raspbian
First:
sudo apt update
sudo apt install snapd
sudo reboot
Second:
sudo snap install core
sudo reboot
Third:
sudo snap install ffmpeg --classic (-minus,-minus, classic)
Forth - Check version:
ffmpeg -version (-minus, version)
Standard Version installed:
ffmpeg version 4.1.6-1~deb10u1+rpt2 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
See this:
https://lindevs.com/install-ffmpeg-on-raspberry-pi/
Un-Install FFMPEG:
sudo apt purge —autoremove -y ffmpeg ( - , - , autoremove)
View what version ffmpg you have installed
ffmpg -version
Install netcat
sudo apt-get install mplayer netcat
10.1 OPTIONAL - Install Docker for those who would rather use Docker for installs.
https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl
Generate client certificate on the Pi root directory by running command (Cut and paste all of this command in to the command line and press enter on the last line to run)
dir or ls
After these commands run type DIR and you see that a client.pem file is generated on the Pi4B
Generate a token to be used on the UDMP or UNVR.
This is different directions than listed on unifi-cam-proxy Github page.
Go to Unifi Protect user interface on your computer (you must have login rights).
A. On the Protect UI, Click Devices (upper left corner icon) Then click 'Add Devices' in the upper right corner then click Find More Devices bottom left corner.
There will be a “pop-up box” selection of Unifi cameras.
Select 'G3 Micro'.
Select 'Continue on Web' and type in a random string for the SSID and Password fields and click 'Generate QR Code'
B. With the AP De-Barcoder loaded on your phone scan the barcode.
Raw data will appear on the screen
Click Copy to pasteboard button
From your phone email the content to your desktop computer.
Open your desktop computer email.
Copy the second to last line of characters that look something like this: ABC3fQQQQQQQQQQQQQ8XYZKWHoK
Record this list of characters for use later as your Token.
Now you are ready to install Unifi-Cam-Proxy on your Raspberry Pi 4B
pip3 install unifi-cam-proxy (This will install UniFi-cam-proxy)
Above looks like a successful install.
RTSP stream
After this you can run the BigBuckBunny test or your specific camera command line from here. OPTIONAL
Pi4B must be running the unify-cam-proxy at all times on your camera network to serve the proxy tokens for your non-Unifi cameras.
Test your Pi4B OS and unify-cam-proxy install with BigBuckBunny video.
192.168.XX.YYY is the IP address of of your UNVR or UDMP
ABC3f3nAFPX123FISpZmFSJ8XYZKWHoK is your Token you generated.
unifi-cam-proxy --host 192.168.XX.YYY --cert client.pem --token ABQQQQQQQQQQQQQQQQQQQQQK rtsp -s rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov
After this code is running on your Pi4B go to the Unifi Protect under interface
A camera UVC3G with IP address of 192.168.1.10 will be running the Bunny movie. Click Live Feed to see it.

Control+Z to stop the Bunny Video.
Run the HiKVision camera (other commands for your specific camera)
192.168.19.163 is the IP address of your UNVR or UDMP
192.168.19.94 is the IP address of your camera
user name of camera: admin
Password of camera: 9Wodda!
unifi-cam-proxy -H 192.168.19.163 -i 192.168.19.64 -c client.pem -t 1234lvnKnAGVe6AblXmfDOWE1wD4ABCD hikvision -u admin -p 9Wodda!
Open up the UDMP user interface to view Live Stream for the new camera added.
From power off:
unifi-cam-proxy -H 192.168.10.153 -i 192.168.10.64 -c client.pem -t 123zlvnKnAGVe6AblXmfDOWE1wDABCD hikvision -u admin -p 9Wodda!
If you get command line fail - generate a new token goto step 10.
unifi-cam-proxy -H 192.168.10.153 -i 192.168.10.64 -c client.pem -t 123xSH3OGqS9ABCi9QhE1a9vm333Yz8R hikvision -u admin -p 9Wodda!
Run: source ~/.bashrc
Run python --version
Run update for current Unifi Proxi software: pip3 install unifi-cam-proxy
Backup your card to an image file OPTIONAL
Example for help: https://www.youtube.com/watch?v=Nc3YyANoOeQ
Pull card from Pi. Plug card into adapter. Plug into MAC. Once card sees BOOT image use Disk Utility Tools to find out what DRIVE # it is IE: 4
Change the drive number below from 1 to drive number of BOOT disk.
Run this command in the MAC terminal:
sudo dd if=/dev/disk4 of=~/Desktop/PiSDCardBackup.dmg
Burn new card with IMAGE backup. Use Etcher 2
20 Auto Run Unifi-Cam-Proxi when your Pi boots. OPTIONAL
Example for help: https://www.youtube.com/watch?v=RFyqi5Utcqw
Boot Pi
Run : sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Add on the last line you command line for to run your Unifi-Cam-Proxy command:
@unifi-cam-proxy -H 192.168.XX.Y -i 192.168.XX.ZZ -c client.pem -t nQQQQQQQQQQQQQQQQQQpZ5 hikvision -u admin -p PPPPPa!
Control-O / Control-Z (Updates your lxsession boot file
Sudo Reboot
Beta Was this translation helpful? Give feedback.
All reactions