keshavdv / unifi-cam-proxy

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

streaming not working in 1.21.3 #199

Closed jurajs5 closed 1 year ago

jurajs5 commented 2 years ago

no streaming in version 1.21.3

snapshots are there, but streaming is KO in proxy site, looks like all is ok, but in unifi UDM pro - there is no video, 3dost all the time (loading)

Camera:

henningpeter commented 1 year ago

Forgot to mention that I also have some errors like: "HikvisionCam[22772] WARNING Previous ffmpeg process for video3 died." when I don't use the -s parameter to force a particular substream. It reaches substream 3 which my Hikvision camera does not have. Mine goes only to 2 so I force either substream 1 or 2. (-s 1 or -s 2 in the proxy start command).

Buster14 commented 1 year ago

@henningpeter So all functions work except web live view? does this also work for the unifi x86 docker image?

Particpant commented 1 year ago

Am I understanding that a ffmpeg upgrade fixes the issue? Could someone who has set this up create a PR, please?

henningpeter commented 1 year ago

@henningpeter So all functions work except web live view? does this also work for the unifi x86 docker image?

For me yes. No idea about the docker image, i run it installed on the host.

bigjools commented 1 year ago

@henningpeter So all functions work except web live view? does this also work for the unifi x86 docker image?

For me yes. No idea about the docker image, i run it installed on the host.

Same. Protect Android app shows live view, web UI does not (in Chrome, not tried other browsers).

keshavdv commented 1 year ago

Does recording playback work for you or are the time stamps incorrect? I've been working on fixing that but would be surprised if ffmpeg was the only fix. Also, disabling the microphone in the UI on the web browser seems to fix playback on browsers since I suspect the requirement for an additional OPUS audio stream in the video is a hard requirement but hard to fix at the moment since ffmpeg doesn't allow that codec in a FLV container. There are some custom patches to enable support, but will require a custom compiled ffmpeg binary.

bigjools commented 1 year ago

Does recording playback work for you or are the time stamps incorrect? I've been working on fixing that but would be surprised if ffmpeg was the only fix. Also, disabling the microphone in the UI on the web browser seems to fix playback on browsers since I suspect the requirement for an additional OPUS audio stream in the video is a hard requirement but hard to fix at the moment since ffmpeg doesn't allow that codec in a FLV container. There are some custom patches to enable support, but will require a custom compiled ffmpeg binary.

I went to check again and here's the current state for me:

Also, disabling the microphone in the UI on the web browser seems to fix playback on browsers

I've done this ("permanently disable" etc), and it's not helped. The live view is a good quality fixed image but does not update.

bigjools commented 1 year ago

Does anyone have the FLV stream from Reolink cameras working? I threw in a quick hack to change the video source URL but ffmpeg keeps dying.

rgobbel commented 1 year ago

Does anybody have any detailed information on exactly what's failing? I want to see if I can fix it, provided it's not an unreasonable amount of effort. I'm already looking at swapping out ffmpeg for gstreamer so I can run on an Nvidia AGX Xavier, which has pretty good support for hardware decoding and encoding with gstreamer, no hardware support for encoding, and seriously buggy support for decoding with ffmpeg. I have various bits of Intel hardware available as well, so this wouldn't just be for aarch64.

jimmyfortinx commented 1 year ago

On my side, after trying the koehler/unifi-cam-proxy:protect-124 docker image, I've been able to make my camera work on Android and iOS, but only without audio -f="-c:v copy -an". As soon as I bring back the audio, the live feed and the recording stopped working on Android. On iOS, the live feed worked but the audio cuts a lot and recording does weird behaviour like it is speed up for a while and stop playing.

I also tried building my own docker image using the clean-snapshots branch, but I've got the same results.

After looking at the media info of my G4 doorbell I saw Unifi includes an Opus audio track in addition of the aac track which I don't have in my stream.

I'm testing with my Unifi Cloud Key which received the Unifi Protect update 2.7.18 and so far it looks fine.

bigjools commented 1 year ago

Does recording playback work for you or are the time stamps incorrect? I've been working on fixing that but would be surprised if ffmpeg was the only fix. Also, disabling the microphone in the UI on the web browser seems to fix playback on browsers since I suspect the requirement for an additional OPUS audio stream in the video is a hard requirement but hard to fix at the moment since ffmpeg doesn't allow that codec in a FLV container. There are some custom patches to enable support, but will require a custom compiled ffmpeg binary.

I found out the hard way that the extra ffmpeg args are hard-coded in the Reolink camera code. I edited those to remove the audio and I am now getting recording and playback working fine in both the Android app and the web UI.

