Rotate camera rtsp stream using Frigate

Dear community,

I use avigilon cameras in the HA frigate integration. Unfortunately avigilon doesn’t support rotation of the rtsp stream. And I couldn’t find out how to rotate the image for the H5 dome cam in frigate using yaml code.

Does anyone know how to do that?


cameras:
  camera1:
    ffmpeg:
      inputs:
        - path: rtsp://USERNAME:[email protected]/defaultPrimary?streamType=u
          roles:
            - detect

    detect:
      enabled: True # <---- disable detection until you have a working camera feed
      width: 1280 # <---- update for your camera's resolution
      height: 720 # <---- update for your camera's resolution

    objects:
      track:
        - car
        - person

bests, Christian

it is recommended to use go2rtc config for the rotation and then access the stream in frigate

Hi!

that really doesnt work at all. There must be something I dont see…

go2rtc:
  streams:
    rtsp_wintergarten: 
      - rtsp://USER:[email protected]/defaultPrimary?streamType=u
      - "ffmpeg:Cam_Wintergarten#video=h264#rotate=180"

cameras:
  Cam_Wintergarten:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/rtsp_wintergarten
          input_args: preset-rtsp-restream
          roles:
            - detect

    detect:
      enabled: True 
      width: 1280 
      height: 720 

    objects:
      track:
        - car
        - person
        
    record:
      enabled: False
    snapshots:
      enabled: True

any mistakes in my code?

The stream is working! But the rotation still doesnt work.

bests, Christian

Number of mistakes:

  1. The ffmpeg stream is not referencing a stream that exists
  2. You need a separate stream named something else to reference directly

ok - you mean like that?

go2rtc:
  streams:
    rtsp_wintergarten: 
      - rtsp://USER:[email protected]/defaultPrimary?streamType=u
	  
    rtsp_wintergarten_rotated:
      - "ffmpeg:rtsp_wintergarten#video=h264#rotate=180"

cameras:
  Cam_Wintergarten_rotated:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/rtsp_wintergarten_rotated
          input_args: preset-rtsp-restream
          roles:
            - detect

    detect:
      enabled: True 
      width: 1280 
      height: 720 

  Cam_Wintergarten:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/rtsp_wintergarten
          input_args: preset-rtsp-restream
          roles:
            - detect

    detect:
      enabled: True 
      width: 1280 
      height: 720 

    objects:
      track:
        - car
        - person
        
    record:
      enabled: False
    snapshots:
      enabled: True

If not - please could you correct the syntax for me? :slight_smile:
I’ve tried so many things that I dont know anymore what I’ve changed each try

bests, Christian

You need to make the names match between go2rtc and cameras config

well - I will rotate the lens on my cam. MUCH more easier and it will work for sure :slight_smile:

1 Like

For anyone else happening by: I can confirm the above works. Helped me out to achieve the same thing to cover an alley way. You shouldn’t have given up!

Thanks to all.

1 Like

@Dilligaf I am somewhat confused still

This is what I have:

go2rtc:
  streams:
    entrada:
      - rtsp://user:[email protected]/live
      - "ffmpeg:entrada#audio=opus"
    
    Entrada_Rotated:
      - "ffmpeg:entrada#video=h264#rotate=90"

  webrtc:
    candidates:
      - 10.69.69.72:8555
      - stun:8555

Then for the camera settings I have:

cameras:
  entrada:
    ffmpeg:
      inputs:
        - path: rtsp://user:[email protected]/live
          roles:
            - detect

    live:
      stream_name: Entrada_Rotated 
  
    detect:
      width: 1080 # <---- update for your camera's resolution
      height: 1920 # <---- update for your camera's resolution
      fps: 7

    objects:
      track:
        - person
        - dog
        - cat

In frigate, when I view all cams, the entrada cam shows horizontal. When I click on it to view it live via frigate I do see it vertical. But pretty much that is the only place I see it vertical. Recordings are horizontal, and in HA cam view I also see it horizontal.

The example you give :

Cam_Wintergarten_rotated:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/rtsp_wintergarten_rotated
          input_args: preset-rtsp-restream
          roles:
            - detect

Does that mean I should create a new camera like this:

Entrada_Rotated:
    ffmpeg:
      inputs:
        - path: rtsp://user:[email protected]/Entrada_Rotated
          roles:
            - detect

The 10.69.69.12 is the cameras IP, and it doesn’t have a rotated stream, so why would the Entrada_Rotated feed be tied to the cameras IP?

So I was on the right track, it wouldn’t make sense to get the rotated feed from the cameras IP, but turns out the 127.0.0.1 IS NOT A CAMERA IP. Assuming it is the local host IP, and I am picking up the rotated stream I created under go2rtc config.

This is the code I ended up with:

  Entrada_Rotated:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/Entrada_Rotated
          roles:
            - detect

And if it was a magic trick, I finally have vertical camera!

Seems a thread on the frigate github might be confusing many people, as it makes it seem you change the live view of the existing camera.