blakeblackshear / frigate

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

[Support]: How to connect http video stream to frigate (green screen) #2673

Closed tobe2bcon closed 2 years ago

tobe2bcon commented 2 years ago

Describe the problem you are having

I'm running frigate in docker on a coral dev board (mendel linux). The camera I have (Elro or Smartwares C903IP.2) provides the video stream on http://user:pw@/videostream.cgi. The problem is, I am not able to visualise the stream in frigate and I can only see the green screen. I read through the issues related to green screen but I am not able to resolve the problem on my own.

This is the docker command I start frigate with:

docker run -d --name frigate --restart=unless-stopped --mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 --device /dev/apex_0:/dev/apex_0 --shm-size=64m -v /home/mendel/frigate:/media/frigate -v /home/mendel/docker/config.yml:/config/config.yml:ro -v /etc/localtime:/etc/localtime:ro -e FRIGATE_RTSP_PASSWORD='' -p 5000:5000 -p 1935:1935 blakeblackshear/frigate:stable-aarch64

Version

0.9.4-26AE608

Frigate config file

mqtt:
  host: 192.168.13.155
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: ""
  password: ""
  stats_interval: 60

detectors:
  coral:
    type: edgetpu
    device: ''

cameras:
  camera_1:
    ffmpeg:
      input_args:
      - -avoid_negative_ts
      - -rtsp
      - http
      inputs:
        - path: http://admin:500686@192.168.13.205/videostream.cgi
          roles:
            - detect
    detect:
      width:  640
      height: 480
      fps: 10

Relevant log output

{
  "birdseye": {
    "enabled": true,
    "height": 720,
    "mode": "objects",
    "quality": 8,
    "width": 1280
  },
  "cameras": {
    "camera_1": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": true,
        "fps": 10,
        "height": 480,
        "max_disappeared": 50,
        "width": 640
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [],
        "input_args": [
          "-avoid_negative_ts",
          "-rtsp",
          "http"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "http://admin:500686@192.168.13.205/videostream.cgi",
            "roles": [
              "record",
              "rtmp",
              "detect"
            ]
          }
        ],
        "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 -rtsp http -i http://admin:500686@192.168.13.205/videostream.cgi -c copy -f flv rtmp://127.0.0.1/live/camera_1 -r 10 -s 640x480 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "record",
            "rtmp",
            "detect"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 8
      },
      "motion": {
        "contour_area": 74,
        "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": "camera_1",
      "objects": {
        "filters": {
          "person": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": "",
        "track": [
          "person"
        ]
      },
      "record": {
        "enabled": false,
        "events": {
          "max_seconds": 300,
          "objects": null,
          "post_capture": 5,
          "pre_capture": 5,
          "required_zones": [],
          "retain": {
            "default": 10,
            "objects": {}
          }
        },
        "retain_days": 0
      },
      "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": "",
      "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": "info",
    "logs": {}
  },
  "model": {
    "height": 320,
    "labelmap": {},
    "labelmap_path": null,
    "path": null,
    "width": 320
  },
  "motion": null,
  "mqtt": {
    "client_id": "frigate",
    "host": "192.168.13.155",
    "password": "",
    "port": 1883,
    "stats_interval": 60,
    "tls_ca_certs": null,
    "tls_client_cert": null,
    "tls_client_key": null,
    "tls_insecure": null,
    "topic_prefix": "frigate",
    "user": ""
  },
  "objects": {
    "filters": null,
    "mask": "",
    "track": [
      "person"
    ]
  },
  "record": {
    "enabled": false,
    "events": {
      "max_seconds": 300,
      "objects": null,
      "post_capture": 5,
      "pre_capture": 5,
      "required_zones": [],
      "retain": {
        "default": 10,
        "objects": {}
      }
    },
    "retain_days": 0
  },
  "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
  }
}

FFprobe output from your camera

ffprobe http://admin:500686@192.168.13.205/videostream.cgi
ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mpjpeg, from 'http://admin:500686@192.168.13.205/videostream.cgi':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc

Frigate stats

{"camera_1":{"camera_fps":0.0,"capture_pid":223,"detection_fps":0.0,"pid":220,"process_fps":0.0,"skipped_fps":0.0},"detection_fps":0.0,"detectors":{"coral":{"detection_start":0.0,"inference_speed":10.0,"pid":216}},"service":{"storage":{"/dev/shm":{"free":66.8,"mount_type":"tmpfs","total":67.1,"used":0.3},"/media/frigate/clips":{"free":1668.4,"mount_type":"ext4","total":2046.6,"used":254.1},"/media/frigate/recordings":{"free":1668.4,"mount_type":"ext4","total":2046.6,"used":254.1},"/tmp/cache":{"free":1000.0,"mount_type":"tmpfs","total":1000.0,"used":0.0}},"uptime":435,"version":"0.9.4-26ae608"}}

Operating system

Other Linux

Install method

Docker CLI

Coral version

Dev Board

Network connection

Wireless

Camera make and model

Elro or Smartwares C903IP.2

Any other information that may be helpful

No response

NickM-27 commented 2 years ago

Are you able to view the stream in VLC?

tobe2bcon commented 2 years ago

