blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
18.94k stars 1.73k forks source link

RTMP streams suddenly low res? #1805

Closed eblohm closed 3 years ago

eblohm commented 3 years ago

Using 0.9.0RC4, but the issue started on 0.9.0RC3. I haven't touched my config file, and I don't think anything was added as a breaking change that would cause this so I'm not sure what I'm not understanding properly.

Here's the config for one of my cameras:

  garage:
    ffmpeg:
      inputs:
        - path: rtsp://USERNAME:PASSWORD@192.168.1.217:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
        - path: rtsp://USERNAME:PASSWORD@192.168.1.217:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - rtmp
            - record
    detect:
      width: 704
      height: 480
      fps: 5
    motion:
      mask:
        - 1914,156,2517,160,2513,69,1916,69
    rtmp:
      enabled: true
    record:
      enabled: true
      retain_days: 25
      events:
        pre_capture: 5
        post_capture: 5
        retain:
          default: 25
    snapshots:
      enabled: true
      timestamp: true
      bounding_box: true
      crop: False
      retain:
        default: 25

Pre- 0.9.0RC3 my RTMP streams would be full resolution of my camera (2592x1944) but now it's significantly lower. I'm assuming it's using the sub-stream that's being used by detect, but I'm not sure why. This specific camera is an Amcrest IP5M-T1179EW-28MM, but I'm running into it with all of my cameras (all Amcrest).

blakeblackshear commented 3 years ago

How are you viewing the rtmp feed?

Also, can you post the JSON config from the debug tab in the UI?

eblohm commented 3 years ago

Home Assistant UI, using the Frigate integration from HACS version 2.0.0

JSON Config:

"garage": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": true,
        "fps": 5,
        "height": 480,
        "max_disappeared": 25,
        "width": 704
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [],
        "input_args": [
          "-avoid_negative_ts",
          "make_zero",
          "-fflags",
          "+genpts+discardcorrupt",
          "-rtsp_transport",
          "tcp",
          "-stimeout",
          "5000000",
          "-use_wallclock_as_timestamps",
          "1"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "rtsp://USERNAME:PASSWORD@192.168.1.217:554/cam/realmonitor?channel=1&subtype=1",
            "roles": [
              "detect"
            ]
          },
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "rtsp://USERNAME:PASSWORD@192.168.1.217:554/cam/realmonitor?channel=1&subtype=0",
            "roles": [
              "rtmp",
              "record"
            ]
          }
        ],
        "output_args": {
          "detect": [
            "-f",
            "rawvideo",
            "-pix_fmt",
            "yuv420p"
          ],
          "record": [
            "-f",
            "segment",
            "-segment_time",
            "10",
            "-segment_format",
            "mp4",
            "-reset_timestamps",
            "1",
            "-strftime",
            "1",
            "-c",
            "copy",
            "-an"
          ],
          "rtmp": [
            "-c",
            "copy",
            "-f",
            "flv"
          ]
        }
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://USERNAME:PASSWORD@192.168.1.217:554/cam/realmonitor?channel=1&subtype=1 -r 5 -s 704x480 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect"
          ]
        },
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://USERNAME:PASSWORD@192.168.1.217:554/cam/realmonitor?channel=1&subtype=0 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/garage-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/garage",
          "roles": [
            "rtmp",
            "record"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 8
      },
      "motion": {
        "contour_area": 82,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 180,
        "mask": [
          "1914,156,2517,160,2513,69,1916,69"
        ],
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "quality": 70,
        "required_zones": [],
        "timestamp": true
      },
      "name": "garage",
      "objects": {
        "filters": {
          "person": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": "",
        "track": [
          "person"
        ]
      },
      "record": {
        "enabled": true,
        "events": {
          "max_seconds": 300,
          "objects": null,
          "post_capture": 5,
          "pre_capture": 5,
          "required_zones": [],
          "retain": {
            "default": 25,
            "objects": {}
          }
        },
        "retain_days": 25
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": true,
        "clean_copy": true,
        "crop": false,
        "enabled": true,
        "height": null,
        "quality": 70,
        "required_zones": [],
        "retain": {
          "default": 25,
          "objects": {}
        },
        "timestamp": true
      },
      "timestamp_style": {
        "color": {
          "blue": 255,
          "green": 255,
          "red": 255
        },
        "effect": null,
        "format": "%m/%d/%Y %H:%M:%S",
        "position": "tl",
        "thickness": 2
      },
      "zones": {}
    },
blakeblackshear commented 3 years ago

Are you certain you still have the stream component enabled in home assistant? It falls back to an mjpeg stream based on the detect role if you don't.

eblohm commented 3 years ago

By that do you mean the stream: entry in Home Assistant's configuration.yaml? I have that, I've also restarted HA, uninstalled and reinstalled the integration, and the HACS custom component, but nothing gets the RTMP stream working normally

blakeblackshear commented 3 years ago

Can you try using VLC to connect to rtmp://<ip_of_frigate>/live/garage?

eblohm commented 3 years ago

That way does give me the high resolution stream

blakeblackshear commented 3 years ago

That means home assistant is pulling the mjpeg stream instead for some reason. Typically that's because stream isn't enabled in home assistant.

eblohm commented 3 years ago

Hm, could it be anything else? I have default_config: set in my configuration.yaml for Home Assistant, which automatically enables stream. I do think you're right though, because the more I think about it, I realized when I would view the camera I'd have the option to Preload Stream, and none of the cameras have that option anymore..

Gonna close this because it's obviously not related to Frigate, it's something with Home Assistant/my HA setup