Unifi Camera Proxy – Stream not loading

By

in

,

Posted

Tags:

Updated

Running the IMX415 camera from this post about H264 streaming, I was trying to get it to work with Unifi Protect through the unifi-camera-proxy. At first I had issues finding the H265 setting, so I was trying to encode the stream to 264 on the fly and was using these flags to convert 265/HEVC to 264 using FFMPEG args.

This is the solution:

--ffmpeg-args "-map 0 -c copy -c:v libx264 -preset ultrafast -crf 30 -x264opts keyint=60:vbv-maxrate=4000:vbv-bufsize=8000"

It turned out okay, but used a lot of CPU, and I originally had --preset ultrafast as a more intensive setting (maybe medium) but this resulted in rubber banding or jumpy behavior where every seconds’ motion plays almost in reverse order.

But then I found the H264 option, and thought I could switch to no change in the FFMPEG args, this resulted in a few weird messages including:

  • operation not permitted
  • Audio bitrate incompatible with FLV
  • and Protect does not load the stream anymore even with the H264 option on the actual camera selected.

Re-using the FFMPEG args from above, the audio bitrate error goes away, but operation not permitted stays.

To get rid of the operation not permitted error, it seems my camera only allows only 1 (or maybe a few) active RTSP streams, and errors when attempting to access from more than one area. This occurs in unifi-cam-protect because there apepars to be multiple processes that can attach to the rtsp stream at the same time, one for the preview picture, and another for the stream, and maybe additional. This issue can be avoided completely by removing the limitation on the camera, which means adding a rtsp-simple-server to proxy the stream, first add to the docker-compose.yml file:

  rtsp-simple-server:

    restart: unless-stopped

    stdin_open: true

    tty: true

    environment:

      – RTSP_PROTOCOLS=tcp

    ports:

      – 8554:8554

      – 1935:1935

      – 8888:8888

    volumes:

      – “./rtsp-simple-server.yml:/rtsp-simple-server.yml”

    image: aler9/rtsp-simple-server

Then configure In rtsp-simple-server.yml the RTSP server to clone the stream to the following to allow the server to be accessed at rtsp://<ip>:8554/test:

paths:
test:
source: rtsp://<user:pass>@<ip>/<stream>

You’ll then update the unifi-cam-proxy to use the rtsp-simple-server‘s proxy of the server. This solves the operation not permitted error.

Adding in the HEVC/H265 re-encoding arguments then allows Protect to again show the stream and play it.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *