blakeblackshear / frigate

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

Unable to get Frigate to work with Android IP Cam #1450

Closed bgbaker closed 3 years ago

bgbaker commented 3 years ago

Describe the bug I have a new install of Frigate using the HomeAssistant supervisor install method addon I have a single camera that is an Android cellphone running Android IP Cam application Below errors come up in the log when starting and nothing works:

ffmpeg.front_yard.detect ERROR : Option stimeout not found. frigate.video INFO : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures frigate.video INFO : front_yard: ffmpeg process is not running. exiting capture thread...

Version of frigate Current version: 1.13

Config file Include your full config file wrapped in triple back ticks.

mqtt:
  # Required: host name
  host: 192.168.0.52
  # Optional: port (default: shown below)
  port: 1883
  # Optional: topic prefix (default: shown below)
  # WARNING: must be unique if you are running multiple instances
  topic_prefix: frigate
  # Optional: client id (default: shown below)
  # WARNING: must be unique if you are running multiple instances
  client_id: frigate
  # Optional: user
  user: mosquitto
  # Optional: password
  # NOTE: Environment variables that begin with 'FRIGATE_' may be referenced in {}.
  #       eg. password: '{FRIGATE_MQTT_PASSWORD}'
  password: password
  # Optional: interval in seconds for publishing stats (default: shown below)
  stats_interval: 60

cameras:
  # Name of your camera
  front_yard:
    ffmpeg:
      inputs:
        - path: http://192.168.1.45:8080/video
          roles:
            - detect
            - rtmp
    width: 1920
    height: 1080

detectors:
  cpu1:
    type: cpu
  cpu2:
    type: cpu

ffmpeg:
  # Optional: global ffmpeg args (default: shown below)
  global_args: -hide_banner -loglevel verbose

Frigate container logs

 * Starting nginx nginx
   ...done.
frigate.app                    INFO    : Creating directory: /tmp/cache
frigate.app                    WARNING : Camera front_yard has rtmp enabled, but rtmp is not assigned to an input.
Starting migrations
peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
peewee_migrate                 INFO    : There is nothing to migrate
frigate.mqtt                   INFO    : MQTT connected
detector.cpu2                  INFO    : Starting detection process: 37
detector.cpu1                  INFO    : Starting detection process: 35
frigate.app                    INFO    : Camera processor started for front_yard: 40
frigate.app                    INFO    : Capture process started for front_yard: 41
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg process is not running. exiting capture thread...
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x55c7c175d500] Starting connection attempt to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x55c7c175d500] Successfully connected to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : Option stimeout not found.
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg process is not running. exiting capture thread...
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x562c7a4fe500] Starting connection attempt to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x562c7a4fe500] Successfully connected to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : Option stimeout not found.
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg process is not running. exiting capture thread...
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x55ddec565500] Starting connection attempt to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x55ddec565500] Successfully connected to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : Option stimeout not found.
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg process is not running. exiting capture thread...
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x5620aa163500] Starting connection attempt to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x5620aa163500] Successfully connected to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : Option stimeout not found.
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg process is not running. exiting capture thread...
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x55b310d06500] Starting connection attempt to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : [tcp @ 0x55b310d06500] Successfully connected to 192.168.1.45 port 8080
ffmpeg.front_yard.detect       ERROR   : Option stimeout not found.
frigate.video                  INFO    : front_yard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : front_yard: ffmpeg process is not running. exiting capture thread...

Frigate stats

{
  "cameras": {
    "front_yard": {
      "best_image_timeout": 60,
      "clips": {
        "enabled": false,
        "objects": null,
        "post_capture": 5,
        "pre_capture": 5,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {}
        }
      },
      "detect": {
        "enabled": true,
        "max_disappeared": 25
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel verbose -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i http://192.168.1.45:8080/video -c copy -f flv rtmp://127.0.0.1/live/front_yard -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect",
            "rtmp"
          ]
        }
      ],
      "fps": null,
      "frame_shape": [
        1080,
        1920
      ],
      "height": 1080,
      "motion": {
        "contour_area": 100,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 180,
        "mask": null,
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "required_zones": [],
        "timestamp": true
      },
      "name": "front_yard",
      "objects": {
        "filters": {
          "person": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": null,
        "track": [
          "person"
        ]
      },
      "record": {
        "enabled": false,
        "retain_days": 30
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": false,
        "crop": false,
        "enabled": false,
        "height": null,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {}
        },
        "timestamp": false
      },
      "width": 1920,
      "zones": {}
    }
  },
  "clips": {
    "max_seconds": 300,
    "retain": {
      "default": 10,
      "objects": {}
    },
    "tmpfs_cache_size": ""
  },
  "database": {
    "path": "/media/frigate/clips/frigate.db"
  },
  "detectors": {
    "cpu1": {
      "device": "usb",
      "num_threads": 3,
      "type": "cpu"
    },
    "cpu2": {
      "device": "usb",
      "num_threads": 3,
      "type": "cpu"
    }
  },
  "environment_vars": {},
  "logger": {
    "default": "INFO",
    "logs": {}
  },
  "model": {
    "height": 320,
    "width": 320
  },
  "mqtt": {
    "client_id": "frigate",
    "host": "192.168.0.52",
    "port": 1883,
    "stats_interval": 60,
    "topic_prefix": "frigate",
    "user": "mosquitto"
  },
  "snapshots": {
    "retain": {
      "default": 10,
      "objects": {}
    }
  }
}

FFprobe from your camera

Run the following command and paste output below

 ffprobe https://192.168.1.45:8080/video
ffprobe version 4.0.5 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 8 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, mpjpeg, from 'https://192.168.1.45:8080/video':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc

Screenshots If applicable, add screenshots to help explain your problem.

Computer Hardware

Camera Info:

Additional context Add any other context about the problem here.

blakeblackshear commented 3 years ago

You will need to use the mjpeg settings from the docs for mjpeg cameras.

bgbaker commented 3 years ago

Thank you Blake. I got this working with the RTP link for Android IP Cam. I tried this initially but there must have been a typo or something. For reference you use: rtsp://IPAddress:Port/h264_pcm.sdp for the RTP stream of Android IP Cam

kevvar commented 2 years ago

@bgbaker I'm trying to make it work with Android IP Cam, but any setup I write doesn't work, any idea? see mi logs and config:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2022-09-29 09:37:03] frigate.app                    INFO    : Starting Frigate (0.11.0-3846a13)
*************************************************************
*************************************************************
***    Your config file is not valid!                     ***
***    Please check the docs at                           ***
***    https://docs.frigate.video/configuration/index     ***
*************************************************************
*************************************************************
***    Config Validation Errors                           ***
*************************************************************
'ffmpeg'
Traceback (most recent call last):
  File "/opt/frigate/frigate/app.py", line 332, in start
    self.init_config()
  File "/opt/frigate/frigate/app.py", line 82, in init_config
    user_config = FrigateConfig.parse_file(config_file)
  File "/opt/frigate/frigate/config.py", line 942, in parse_file
    return cls.parse_obj(config)
  File "pydantic/main.py", line 521, in pydantic.main.BaseModel.parse_obj
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1056, in pydantic.main.validate_model
  File "pydantic/fields.py", line 859, in pydantic.fields.ModelField.validate
  File "pydantic/fields.py", line 994, in pydantic.fields.ModelField._validate_mapping_like
  File "pydantic/fields.py", line 1067, in pydantic.fields.ModelField._validate_singleton
  File "pydantic/fields.py", line 857, in pydantic.fields.ModelField.validate
  File "pydantic/fields.py", line 1074, in pydantic.fields.ModelField._validate_singleton
  File "pydantic/fields.py", line 1121, in pydantic.fields.ModelField._apply_validators
  File "pydantic/class_validators.py", line 313, in pydantic.class_validators._generic_validator_basic.lambda12
  File "pydantic/main.py", line 704, in pydantic.main.BaseModel.validate
  File "/opt/frigate/frigate/config.py", line 584, in __init__
    if len(config["ffmpeg"]["inputs"]) == 1:
KeyError: 'ffmpeg'
*************************************************************
***    End Config Validation Errors                       ***
*************************************************************
[cmd] python3 exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

frigate.yml

mqtt:
  host: 192.168.1.128
  user: mosco
  password: mosco1

cameras:
  camara_prueba:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.140:8080/h264_pcm.sdp
          roles:
            - detect
            - rtmp
  detect:
    width: 1920
    height: 1080
    fps: 5

detectors:
  cpu1:
    type: cpu
  cpu2:
    type: cpu

ffmpeg:
  global_args: -hide_banner -loglevel verbose
NickM-27 commented 2 years ago

@kevvar please view the docs on creating a config file. detect is not indented enough.

kevvar commented 2 years ago

@NickM-27 It works, I'm so sorry for that dumb mistake. You made my day, have a great one!

boyphongsakorn commented 2 years ago

in my home is work (MJPEG) but video is freeze or sometime video broken green

download.md.png

ffmpeg:
  output_args:
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac

cameras:
  ftfh_camera:
    ffmpeg:
      input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1
      inputs:
        - path: http://192.168.31.92:8080/video
          roles:
            - detect
      output_args:
        record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an
        rtmp: -c:v libx264 -an -f flv
    objects:
      track:
        - person
        - cat
        - dog
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: false
      retain:
        default: 2

record:
  enabled: true
  retain:
    days: 7
    mode: all
kevvar commented 2 years ago

Maybe you can change the path to the rtsp link provided by the app