blakeblackshear / frigate

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

[Support]: rtmp playing wrong rtsp stream when multiple input paths are defined #2001

Closed lcasale closed 2 years ago

lcasale commented 3 years ago

Describe the problem you are having

If I have a single input path defined with my main rtsp stream, rtmp plays the main stream.

If I have two input paths defined with my sub stream's role as "detect" and my main stream's roles' as "record" and "rtmp", rtmp plays the sub stream.

Version

0.9.1-800F33E

Frigate config file

{
    "birdseye": {
      "enabled": true,
      "height": 720,
      "mode": "objects",
      "quality": 8,
      "width": 1280
    },
    "cameras": {
      "amcrest": {
        "best_image_timeout": 60,
        "detect": {
          "enabled": true,
          "fps": 20,
          "height": 360,
          "max_disappeared": 100,
          "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://xxxx:xxxx@amcrest:554/cam/realmonitor?channel=1&subtype=1",
              "roles": [
                "detect"
              ]
            },
            {
              "global_args": [],
              "hwaccel_args": [],
              "input_args": [],
              "path": "rtsp://xxxx:xxxx@amcrest:554/cam/realmonitor?channel=1&subtype=0",
              "roles": [
                "record",
                "rtmp"
              ]
            }
          ],
          "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://xxxx:xxxx@amcrest:554/cam/realmonitor?channel=1&subtype=1 -r 20 -s 704x360 -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://xxxx:xxxx@amcrest: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/amcrest-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/amcrest",
            "roles": [
              "record",
              "rtmp"
            ]
          }
        ],
        "live": {
          "height": 720,
          "quality": 8
        },
        "motion": {
          "contour_area": 109,
          "delta_alpha": 0.2,
          "frame_alpha": 0.2,
          "frame_height": 180,
          "mask": "",
          "threshold": 25
        },
        "mqtt": {
          "bounding_box": true,
          "crop": true,
          "enabled": true,
          "height": 270,
          "quality": 70,
          "required_zones": [],
          "timestamp": true
        },
        "name": "amcrest",
        "objects": {
          "filters": {
            "bear": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            },
            "bicycle": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            },
            "bird": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            },
            "car": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.4,
              "threshold": 0.5
            },
            "cat": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            },
            "dog": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            },
            "motorcycle": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            },
            "person": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 0,
              "min_score": 0.5,
              "threshold": 0.7
            }
          },
          "mask": "",
          "track": [
            "person",
            "car",
            "motorcycle",
            "bicycle",
            "bird",
            "cat",
            "dog",
            "bear"
          ]
        },
        "record": {
          "enabled": true,
          "events": {
            "max_seconds": 300,
            "objects": null,
            "post_capture": 5,
            "pre_capture": 5,
            "required_zones": [],
            "retain": {
              "default": 10,
              "objects": {}
            }
          },
          "retain_days": 1
        },
        "rtmp": {
          "enabled": true
        },
        "snapshots": {
          "bounding_box": true,
          "clean_copy": true,
          "crop": false,
          "enabled": false,
          "height": null,
          "quality": 70,
          "required_zones": [],
          "retain": {
            "default": 10,
            "objects": {}
          },
          "timestamp": false
        },
        "timestamp_style": {
          "color": {
            "blue": 255,
            "green": 255,
            "red": 255
          },
          "effect": null,
          "format": "%m/%d/%Y %H:%M:%S",
          "position": "tl",
          "thickness": 2
        },
        "zones": {}
      }
    },
    "database": {
      "path": "/media/frigate/frigate.db"
    },
    "detect": {
      "enabled": true,
      "fps": 5,
      "height": 720,
      "max_disappeared": null,
      "width": 1280
    },
    "detectors": {
      "coral": {
        "device": "pci",
        "num_threads": 3,
        "type": "edgetpu"
      }
    },
    "environment_vars": {},
    "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"
      ],
      "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"
        ]
      }
    },
    "live": {
      "height": 720,
      "quality": 8
    },
    "logger": {
      "default": "debug",
      "logs": {}
    },
    "model": {
      "height": 320,
      "labelmap": {},
      "labelmap_path": null,
      "path": null,
      "width": 320
    },
    "motion": null,
    "mqtt": {
      "client_id": "frigate",
      "host": "xxxx",
      "password": "xxxx",
      "port": 1883,
      "stats_interval": 60,
      "tls_ca_certs": null,
      "tls_client_cert": null,
      "tls_client_key": null,
      "tls_insecure": null,
      "topic_prefix": "frigate",
      "user": "xxxx"
    },
    "objects": {
      "filters": {
        "car": {
          "mask": null,
          "max_area": 24000000,
          "min_area": 0,
          "min_score": 0.4,
          "threshold": 0.5
        }
      },
      "mask": "",
      "track": [
        "person",
        "car",
        "motorcycle",
        "bicycle",
        "bird",
        "cat",
        "dog",
        "bear"
      ]
    },
    "record": {
      "enabled": true,
      "events": {
        "max_seconds": 300,
        "objects": null,
        "post_capture": 5,
        "pre_capture": 5,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {}
        }
      },
      "retain_days": 1
    },
    "rtmp": {
      "enabled": true
    },
    "snapshots": {
      "bounding_box": true,
      "clean_copy": true,
      "crop": false,
      "enabled": false,
      "height": null,
      "quality": 70,
      "required_zones": [],
      "retain": {
        "default": 10,
        "objects": {}
      },
      "timestamp": false
    },
    "timestamp_style": {
      "color": {
        "blue": 255,
        "green": 255,
        "red": 255
      },
      "effect": null,
      "format": "%m/%d/%Y %H:%M:%S",
      "position": "tl",
      "thickness": 2
    }
  }

Relevant log output

N/A

FFprobe output from your camera

N/A

Frigate stats

No response

Operating system

UNRAID

Install method

Docker CLI

Coral version

PCIe

Network connection

Wired

Camera make and model

Amcrest IP5M-T1179EW-28MM

Any other information that may be helpful

No response

blakeblackshear commented 3 years ago

How are you verifying which stream is using RTMP? Looking at the generated ffmpeg commands, you can clearly see which stream is sending to rtmp, and it's correct. The rtmp stream is not used in the WebUI for frigate and is only used by home assistant if you have the stream component enabled.

lcasale commented 3 years ago

Sorry I should have been more specific. I'm testing via home assistant using the frigate and card add-ons with jsmpeg. There is a substantial difference in home assistant in regards to fps and quality when I have a single path defined with all 3 roles vs 2 paths with split roles.

blakeblackshear commented 3 years ago

Jsmpeg pulls from the detect feed, not RTMP.

stale[bot] commented 2 years 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.