keshavdv / unifi-cam-proxy

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

Foscam Cameras #134

Closed pgeremia closed 2 years ago

pgeremia commented 2 years ago

Discussed in https://github.com/keshavdv/unifi-cam-proxy/discussions/133

Originally posted by **pgeremia** December 28, 2021 Hello, I set up a CentOS 8 Stream VM and loaded all of the prerequisites. I am able to run unify-cam-proxy with no problem and it does connect to my Protect NVR. I would like to use it with my Foscam Cameras. rtsp://username:password@cameraip:88/videoMain The above is the rtsp address I am using. I am able to bring it up in VLC with no problem. Below are the video attributes from VLC: image I cannot get this to stream to Protect. I do see the thumbnail, but that is about it. Any ideas? Thank You, Pete
pgeremia commented 2 years ago

This SORTOF works. I get choppiness and blanking out in the unifi web app. Plus the iPhone app just crashes when going to the live view. I will keep trying. I also had to do the timeout hack since I built my own version of ffmpeg from source.

unifi-cam-proxy --host NVRIP --ip CAMIP --mac CAMMAC --cert camcerts/client.pem --token CAMTOKEN rtsp -s rtsp://camuser:campass@camip:88/videoMain --ffmpeg-args '-c:v copy -bsf:v "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 2 -codec:a aac -b:a 32k'

pgeremia commented 2 years ago

I set the Foscam camera video with the following settings:

Stream Type: QHD Mode Resolution: 2K Bitrate: 2M Frame Rate: 15 Key frame interval: 15 Rate Control Model: None

Then I use this for unifi-cam-proxy:

unifi-cam-proxy --host 10.xx.xx.1 --ip 10.xx.xx.131 --mac 00:62:6e:ec:88:28 --cert camcerts/client.pem --token unifiToken rtsp -s rtsp://camuser:campassword@10.xx.xx.131:88/videoMain --ffmpeg-args '-c:v copy -bsf:v "h264_metadata=tick_rate=30030/1001" -ar 32000 -ac 2 -codec:a aac -b:a 32k'

This works pretty well in the Web application but causes iPhone app to still crash. When I run ffmpeg alone I see this.

[h264 @ 0x3446640] decode_slice_header error [h264 @ 0x3446640] no frame! [h264 @ 0x3446640] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3446640] decode_slice_header error [h264 @ 0x3446640] no frame! [h264 @ 0x3446640] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3446640] decode_slice_header error [h264 @ 0x3446640] no frame! Guessed Channel Layout for Input Stream #0.1 : mono Input #0, rtsp, from 'rtsp://admin1:lsasamicL9@10.99.99.131:88/videoMain': Metadata: title : IP Camera Video comment : videoMain Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (Constrained Baseline), yuvj420p(pc, progressive), 2304x1536, 90k tbr, 90k tbn Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native)) Output #0, flv, to 'pipe:': Metadata: title : IP Camera Video comment : videoMain streamname : Mac95XA5INegyDzZ encoder : Lavf59.10.100 Stream #0:0: Video: h264 (Constrained Baseline) ([7][0][0][0] / 0x0007), yuvj420p(pc, progressive), 2304x1536, q=2-31, 90k tbr, 1k tbn Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, stereo, fltp, 32 kb/s Metadata: encoder : Lavc59.15.102 aac [aac @ 0x3481100] Queue input is backward in time0:00:00.00 bitrate=N/A speed= 0x
[flv @ 0x344d600] Non-monotonous DTS in output stream 0:1; previous: 453, current: 450; changing to 453. This may result in incorrect timestamps in the output file. [aac @ 0x3481100] Queue input is backward in time Last message repeated 1 times [flv @ 0x344d600] Non-monotonous DTS in output stream 0:1; previous: 863, current: 855; changing to 863. This may result in incorrect timestamps in the output file. [aac @ 0x3481100] Queue input is backward in time [flv @ 0x344d600] Non-monotonous DTS in output stream 0:1; previous: 1433, current: 1414; changing to 1433. This may result in incorrect timestamps in the output file. [aac @ 0x3481100] Queue input is backward in time

keshavdv commented 2 years ago

Try using -ac 1 to mirror the fix in https://github.com/keshavdv/unifi-cam-proxy/commit/2d469a83886c4553ec15fd00eb87c744bbf576d1

pgeremia commented 2 years ago

That did it! Thank you!!!