keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.65k stars 230 forks source link

Issue streaming JideTech cameras #150

Closed hamster closed 2 years ago

hamster commented 2 years ago

Howdy,

I have two cameras from JideTech, specifically these ones: https://www.amazon.com/gp/product/B07KSWNDXV

Both cameras work fine with Zoneminder and I can open the stream fine in VLC. However, I cannot get a live view from these cams. It does appear that Unifi does record the stream, however. I've played with the camera settings quite a bit with no luck. I assume there might be some ffmpeg options I can use to convert the stream into something Unifi likes, but I don't know what that would be.

I have other cameras that work fine with this proxy. I am using the latest version of the proxy, and Unifi Protect version 1.21.0-beta.3 (though it was doing the same thing using the release channel version)

$ ffprobe rtsp://admin:password@192.168.1.231:554/1/h264major ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 [rtsp @ 0x563fd5f41e40] max delay reached. need to consume packet [rtsp @ 0x563fd5f41e40] RTP: missed 27 packets [h264 @ 0x563fd5f45940] error while decoding MB 49 20, bytestream -7 [h264 @ 0x563fd5f45940] concealing 5760 DC, 5760 AC, 5760 MV errors in P frame Input #0, rtsp, from 'rtsp://admin:password@192.168.1.231:554/1/h264major': Metadata: title : h264major comment : h264major Duration: N/A, start: 0.084000, bitrate: N/A Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 20 tbr, 90k tbn, 180k tbc Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s

image

Any tips would be appreciated.

dsinfinite commented 2 years ago

I have a similar camera. I just got further than the last time I tried.

image

Probe: Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt470bg/bt470bg/bt709, progressive), 1280x960, 10 fps, 18.58 tbr, 90k tbn, 20 tbc

Options, tick rate is 2x fps: --ffmpeg-args "-c:v copy -vbsf:v h264_metadata=tick_rate=20"

During live view, change it from Auto 720p to full 1080P

dsinfinite commented 2 years ago

Got further - looks to work with these settings:

image

rtsp://192.168.253.197/1/h264major --ffmpeg-args "-c:v copy -vbsf:v h264_metadata=tick_rate=20"

GhostlyCrowd commented 2 years ago

Got further - looks to work with these settings:

image

rtsp://192.168.253.197/1/h264major --ffmpeg-args "-c:v copy -vbsf:v h264_metadata=tick_rate=20"

If your camera does CBR which is does, I would use that, drop it down to around 1024 and keep the tick rate arguments, work your walk up from there in the bitrate until you hit a live viewing issue and then pull it back a bit. 8192 kbps * 3 is 24.576 mbps might be too taxing on the camera and also depends on network congestions locally.

dsinfinite commented 2 years ago

Works fine at 8192 with VBR/CBR with no buffering.

Issue with it working only at 1080p and not Auto 720 is that I was also using Synology Surveillance station at the same time. As soon as I disabled it in that DVR everything seems to work fine so far.

GhostlyCrowd commented 2 years ago

Works fine at 8192 with VBR/CBR with no buffering.

Issue with it working only at 1080p and not Auto 720 is that I was also using Synology Surveillance station at the same time. As soon as I disabled it in that DVR everything seems to work fine so far.

Right so, Disabling the other open stream from the synology suggests what I was getting at still, were your running the cameras ability to keep up with open streams. CBR is still a better option for stability vbr is better for bandwidth and resources though but do note that your argument proxy opens 3 streams to the camera at the bit rate you set to satisfy its needs so it does not reject the camera as well as a stream to make snapshots, thats 4 streams and very taxing on a camera at such a high bit rate. The Auto, 720p and 1080 P streams are essentially all the same thing from the ffmpeg proxy input as far as i can see. video 1-3 stream from the argument input. Id assume you saw a lot of "change video settings" arguments in your unify cam proxy, thats the proxy tossing out a stream being called on because it is not usable. As soon as you shut the synology off it freed up resources and it was fine.

hamster commented 2 years ago

Dang, still no love for me with the settings @dsinfinite describes. Perhaps my firmware is out of date?

image

It also seems like the 3 ffmpeg video streams are constantly being respawned. Maybe I have a wacky version of ffmpeg?

i$ ffmpeg ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100

I do get a very low res preview right as it starts, but no stream or anything after that.

hamster commented 2 years ago

Hah, and my other camera has a different firmware: V1.04.10-190430. Same issues, though.

I've sent an email request for an updated firmware, we'll see if that helps any.

dsinfinite commented 2 years ago

Forgot that when I first installed it I manually modified the base.py under the cams folder. This is the change I had to make for my other cameras:

Old: "ffmpeg -nostdin -y -stimeout 15000000"

New: "ffmpeg -nostdin -y -use_wallclock_as_timestamps 1"

Also, using a build from around August of last year - haven't updated yet.

GhostlyCrowd commented 2 years ago

You do not have to modify the base python code to pass ffmpeg arguments, you can use --ffmpeg-args='-use_wallclock_as_timestamps 1'

What reason did you remove the stream connection time out for. If there was a reason it should be noted here for others and for investigation.

dsinfinite commented 2 years ago

You do not have to modify the base python code to pass ffmpeg arguments, you can use --ffmpeg-args='-use_wallclock_as_timestamps 1'

What reason did you remove the stream connection time out for. If there was a reason it should be noted here for others and for investigation.

I will have to go back and do some testing - I was using unifi-cam-proxy as a temporary stop-gap until my unifi cameras arrived. I just pulled everything out again since I still have a Jidetech camera connected to my other DVR solution to see if I could help hamster.

hamster commented 2 years ago

OK, I got updated firmware, which they say is the last version available, V1.04.10-190121

Still not able to get anything more than a snapshot at start up.

stale[bot] commented 2 years ago

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.