Thank you for your quick response. I copied http://admin:500686@192.168.13.205/videostream.cgi to VLC and immediately got the camera's stream

blakeblackshear commented 2 years ago

Ffprobe shows that your camera provides an mjpeg stream. https://docs.frigate.video/configuration/camera_specific#mjpeg-cameras

tobe2bcon commented 2 years ago

Hi Blake, thank you for your hints. I've modified the config.yml accordingly. While still showing the green screen, this is working so far:`mqtt:

host: 192.168.13.155

port: 1883

topic_prefix: frigate

client_id: frigate

user: ""

password: ""

stats_interval: 60

detectors:

coral:

type: edgetpu

device: ''

ffmpeg:

  input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags

low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1

  output_args:

    detect: -f segment -segment_time 10 -segment_format mp4

-reset_timestamps 1 -strftime 1 -c:v libx264 -an

    rtmp: -c:v libx264 -an -f flv

cameras:

camera_1:

ffmpeg:

  inputs:

    - path: ***@***.***/videostream.cgi

      roles:

        - detect

- record

- rtmp

detect:

  width:  640

  height: 480

  fps: 5

record:

width: 640

height: 480

fps: 10

rtmp:

width: 640

height: 480

fps: 10

The debug stats show this:{ "birdseye": { "enabled": true, "height": 720, "mode": "objects", "quality": 8, "width": 1280 }, "cameras": { "camera_1": { "best_image_timeout": 60, "detect": { "enabled": true, "fps": 5, "height": 480, "max_disappeared": 25, "width": 640 }, "ffmpeg": { "global_args": [ "-hide_banner", "-loglevel", "warning" ], "hwaccel_args": [], "input_args": "-avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1", "inputs": [ { "global_args": [], "hwaccel_args": [], "input_args": [], "path": @./videostream.cgi ", "roles": [ "record", "rtmp", "detect" ] } ], "output_args": { "detect": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an", "record": [ "-f", "segment", "-segment_time", "10", "-segment_format", "mp4", "-reset_timestamps", "1", "-strftime", "1", "-c", "copy", "-an" ], "rtmp": "-c:v libx264 -an -f flv" } }, "ffmpeg_cmds": [ { "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -i @./videostream.cgi -c:v libx264 -an -f flv rtmp://127.0.0.1/live/camera_1 -r 5 -s 640x480 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an pipe:", "roles": [ "record", "rtmp", "detect" ] } ], "live": { "height": 720, "quality": 8 }, "motion": { "contour_area": 74, "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": "camera_1", "objects": { "filters": { "person": { "mask": null, "max_area": 24000000, "min_area": 0, "min_score": 0.5, "threshold": 0.7 } }, "mask": "", "track": [ "person" ] }, "record": { "enabled": false, "events": { "max_seconds": 300, "objects": null, "post_capture": 5, "pre_capture": 5, "required_zones": [], "retain": { "default": 10, "objects": {} } }, "retain_days": 0 }, "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": "", "num_threads": 3, "type": "edgetpu" } }, "environment_vars": {}, "ffmpeg": { "global_args": [ "-hide_banner", "-loglevel", "warning" ], "hwaccel_args": [], "input_args": "-avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1", "output_args": { "detect": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an", "record": [ "-f", "segment", "-segment_time", "10", "-segment_format", "mp4", "-reset_timestamps", "1", "-strftime", "1", "-c", "copy", "-an" ], "rtmp": "-c:v libx264 -an -f flv" } }, "live": { "height": 720, "quality": 8 }, "logger": { "default": "info", "logs": {} }, "model": { "height": 320, "labelmap": {}, "labelmap_path": null, "path": null, "width": 320 }, "motion": null, "mqtt": { "client_id": "frigate", "host": "192.168.13.155", "password": "", "port": 1883, "stats_interval": 60, "tls_ca_certs": null, "tls_client_cert": null, "tls_client_key": null, "tls_insecure": null, "topic_prefix": "frigate", "user": "" }, "objects": { "filters": null, "mask": "", "track": [ "person" ] }, "record": { "enabled": false, "events": { "max_seconds": 300, "objects": null, "post_capture": 5, "pre_capture": 5, "required_zones": [], "retain": { "default": 10, "objects": {} } }, "retain_days": 0 }, "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 } }` What else could I do now? Thank you in advance. BestThomas Am Mittwoch, dem 19.01.2022 um 15:22 -0800 schrieb Blake Blackshear:

Ffprobe shows that your camera provides an mjpeg stream. https://docs.frigate.video/configuration/camera_specific#mjpeg-cameras

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: < @.***>

tobe2bcon commented 2 years ago

Hi Blake, since the camera also wasn't capable to connect to my WLAN, I have decided to return it to the supplier. Following your advice I have ordered a daruha camera with H.264, that will hopefully connect to frigate easily. So this issue can be closed

Since connecting mjpeg cameras seems to be interesting for several people I am still working on a sultion that is based on a different approach: The conversion of the video stream needs not neccessarily be done with ffmpeg within frigate. I am currently close to a solution based on v4l2server. Only the mapping from the real video port (USB) to a virtual video device is still missing, since v4l2loopback is not running properly yet.

If you are interested I will keep you updated on this.

Best Thomas