Closed d827bcx closed 2 years ago
Welcome to the club lol everyone is having this issue no one has found a solution, even the test video does this now. Stale bot just keeps closing the reports of this automatically.
Ugh - okay, thank you for letting me know. I was hoping that because the Android app displays the stream without issue, there were some settings or code to muck with to resolve.
This usually means your camera/stream needs a bitfilter to make the browser's player happy. Have you tried with any combination of --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=<2x your camera's FPS>:fixed_frame_rate_flag=1"
?
@GhostlyCrowd, I believe I'm on the latest version of Protect and have still been using a Hikvision camera without issues for the past few months. Can you share a repro of your issue using the test video in a separate issue?
Thank you for the tip. I haven't had any luck yet - but I'm not an expert on ffmpeg, so I'll keep messing around, but can you confirm that this looks right in the console? Do I need any other args to ffmpeg?
unifi-cam-proxy -H --mac AA:BB:CC:00:11:22 -c /cert/client.pem -t token rtsp -s rtsp://user:pass@ip:554/Streaming/Channels/101/?transportmode=unicast.sdp --ffmpeg-args "-c:v copy -vbsf:v h264_metadata=tick_rate=48:fixed_frame_rate_flag=1"
021-12-20 14:04:13 unifi-cam-proxy-RTSP RTSPCam[1] INFO Spawning ffmpeg for video1 (2r6ESyuhAhd0eN6c): ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://user:pass>@<ip:554/Streaming/Channels/101/?transportmode=unicast.sdp" -c:v copy -vbsf:v h264_metadata=tick_rate=48:fixed_frame_rate_flag=1 -metadata streamname=2r6ESyuhAhd0eN6c -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 10.37.12.6 7550
FYI - camera settings (I've messed around with these a little bit as well, but still no luck - open to any help) Stream Type: Main Stream(Normal) Video Type: Video Stream Resolution: 3840*2160 Bitrate Type: Variable Video Quality: Medium Frame Rate: 24 fps Max. Bitrate: 6144 Kbps Video Encoding: H.264 H.264+: OFF Profile: Main Profile I Frame Interval: 50 SVC: OFF
Thanks!
Some more success - app and browser now both working for live view. I saw the notes in issue 126 and ran ffprobe to get the right frame rate value and pulled off fixed_frame_rate_flag.
Now to try working on detections. If anyone has any hints, they would be much appreciated.
Disclaimers: I only have a single Annke NC800 that I've tested with, the pyHik code is obviously not my own, and a huge thank you to everyone that has posted details here of thier efforts.
That said, I have my cam working with recording, live view for browser and android app and motion events in protect (using UNVR). I do not have audio working yet.
It appears that Annke is nearly identical to Hikvision in all respects except that in the RTSP stream, /101 is needed rather /1 (my camera is not PTZ so I couldn't test that). If anyone is inclined to update the HikVision cam code to support Annke - thank you.
I'm using the docker image and have not made any modifications to the version of ffmpeg.
unifi-cam-proxy -H nvrIP --mac mac -i camIP -c /cert/client.pem -t token rtsp -s rtsp://user:pass@camIP:554/Streaming/Channels/101/ --ffmpeg-args "-c:v copy -vbsf:v h264_metadata=tick_rate=24" --http-api 8211
I got the tick rate using ffprobe RTSP stream from camera Which returned Stream #0:0: Video: h264 (Main), yuvj420p(pc, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 12 tbr, 90k tbn, 180k tbc Oddly, mine didn't have an fps item and I ended up doubling the tbr value. I also left off the fixed_frame_rate_flag which made live view in the browser finally work for me.
I also specified the added the http-api switch for motion.
Next, I found pyHik, so a big thanks to mezz64 for that great work: https://github.com/mezz64/pyHik
I set up a simple motion event on the cam itself event->basic event->enable motion detection and then just created a zone that fills up the whole screen and specifed the Linkage Method to Notify Surveillance Center.
Next, I edited his basic_usage.py to put in the cam IP, user and password cam = HikCamObject('http://XXX.XXX.XXX.XXX', 80, 'user', 'password') Then I ran basic_usage.py and walked in front of the camera a few times.
When I looked at console, I had a bunch of events: /usr/local/bin/python ./basic_usage.py NAME: IP CAMERA ID: 9aee4000-9be4-11b4-832c-44a6426b4e11 {'Motion': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397361)]], 'Tamper Detection': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397364)]], 'Disk Full': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397366)]], 'Disk Error': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397367)]], 'Illegal Access': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397368)]], 'Line Crossing': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397369)]], 'Field Detection': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397370)]], 'Bad Video': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397371)]], 'Entering Region': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397372)]], 'Exiting Region': [[False, 1, 0, datetime.datetime(2021, 12, 26, 12, 27, 3, 397373)]]} Motion Dectect State: True Callback: 9aee4000-9be4-11b4-832c-44a6426b4e11.Motion.1 IP CAMERA Motion 1:True @ 2021-12-26 12:28:02.748494 Callback: 9aee4000-9be4-11b4-832c-44a6426b4e11.Motion.1 IP CAMERA Motion 1:False @ 2021-12-26 12:28:18.947367 Callback: 9aee4000-9be4-11b4-832c-44a6426b4e11.Motion.1 IP CAMERA Motion 1:True @ 2021-12-26 12:28:19.866964 Callback: 9aee4000-9be4-11b4-832c-44a6426b4e11.Motion.1 IP CAMERA Motion 1:False @ 2021-12-26 12:28:52.947706
Then I edited basic_usage.py to call the urls in unifi-cam-proxy on motion start and stop
self.hik_request.get("http://10.37.12.17:8211/start_motion", timeout=5)
else:
#print("Motion End")
self.hik_request.get("http://10.37.12.17:8211/stop_motion", timeout=5)
And that's it - I launched basic_usage.py again and walked in front of the cam and events started appearing in protect. I've noticed it can take up to a minute for the end of motion to trigger.
If someone with coding skills beyond mine can integrate all of this so that using the hikvision switch makes all this happen automagically, I think many folks would be happy.
To get audio working, I just changed the ffmpeg param to: --ffmpeg-args "-c:v copy -vbsf:v h264_metadata=tick_rate=24 -ar 32000 -ac 1 -codec:a aac -b:a 32k" and then on the cam set Configuration->Video/Audio->Video->Video Type to Video&Audio With the Audio settings: AAC/16kHz/32kbps
Now I believe I have everything working as I would have hoped.
@keshavdv - I just wanted to close this out with a huge thank you for developing this. Everything is working great after the tinkering as above (and some more to create a single docker that starts up both unifi-cam-proxy as well as pyHik).
@keshavdv - I just wanted to close this out with a huge thank you for developing this. Everything is working great after the tinkering as above (and some more to create a single docker that starts up both unifi-cam-proxy as well as pyHik).
Thanks. I make docker volume with you edition of pyhik. https://hub.docker.com/repository/docker/andrew55529/unifi-cam-proxy-api-motion Need 4 arg 1-ip:port where unifi-cam-proxy, 2-ip camera,3-login camera,4-password camera) example: docker run --restart always -d andrew55529/unifi-cam-proxy-api-motion 192.168.10.2:2411 192.168.10.111 admin Password
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@keshavdv - I just wanted to close this out with a huge thank you for developing this. Everything is working great after the tinkering as above (and some more to create a single docker that starts up both unifi-cam-proxy as well as pyHik).
Thanks. I make docker volume with you edition of pyhik. https://hub.docker.com/repository/docker/andrew55529/unifi-cam-proxy-api-motion Need 4 arg 1-ip:port where unifi-cam-proxy, 2-ip camera,3-login camera,4-password camera) example: docker run --restart always -d andrew55529/unifi-cam-proxy-api-motion 192.168.10.2:2411 192.168.10.111 admin Password
What is the value of the first argument? The IP address on which machine I run the container you created in docker? Is the port a random port that is not in use?
Hello -
I have a Annke NC800 camera. I am running Protect 1.20.0 on a UNVR with UniFi OS Version 2.2.12.
I am using the latest Docker image with the command: unifi-cam-proxy -H ip --mac AA:BB:CC:00:11:22 -c /cert/client.pem -t token rtsp -s rtsp://user:pass@ip:554/Streaming/Channels/101/?transportmode=unicast.sdp
The stream is recording but it is not quite working as expected.
When logging into the NVR via the web, I can go to Playback and watch the historical recording, but whenever I try to view the live feed, it just shows a single, current still frame and forever displays the 3 loading dots in the bottom left corner. However. if I use the Android app, the live feed displays without issue.
Also, it is not creating any detection snippets.
Does anyone have any thoughts or suggestions?
Thank You