(I also had to throw in a hack to fix https://github.com/keshavdv/unifi-cam-proxy/issues/280 to use a GET instead of a POST when subscribing to the motion events API.)

However, any recorded clips are off by about 20 minutes now. The timestamp shown in the thumbnails of the videos is correct, but when you play the clip it's from about 20 minutes too early.

MrRobot245 commented 1 year ago

koehler/unifi-cam-proxy:protect-124 seems to work fine or me with a WyzeCam, with my other 3 real Protect cams fine. I couldn't find much on koehler though. Running protect 2.2.11

tfer6 commented 1 year ago

koehler/unifi-cam-proxy:protect-124 seems to work fine or me with a WyzeCam, with my other 3 real Protect cams fine. I couldn't find much on koehler though. Running protect 2.2.11

@MrRobot245 Two questions that hopefully you can answer. Are you using the RTSP stream directly from the Wyze Cam or piping it through something like Wyze Bridge? Did you change any of the FFMPEG args or just leave it as it is in koehler

MrRobot245 commented 1 year ago

RTSP streams direct from the camera. I do have FFMPEG args

--ffmpeg-args '-c:a copy -c:v copy'

enz1ey commented 1 year ago

@MrRobot245

I also use Wyze cameras almost exclusively aside from Unifi. So from what I gather, we can simply install that koehler docker image and use the same setup instructions from this wiki?

MrRobot245 commented 1 year ago

@MrRobot245

I also use Wyze cameras almost exclusively aside from Unifi. So from what I gather, we can simply install that koehler docker image and use the same setup instructions from this wiki?

I have one Wyzecam on RTSP firmware and that image does seem to work! Been using it for the last few days without any issue

bdsoha commented 1 year ago

This issue should be closed by #276

fblgit commented 1 year ago

The build has to be fixed, tagging, and publishing @keshavdv I'll test it, if it works.. i push a fix for the build /cc @keshavdv

[WIP]

stale[bot] commented 1 year 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.

bdsoha commented 1 year ago

@jurajs5 Have a look at the most recent publish image. /cc @fblgit

daltskin commented 1 year ago

Wow! It's working again - just tested with latest Protect 2.7.34

Great work all 😁

For others, just need to point to the dev docker tag.

Sample Docker compose extract working for me below:

 unifi-cam-proxy:
    image: keshavdv/unifi-cam-proxy:dev
    volumes:
      - './client.pem:/client.pem'
    restart: always
    command: unifi-cam-proxy frigate -s rtsp://[removed] --mqtt-host [removed] --frigate-camera [removed] --ffmpeg '-c:v copy -an' --snapshot-url [removed]
    depends_on:
      - frigate

Minor issue is that with frigate detections, the start time on playback seems off. The correct thumbnail displays with the detection in it, but when you review the clip it starts at the wrong time. Possibly issue with time sync?

bdsoha commented 1 year ago

Wow! It's working again - just tested with latest Protect 2.7.34

Great work all 😁

For others, just need to point to the dev docker tag.

Sample Docker compose extract working for me below:

 unifi-cam-proxy:
    image: keshavdv/unifi-cam-proxy:dev
    volumes:
      - './client.pem:/client.pem'
    restart: always
    command: unifi-cam-proxy frigate -s rtsp://[removed] --mqtt-host [removed] --frigate-camera [removed] --ffmpeg '-c:v copy -an' --snapshot-url [removed]
    depends_on:
      - frigate

Minor issue is that with frigate detections, the start time on playback seems off. The correct thumbnail displays with the detection in it, but when you review the clip it starts at the wrong time. Possibly issue with time sync?

Glad to hear. Open a separate issue regarding the time sync.

Mike-de-bike commented 1 year ago

Hello! Because of the above mentioned error I tried to insert that lines in to the docker-compose file.

Unifi Protect 2.2.11 camera: Axis M 2026 LE MK IIcommand: unifi-cam-proxy frigate -s rtsp://[removed] --mqtt-host [removed] --frigate-camera [removed] --ffmpeg '-c:v copy -an' --snapshot-url [removed] depends_on:

version: "3.9"
services:
  unifi-cam-proxy:
    restart: always
    image: keshavdv/unifi-cam-proxy:dev
    volumes:
      - "./client.pem:/client.pem"
    command: unifi-cam-proxy --host 192.168.1.1 --cert /client.pem --token xxxxxxxxxxxxxxxxxxxxxxxxx rtsp -s rtsp://root:xxxxxxxxx@192.168.30.7/axis-media/media.amp

That is the output:

root@pizzabox:/home/stefan/unifi-cam-proxy# docker compose up
[+] Running 1/1
 ✔ Container unifi-cam-proxy-unifi-cam-proxy-1  Recreated                                                                                                                                                                                                                   0.1s 
Attaching to unifi-cam-proxy-unifi-cam-proxy-1
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Spawning stream for snapshots: ffmpeg -nostdin -y -re -rtsp_transport tcp -i "rtsp://root:xxxxxxxxx@192.168.30.7/axis-media/media.amp" -command: unifi-cam-proxy frigate -s rtsp://[removed] --mqtt-host [removed] --frigate-camera [removed] --ffmpeg '-c:v copy -an' --snapshot-url [removed]
    depends_on:
      - frigater 1 -update 1 /tmp/tmp7l0u_7c3/screen.jpg
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 Core[1] INFO Creating ws connection to wss://192.168.1.1:7442/camera/1.0/ws?token=FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Adopting with token [FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj] and mac [AABBCCDDEEFF]
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:55 188406214c96 RTSPCam[1] INFO Processing [StopService] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Processing [ChangeVideoSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
unifi-cam-proxy-unifi-cam-proxy-1  |   built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924
unifi-cam-proxy-unifi-cam-proxy-1  |   configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1
unifi-cam-proxy-unifi-cam-proxy-1  |   libavutil      57. 28.100 / 57. 28.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavcodec     59. 37.100 / 59. 37.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavformat    59. 27.100 / 59. 27.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavdevice    59.  7.100 / 59.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavfilter     8. 44.100 /  8. 44.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libswscale      6.  7.100 /  6.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libswresample   4.  7.100 /  4.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libpostproc    56.  6.100 / 56.  6.100
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Spawning ffmpeg for video2 (xwBgp6By222ZfqwO): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://root:xxxxxxxx@192.168.30.7/axis-media/media.amp" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=xwBgp6By222ZfqwO -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.1.1 7550
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Processing [ChangeVideoSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
unifi-cam-proxy-unifi-cam-proxy-1  |   built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924
unifi-cam-proxy-unifi-cam-proxy-1  |   configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1
unifi-cam-proxy-unifi-cam-proxy-1  |   libavutil      57. 28.100 / 57. 28.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavcodec     59. 37.100 / 59. 37.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavformat    59. 27.100 / 59. 27.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavdevice    59.  7.100 / 59.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavfilter     8. 44.100 /  8. 44.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libswscale      6.  7.100 /  6.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libswresample   4.  7.100 /  4.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libpostproc    56.  6.100 / 56.  6.100
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Spawning ffmpeg for video1 (WbifI6aYCHdGuVl8): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://root:6cdc3e44527abefb978d2ec59976809e@192.168.30.7/axis-media/media.amp" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=WbifI6aYCHdGuVl8 -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.1.1 7550
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Processing [ChangeVideoSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
unifi-cam-proxy-unifi-cam-proxy-1  |   built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924
unifi-cam-proxy-unifi-cam-proxy-1  |   configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1
unifi-cam-proxy-unifi-cam-proxy-1  |   libavutil      57. 28.100 / 57. 28.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavcodec     59. 37.100 / 59. 37.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavformat    59. 27.100 / 59. 27.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavdevice    59.  7.100 / 59.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libavfilter     8. 44.100 /  8. 44.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libswscale      6.  7.100 /  6.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libswresample   4.  7.100 /  4.  7.100
unifi-cam-proxy-unifi-cam-proxy-1  |   libpostproc    56.  6.100 / 56.  6.100
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Spawning ffmpeg for video3 (gJOsz6GII1ejD752): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://root:xxxxxxx@192.168.30.7/axis-media/media.amp" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=gJOsz6GII1ejD752 -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.1.1 7550
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Processing [UpdateFirmwareRequest] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Reconnecting...
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Cleaning up instance
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Stopping stream video2
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Stopping stream video1
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 RTSPCam[1] INFO Stopping stream video3
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:56 188406214c96 Core[1] INFO Backing off connect(...) for 2.0s (True)
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:58 188406214c96 Core[1] INFO Creating ws connection to wss://192.168.1.1:7442/camera/1.0/ws?token=FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:58 188406214c96 RTSPCam[1] INFO Adopting with token [FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj] and mac [AABBCCDDEEFF]
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:58 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:58 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:59 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:59 188406214c96 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:59 188406214c96 RTSPCam[1] INFO Processing [StopService] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:59 188406214c96 RTSPCam[1] INFO Processing [ChangeVideoSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:59 188406214c96 RTSPCam[1] INFO Processing [ChangeDeviceSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:10:59 188406214c96 RTSPCam[1] INFO Processing [NetworkStatus] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:00 188406214c96 RTSPCam[1] INFO Processing [GetSystemStats] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:03 188406214c96 RTSPCam[1] INFO Processing [GetRequest] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:03 188406214c96 RTSPCam[1] INFO Spawning stream for snapshots: ffmpeg -nostdin -y -re -rtsp_transport tcp -i "rtsp://root:xxxxxx@192.168.30.7/axis-media/media.amp" -r 1 -update 1 /tmp/tmp7l0u_7c3/screen.jpg
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:03 188406214c96 RTSPCam[1] WARNING Snapshot file /tmp/tmp7l0u_7c3/screen.jpg is not ready yet, skipping upload
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:04 188406214c96 RTSPCam[1] INFO Processing [NetworkStatus] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:04 188406214c96 RTSPCam[1] INFO Processing [GetSystemStats] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:05 188406214c96 RTSPCam[1] INFO Processing [ChangeIspSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:05 188406214c96 RTSPCam[1] INFO Processing [ChangeOsdSettings] message
unifi-cam-proxy-unifi-cam-proxy-1  | 2023-04-26 19:11:05 188406214c96 RTSPCam[1] INFO Processing [ChangeAudioEventsSettings] message

The camera is marked online. One Screenshot is uploaded. No video is streamed.

The command of @bdsoha cannot be executed, because of not knowing the argument frigate and the mqtt and frigate parameters: command: unifi-cam-proxy frigate -s rtsp://[removed] --mqtt-host [removed] --frigate-camera [removed] --ffmpeg '-c:v copy -an' --snapshot-url [removed] depends_on:

bdsoha commented 1 year ago

@Mike-de-bike I didn't provide any commands, you are probably referring to the quoted text from my reply.

Mike-de-bike commented 1 year ago

@Mike-de-bike I didn't provide any commands, you are probably referring to the quoted text from my reply.

Okay, thx. Do you recognize an error in the output, i have inserted? What could be the reason, that it doesn't work?

bdsoha commented 1 year ago

@Mike-de-bike I didn't provide any commands, you are probably referring to the quoted text from my reply.

Okay, thx. Do you recognize an error in the output, i have inserted? What could be the reason, that it doesn't work?

Are you running the most recent published image? Try running docker pull keshavdv/unifi-cam-proxy:dev.

Mike-de-bike commented 1 year ago

@Mike-de-bike I didn't provide any commands, you are probably referring to the quoted text from my reply.

Okay, thx. Do you recognize an error in the output, i have inserted? What could be the reason, that it doesn't work?

Are you running the most recent published image? Try running docker pull keshavdv/unifi-cam-proxy:dev.

I used the way of 'docker compose up' with a docker file (with the same docker:dev rep).

bdsoha commented 1 year ago

Since dev is considered tagged, then docker will not always pull the most recent image. Stop your compose execution and run docker pull keshavdv/unifi-cam-proxy:dev. Then rerun your compose execution.

Mike-de-bike commented 1 year ago

Since dev is considered tagged, then docker will not always pull the most recent image. Stop your compose execution and run docker pull keshavdv/unifi-cam-proxy:dev. Then rerun your compose execution.

Thank you, I will test it in a while! :-)

flarestarwingz commented 1 year ago

Hey, I was looking to pull the latest image and replace the Latest with Dev to see if it sorts this issue. I'm running the docker image directly on a Unifi Dream Machine, but I get this error if I try to pull (since I can't access docker/podman compose):

podman pull docker://docker.io/keshavdv/unifi-cam-proxy:dev Trying to pull docker://docker.io/keshavdv/unifi-cam-proxy:dev... manifest unknown: OCI index found, but accept header does not support OCI indexes

daltskin commented 1 year ago

keshavdv/unifi-cam-proxy:dev

This looks similar issue to this: https://github.com/pi-hole/docker-pi-hole/issues/1289#issuecomment-1399261168

@keshavdv / @bdsoha may need to tag a new version?

Mike-de-bike commented 1 year ago

Since dev is considered tagged, then docker will not always pull the most recent image. Stop your compose execution and run docker pull keshavdv/unifi-cam-proxy:dev. Then rerun your compose execution.

After stopping the container and removing local images I ran "docker pull ..." and started it via compose up. docker-compose.yaml `version: "3.9" services: unifi-cam-proxy: restart: unless-stopped image: keshavdv/unifi-cam-proxy:dev volumes:

That is the output of the container log. Unfortunately the video stream is not running:

2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Spawning stream for snapshots: ffmpeg -nostdin -y -re -rtsp_transport tcp -i "rtsp://root:xxxxxxxxxxxxxx@192.168.30.7/axis-media/media.amp" -r 1 -update 1 /tmp/tmpm7djb4am/screen.jpg 2023-04-27 18:09:34 e6f0467a40f2 Core[1] INFO Creating ws connection to wss://192.168.1.1:7442/camera/1.0/ws?token=FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj 2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Adopting with token [FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj] and mac [AABBCCDDEEFF] 2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message 2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message 2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message 2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message 2023-04-27 18:09:34 e6f0467a40f2 RTSPCam[1] INFO Processing [StopService] message 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924 configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1 libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Spawning ffmpeg for video2 (xwBgp6By222ZfqwO): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://root:xxxxxxxxxxxxxx@192.168.30.7/axis-media/media.amp" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=xwBgp6By222ZfqwO -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.1.1 7550 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924 configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1 libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Spawning ffmpeg for video1 (WbifI6aYCHdGuVl8): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://root:xxxxxxxxxxxxxx@192.168.30.7/axis-media/media.amp" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=WbifI6aYCHdGuVl8 -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.1.1 7550 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924 configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1 libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Spawning ffmpeg for video3 (gJOsz6GII1ejD752): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://root:xxxxxxxxxxxxxx@192.168.30.7/axis-media/media.amp" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=gJOsz6GII1ejD752 -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.1.1 7550 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Processing [UpdateFirmwareRequest] message 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Reconnecting... 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Cleaning up instance 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Stopping stream video2 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Stopping stream video1 2023-04-27 18:09:35 e6f0467a40f2 RTSPCam[1] INFO Stopping stream video3 2023-04-27 18:09:35 e6f0467a40f2 Core[1] INFO Backing off connect(...) for 2.0s (True) 2023-04-27 18:09:37 e6f0467a40f2 Core[1] INFO Creating ws connection to wss://192.168.1.1:7442/camera/1.0/ws?token=FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj 2023-04-27 18:09:37 e6f0467a40f2 RTSPCam[1] INFO Adopting with token [FnCpOm5kdlZcJyfZN3wROv4XxZHjeFFj] and mac [AABBCCDDEEFF] 2023-04-27 18:09:37 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message 2023-04-27 18:09:37 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_hello] message 2023-04-27 18:09:38 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message 2023-04-27 18:09:38 e6f0467a40f2 RTSPCam[1] INFO Processing [ubnt_avclient_paramAgreement] message 2023-04-27 18:09:38 e6f0467a40f2 RTSPCam[1] INFO Processing [StopService] message 2023-04-27 18:09:38 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message 2023-04-27 18:09:38 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeDeviceSettings] message 2023-04-27 18:09:38 e6f0467a40f2 RTSPCam[1] INFO Processing [NetworkStatus] message 2023-04-27 18:09:39 e6f0467a40f2 RTSPCam[1] INFO Processing [GetSystemStats] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeIspSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeOsdSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeAudioEventsSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeSoundLedSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeSmartMotionSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [EnableLogging] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeDeviceSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeDeviceSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [SmartMotionTest] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [UpdateUsernamePassword] message 2023-04-27 18:09:44 e6f0467a40f2 RTSPCam[1] INFO Processing [ChangeVideoSettings] message 2023-04-27 18:09:47 e6f0467a40f2 RTSPCam[1] INFO Processing [NetworkStatus] message 2023-04-27 18:09:47 e6f0467a40f2 RTSPCam[1] INFO Processing [GetSystemStats] message 2023-04-27 18:09:52 e6f0467a40f2 RTSPCam[1] INFO Processing [GetRequest] message 2023-04-27 18:09:52 e6f0467a40f2 RTSPCam[1] INFO Spawning stream for snapshots: ffmpeg -nostdin -y -re -rtsp_transport tcp -i "rtsp://root:xxxxxxxxxxxxxx@192.168.30.7/axis-media/media.amp" -r 1 -update 1 /tmp/tmpm7djb4am/screen.jpg 2023-04-27 18:09:52 e6f0467a40f2 RTSPCam[1] WARNING Snapshot file /tmp/tmpm7djb4am/screen.jpg is not ready yet, skipping upload

ptorsten commented 1 year ago

Can someone run a ffprobe on a working stream - can't still get my Lorex cameras working in web nor really in iOS

Mike-de-bike commented 1 year ago

Since dev is considered tagged, then docker will not always pull the most recent image. Stop your compose execution and run docker pull keshavdv/unifi-cam-proxy:dev. Then rerun your compose execution.

Is there an option do set debugging parameters in the execution of unifi-cam-proxy?

bdsoha commented 1 year ago

keshavdv/unifi-cam-proxy:dev

This looks similar issue to this: pi-hole/docker-pi-hole#1289 (comment)

@keshavdv / @bdsoha may need to tag a new version?

Unfortunately, I don't have repository permission to create a release tag. /cc @keshavdv

vr6syncro commented 1 year ago

any updates so far to get it running?

flarestarwingz commented 1 year ago

There's work in the Dev branch and it sounds good there. I'm having issues pulling the image as are a few others, but once that's sorted it would be worth giving it a try.

vr6syncro commented 1 year ago

i am on dev but have lot of issues. have 2 cams connected and showed as online. one cam get a image and the other is only black screen. Video playback is never available.

Edit also my protect is crashing. i am on 2.2.11

altodd commented 1 year ago

To put in my two cents - I have built manually from main (looks most recently updated) and pulling the dev tag from docker hub I get the same result of camera always showing up as updating. I am using amcrest camera and have updated my UDM Pro to 2.5.17 and protect is v 2.2.11. Let me know if I can help with testing of amcrest if other cameras are working already.

JacobErnst98 commented 1 year ago

Just tested using the docker compose configuration with :dev on Protect version 2.7.34 stream buffers forever and the image is just black.

Mike-de-bike commented 1 year ago

Please give me a working version number of unifi protect, that cooperates with the actual unifi-cam-proxy. I am downgrading towards 2.11 with no working result.

bdsoha commented 1 year ago

Working for me on protect:2.6.17.

Mike-de-bike commented 1 year ago

Working for me on protect:2.6.17

What device do you use? My dm pro only updates to 2.2.11.

tfer6 commented 1 year ago

I just updated to 2.7.34 and can confirm the :dev image is working for me.

In fact, performance actually improved. Previously I could only view live streams via the Android App. Accessing via the web and the stream would never load. I could view recordings on both.

Here is the compose I'm using. I stole it from above or reddit, I don't remember.

services:
  unifi-cam-proxy-garage:
    image:  keshavdv/unifi-cam-proxy:dev
    volumes:
      - /volume1/docker/appdata/unifiproxy/client.pem:/client.pem:ro  
    restart: unless-stopped
    command: unifi-cam-proxy --host "192.168.1.1" --cert /client.pem --mac "${UNIQUE_MAC_1}" --token "${TOKEN_1}" frigate -s "${RTSP_URL_1}" --snapshot-url "http://192.168.1.202:5000/api/${FRIGATE_CAMERA_NAME_1}/latest.jpg" --mqtt-host "192.168.1.200" --frigate-camera "${FRIGATE_CAMERA_NAME_1}" --ffmpeg-args "-c:a copy -c:v copy"
  unifi-cam-proxy-den:
    image:  keshavdv/unifi-cam-proxy:dev
    volumes:
      - /volume1/docker/appdata/unifiproxy/client.pem:/client.pem:ro  
    restart: unless-stopped
    command: unifi-cam-proxy --host "192.168.1.1" --cert /client.pem --mac "${UNIQUE_MAC_2}" --token "${TOKEN_2}" frigate -s "${RTSP_URL_2}" --snapshot-url "http://192.168.1.202:5000/api/${FRIGATE_CAMERA_NAME_2}/latest.jpg" --mqtt-host "192.168.1.200" --frigate-camera "${FRIGATE_CAMERA_NAME_2}" --ffmpeg-args "-c:a copy -c:v copy"
bdsoha commented 1 year ago

Working for me on protect:2.6.17

What device do you use? My dm pro only updates to 2.2.11.

The UXG Pro running v3.0.7.

ptorsten commented 1 year ago

What camera are you using? I'm starting to believe it's all about the stream coming from the camera, played with transcoding and I can kinda get it to play (I have Lorex cameras)

On Mon, May 1, 2023 at 6:00 PM tfer6 @.***> wrote:

I just updated to 2.7.34 and can confirm the :dev image is working for me.

In fact, performance actually improved. Previously I could only view live streams via the Android App. Accessing via the web and the stream would never load. I could view recordings on both.

Here is the compose I'm using. I stole it from above or reddit, I don't remember.

services: unifi-cam-proxy-garage: image: keshavdv/unifi-cam-proxy:dev volumes: - /volume1/docker/appdata/unifiproxy/client.pem:/client.pem:ro restart: unless-stopped command: unifi-cam-proxy --host "192.168.1.1" --cert /client.pem --mac "${UNIQUE_MAC_1}" --token "${TOKEN_1}" frigate -s "${RTSP_URL_1}" --snapshot-url " http://192.168.1.202:5000/api/${FRIGATE_CAMERA_NAME_1}/latest.jpg" --mqtt-host "192.168.1.200" --frigate-camera "${FRIGATE_CAMERA_NAME_1}" --ffmpeg-args "-c:a copy -c:v copy" unifi-cam-proxy-den: image: keshavdv/unifi-cam-proxy:dev volumes: - /volume1/docker/appdata/unifiproxy/client.pem:/client.pem:ro restart: unless-stopped command: unifi-cam-proxy --host "192.168.1.1" --cert /client.pem --mac "${UNIQUE_MAC_2}" --token "${TOKEN_2}" frigate -s "${RTSP_URL_2}" --snapshot-url " http://192.168.1.202:5000/api/${FRIGATE_CAMERA_NAME_2}/latest.jpg" --mqtt-host "192.168.1.200" --frigate-camera "${FRIGATE_CAMERA_NAME_2}" --ffmpeg-args "-c:a copy -c:v copy"

— Reply to this email directly, view it on GitHub https://github.com/keshavdv/unifi-cam-proxy/issues/199#issuecomment-1530729152, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTLTRLZHHK4DGAKNWOW5DXEBMBTANCNFSM5QFNMCAA . You are receiving this because you commented.Message ID: @.***>

tfer6 commented 1 year ago

I'm using two Wyze cams being piped through Docker-Wyze-Bridge. https://github.com/mrlt8/docker-wyze-bridge

phillijw commented 1 year ago

I'll share what little I found (which I already shared in the discord chat):

The error I'm getting is this:

2023-05-02 17:48:00 f61e61ae87c2 RTSPCam[1] INFO Spawning ffmpeg for video3 (CKgSr1lP1JIxW8eA): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://admin:xxxxxxxx@192.168.4.23:554/cam/realmonitor?channel=1&subtype=0" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=CKgSr1lP1JIxW8eA -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.2.1 7550
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/unifi/clock_sync.py", line 179, in <module>
    main(parse_args())
  File "/app/unifi/clock_sync.py", line 156, in main
    write(read_bytes(source, payload_size))
  File "/app/unifi/clock_sync.py", line 28, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
Error closing file pipe:: Broken pipe
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/unifi/clock_sync.py", line 179, in <module>
    main(parse_args())
  File "/app/unifi/clock_sync.py", line 156, in main
    write(read_bytes(source, payload_size))
  File "/app/unifi/clock_sync.py", line 28, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

It is in the time sync module. I was able to attach to the docker container, modify the file and added a little bit of try/catch debugging output like so:

else:
  try:
    # Write the original packet
    write(header)
    write(read_bytes(source, payload_size))
  except:
    print(f'Shit hit the fan!\n\theader: {header}\n\tsource: {source}\n\tpayload_size: {payload_size}', file=sys.stderr)

You can see the log output afterward here:

/app/unifi # ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://admin:xxxxxxxx@192.168.4.23:554/cam/realmonitor?channel=1&subtype
=0" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=O7Ma3vgWRhQP8BCC -f flv - | /usr/local/bin/python clock_sync.py --write-timestamps | nc -vvv 192.168.2.1 7550
Connection to 192.168.2.1 7550 port [tcp/*] succeeded!
Calling main method
Shit hit the fan!
    header: b"\t\x00\xba\x9a\x00\x00\xd7\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 47770
Shit hit the fan!
    header: b"\t\x00U\x08\x00\x00\xf2\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 21768
Shit hit the fan!
    header: b"\t\x00P\x17\x00\x00\xff\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 20503
Shit hit the fan!
    header: b"\t\x00S\xd0\x00\x01\x07\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 21456
Shit hit the fan!
    header: b"\t\x00G=\x00\x01\x0e\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 18237
Shit hit the fan!
    header: b"\t\x00;\x8d\x00\x01:\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 15245
Shit hit the fan!
    header: b"\t\x005\x8d\x00\x01\x7f\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 13709
Shit hit the fan!
    header: b"\t\x00%\xb7\x00\x01\xb2\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 9655
Shit hit the fan!
    header: b'\t\x00"J\x00\x01\xcf\x00\x00\x00\x00\''
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 8778
Shit hit the fan!
    header: b"\t\x00W>\x00\x01\xfd\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 22334
Shit hit the fan!
    header: b"\t\x00S\x82\x00\x02R\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 21378
Shit hit the fan!
    header: b"\t\x00A\xbe\x00\x02l\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 16830
Shit hit the fan!
    header: b"\t\x005/\x00\x02\x98\x00\x00\x00\x00'"
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 13615
Shit hit the fan!
    header: b'\x08\x00\x00}\x00\x02\xbc\x00\x00\x00\x00\xaf'
    source: <_io.BufferedReader name='<stdin>'>
    payload_size: 125
Traceback (most recent call last):
  File "/app/unifi/clock_sync.py", line 183, in <module>
    main(parse_args())
  File "/app/unifi/clock_sync.py", line 165, in main
    write_timestamp_trailer(packet_type == 9, now - start)
  File "/app/unifi/clock_sync.py", line 41, in write_timestamp_trailer
    write(bytes([0, 43, 17, 0, 0, 0, 0, 0, 0, 0, 0]))
  File "/app/unifi/clock_sync.py", line 28, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
Error closing file pipe:: Broken pipe
/app/unifi #

If I do not include the netcat command at the end, I don't get any errors. This indicates the protect server is breaking the connection for some reason. We need to figure out why.

bdsoha commented 1 year ago

I'll share what little I found (which I already shared in the discord chat):

The error I'm getting is this:

2023-05-02 17:48:00 f61e61ae87c2 RTSPCam[1] INFO Spawning ffmpeg for video3 (CKgSr1lP1JIxW8eA): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://admin:xxxxxxxx@192.168.4.23:554/cam/realmonitor?channel=1&subtype=0" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=CKgSr1lP1JIxW8eA -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 192.168.2.1 7550
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/unifi/clock_sync.py", line 179, in <module>
    main(parse_args())
  File "/app/unifi/clock_sync.py", line 156, in main
    write(read_bytes(source, payload_size))
  File "/app/unifi/clock_sync.py", line 28, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
Error closing file pipe:: Broken pipe
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/unifi/clock_sync.py", line 179, in <module>
    main(parse_args())
  File "/app/unifi/clock_sync.py", line 156, in main
    write(read_bytes(source, payload_size))
  File "/app/unifi/clock_sync.py", line 28, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

It is in the time sync module. I was able to attach to the docker container, modify the file and added a little bit of try/catch debugging output like so:

else:
  try:
    # Write the original packet
    write(header)
    write(read_bytes(source, payload_size))
  except:
    print(f'Shit hit the fan!\n\theader: {header}\n\tsource: {source}\n\tpayload_size: {payload_size}', file=sys.stderr)

You can see the log output afterward here:

/app/unifi # ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://admin:xxxxxxxx@192.168.4.23:554/cam/realmonitor?channel=1&subtype
=0" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamName=O7Ma3vgWRhQP8BCC -f flv - | /usr/local/bin/python clock_sync.py --write-timestamps | nc -vvv 192.168.2.1 7550
Connection to 192.168.2.1 7550 port [tcp/*] succeeded!
Calling main method
Shit hit the fan!
  header: b"\t\x00\xba\x9a\x00\x00\xd7\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 47770
Shit hit the fan!
  header: b"\t\x00U\x08\x00\x00\xf2\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 21768
Shit hit the fan!
  header: b"\t\x00P\x17\x00\x00\xff\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 20503
Shit hit the fan!
  header: b"\t\x00S\xd0\x00\x01\x07\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 21456
Shit hit the fan!
  header: b"\t\x00G=\x00\x01\x0e\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 18237
Shit hit the fan!
  header: b"\t\x00;\x8d\x00\x01:\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 15245
Shit hit the fan!
  header: b"\t\x005\x8d\x00\x01\x7f\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 13709
Shit hit the fan!
  header: b"\t\x00%\xb7\x00\x01\xb2\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 9655
Shit hit the fan!
  header: b'\t\x00"J\x00\x01\xcf\x00\x00\x00\x00\''
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 8778
Shit hit the fan!
  header: b"\t\x00W>\x00\x01\xfd\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 22334
Shit hit the fan!
  header: b"\t\x00S\x82\x00\x02R\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 21378
Shit hit the fan!
  header: b"\t\x00A\xbe\x00\x02l\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 16830
Shit hit the fan!
  header: b"\t\x005/\x00\x02\x98\x00\x00\x00\x00'"
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 13615
Shit hit the fan!
  header: b'\x08\x00\x00}\x00\x02\xbc\x00\x00\x00\x00\xaf'
  source: <_io.BufferedReader name='<stdin>'>
  payload_size: 125
Traceback (most recent call last):
  File "/app/unifi/clock_sync.py", line 183, in <module>
    main(parse_args())
  File "/app/unifi/clock_sync.py", line 165, in main
    write_timestamp_trailer(packet_type == 9, now - start)
  File "/app/unifi/clock_sync.py", line 41, in write_timestamp_trailer
    write(bytes([0, 43, 17, 0, 0, 0, 0, 0, 0, 0, 0]))
  File "/app/unifi/clock_sync.py", line 28, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
Error closing file pipe:: Broken pipe
/app/unifi #

If I do not include the netcat command at the end, I don't get any errors. This indicates the protect server is breaking the connection for some reason. We need to figure out why.

Are you running the most recent dev tag?

phillijw commented 1 year ago

Yes, I believe so...

This is the version I ran that against:

REPOSITORY                            TAG       IMAGE ID       CREATED         SIZE
keshavdv/unifi-cam-proxy              dev       167afb8980fe   2 weeks ago     234MB
$ docker image pull keshavdv/unifi-cam-proxy:dev
dev: Pulling from keshavdv/unifi-cam-proxy
Digest: sha256:af20f59d596b798cc9b53a9049f7d4aacd1d4bffc9bb2ff8b9a81f6b1e230b2d
Status: Image is up to date for keshavdv/unifi-cam-proxy:dev
docker.io/keshavdv/unifi-cam-proxy:dev