blakeblackshear / frigate

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

Unable to get substream from Amcrest POE Camera #1624

Closed stu1811 closed 3 years ago

stu1811 commented 3 years ago

Describe the bug Unable to get video from IP camera. I'm able to get a stream from my doorbell so I know the system is setup right. I assume a problem with my config.

 ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures

Version of frigate Output from /api/version 1.13 in Home Assistant 0.8.4-5043040

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

# frigate.yml
detectors:
  cpu1:
    type: cpu
mqtt:
  # Required: host name
  host: core-mosquitto
  # 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: mqtt_username
  # Optional: password
  # NOTE: Environment variables that begin with 'FRIGATE_' may be referenced in {}.
  #       eg. password: '{FRIGATE_MQTT_PASSWORD}'
  password: mqtt_password
  # Optimal in seconds for publishing stats (default: shown below)
  stats_interval: 60
cameras:
  # Name of your camera

  garage:
    ffmpeg:
      inputs:
        - path: rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect #-f segment -segment_time 60 -segment_format yuv420p -reset_timestamps 1 -strftime 1 -c copy -an
            - record #-f segment -segment_time 60 -segment_format yuv420p -reset_timestamps 1 -strftime 1 -c copy -an
            - rtmp
        - path: rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - clips
          #  - record
          #  - rtmp
    objects: 
      track:
        - person
        - car
        - truck
        - bicycle
        - motorcycle
        - dog
        - cat
        # Optional: save clips configuration
    clips:
      # Required: enables clips for the camera (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: Number of seconds before the event to include in the clips (default: shown below)
      pre_capture: 5
      # Optional: Number of seconds after the event to include in the clips (default: shown below)
      post_capture: 5
      # Optional: Objects to save clips for. (default: all tracked objects)
      objects:
        - person
      # Optional: Restrict clips to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain_days: 30
    width: 704
    height: 480
    fps: 5

Frigate container logs

* Starting nginx nginx
   ...done.
frigate.app                    INFO    : Creating directory: /tmp/cache
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
frigate.app                    INFO    : Camera processor started for garage: 38
frigate.app                    INFO    : Capture process started for garage: 40
detector.cpu1                  INFO    : Starting detection process: 36
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x561737b4aac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x561737c41680] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x561737c41680] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x561737b47c80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x561737b47c80] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x561737b47c80] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x561737b47c80] Failed to update header with correct filesize.

Frigate stats

{
  "cameras": {
    "garage": {
      "best_image_timeout": 60,
      "clips": {
        "enabled": true,
        "objects": [
          "person"
        ],
        "post_capture": 5,
        "pre_capture": 5,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {
            "person": 15
          }
        }
      },
      "detect": {
        "enabled": true,
        "max_disappeared": 25
      },
      "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://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1 -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /media/frigate/recordings/garage-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/garage -r 5 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect",
            "record",
            "rtmp"
          ]
        },
        {
          "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://admin:MYPASSWORD@192.168.42.220: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",
          "roles": [
            "clips"
          ]
        }
      ],
      "fps": 5,
      "frame_shape": [
        480,
        704
      ],
      "height": 480,
      "motion": {
        "contour_area": 100,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 80,
        "mask": null,
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "required_zones": [],
        "timestamp": true
      },
      "name": "garage",
      "objects": {
        "filters": {
          "bicycle": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "car": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "cat": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "dog": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "motorcycle": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "person": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "truck": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": null,
        "track": [
          "person",
          "car",
          "truck",
          "bicycle",
          "motorcycle",
          "dog",
          "cat"
        ]
      },
      "record": {
        "enabled": true,
        "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": 704,
      "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"
    }
  },
  "environment_vars": {},
  "logger": {
    "default": "INFO",
    "logs": {}
  },
  "model": {
    "height": 320,
    "width": 320
  },
  "mqtt": {
    "client_id": "frigate",
    "host": "core-mosquitto",
    "port": 1883,
    "stats_interval": 60,
    "topic_prefix": "frigate",
    "user": "mqtt_username"
  },
  "snapshots": {
    "retain": {
      "default": 10,
      "objects": {}
    }
  }
}

FFprobe from your camera

Run the following command and paste output below

ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers                                                                                                                                                           
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)                                                                                                                                                                                              
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filt
er=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-librubberba
nd --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-li
bx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc -
-enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared                                                                                                                                                                     
  libavutil      56. 31.100 / 56. 31.100                                                                                                                                                                                                 
  libavcodec     58. 54.100 / 58. 54.100                                                                                                                                                                                                 
  libavformat    58. 29.100 / 58. 29.100                                                                                                                                                                                                 
  libavdevice    58.  8.100 / 58.  8.100                                                                                                                                                                                                 
  libavfilter     7. 57.100 /  7. 57.100                                                                                                                                                                                                 
  libavresample   4.  0.  0 /  4.  0.  0                                                                                                                                                                                                 
  libswscale      5.  5.100 /  5.  5.100                                                                                                                                                                                                 
  libswresample   3.  5.100 /  3.  5.100                                                                                                                                                                                                 
  libpostproc    55.  5.100 / 55.  5.100                                                                                                                                                                                                 
Input #0, rtsp, from 'rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1':                                                                                                                                   
  Metadata:                                                                                                                                                                                                                              
    title           : Media Server                                                                                                                                                                                                       
  Duration: N/A, start: 0.400000, bitrate: N/A                                                                                                                                                                                           
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 704x480, 100 tbr, 90k tbn, 180k tbc  

Screenshots Green screen inside frigate. Figured screenshot was not necessary.

Computer Hardware

Camera Info:

Additional context If I disable the substream and only use the main stream the video loads fine.

trythatagain commented 3 years ago

I have a Amcrest IP8M-T2499, I add '&unicast=true&proto=Onvif' to my streams, but I'm not sure thats needed though. I'd put the stream in VLC and look at the codec info, but for my camera (8pm) using subtype=1 would equal 640 * 480, so perhaps try that.

stu1811 commented 3 years ago

@trythatagain VLC media info below. Is it weird that the video resolution is different than the buffer dimension? I tried changing the substream to VGA (640x480) and I get the same results. Original substream config is also pictured below.

image image

Here are the logs form VGA run. I tried adding unicast and Onvif to the url as you suggested.

  "cameras": {
    "garage": {
      "best_image_timeout": 60,
      "clips": {
        "enabled": true,
        "objects": [
          "person"
        ],
        "post_capture": 5,
        "pre_capture": 5,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {
            "person": 15
          }
        }
      },
      "detect": {
        "enabled": true,
        "max_disappeared": 25
      },
      "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://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /media/frigate/recordings/garage-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/garage -r 5 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect",
            "record",
            "rtmp"
          ]
        },
        {
          "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://admin:MYPASSWORD@192.168.42.220: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",
          "roles": [
            "clips"
          ]
        }
      ],
      "fps": 5,
      "frame_shape": [
        480,
        640
      ],
      "height": 480,
      "motion": {
        "contour_area": 100,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 80,
        "mask": null,
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "required_zones": [],
        "timestamp": true
      },
      "name": "garage",
      "objects": {
        "filters": {
          "bicycle": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "car": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "cat": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "dog": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "motorcycle": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "person": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "truck": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": null,
        "track": [
          "person",
          "car",
          "truck",
          "bicycle",
          "motorcycle",
          "dog",
          "cat"
        ]
      },
      "record": {
        "enabled": true,
        "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": 640,
      "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"
    }
  },
  "environment_vars": {},
  "logger": {
    "default": "INFO",
    "logs": {}
  },
  "model": {
    "height": 320,
    "width": 320
  },
  "mqtt": {
    "client_id": "frigate",
    "host": "core-mosquitto",
    "port": 1883,
    "stats_interval": 60,
    "topic_prefix": "frigate",
    "user": "mqtt_username"
  },
  "snapshots": {
    "retain": {
      "default": 10,
      "objects": {}
    }
  }
}
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x55a1d5bbdac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55a1d5cfaac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55a1d5cfaac0] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x55a1d5bc8d80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x55a1d5bc8d80] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55a1d5bc8d80] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55a1d5bc8d80] Failed to update header with correct filesize.
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x562e7faecac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x562e7fb91140] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x562e7fb91140] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x562e7faf7340] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x562e7faf7340] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x562e7faf7340] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x562e7faf7340] Failed to update header with correct filesize.
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x562c5432cac0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x562c543d12c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x562c543d12c0] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x562c5433cd80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x562c5433cd80] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x562c5433cd80] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x562c5433cd80] Failed to update header with correct filesize.
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x55f855e4f600] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55f855f70500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55f855f70500] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x55f855e4e180] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x55f855e4e180] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55f855e4e180] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55f855e4e180] Failed to update header with correct filesize.
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x55c997e13600] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55c997ed6680] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55c997ed6680] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x55c997e14040] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x55c997e14040] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55c997e14040] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55c997e14040] Failed to update header with correct filesize.
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
# frigate.yml
detectors:
  cpu1:
    type: cpu
mqtt:
  # Required: host name
  host: core-mosquitto
  # 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: mqtt_username
  # Optional: password
  # NOTE: Environment variables that begin with 'FRIGATE_' may be referenced in {}.
  #       eg. password: '{FRIGATE_MQTT_PASSWORD}'
  password: mqtt_password
  # Optimal in seconds for publishing stats (default: shown below)
  stats_interval: 60
cameras:
  # Name of your camera

  garage:
    ffmpeg:
      #input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 #-use_wallclock_as_timestamps 1
      #output_args:
        #record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an
#-use_wallclock_as_timestamps 1
#     hwaccel_args:
#        - -c:v
#        - h264_v4l2m2m
      inputs:
        - path: rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif
          roles:
            - detect #-f segment -segment_time 60 -segment_format yuv420p -reset_timestamps 1 -strftime 1 -c copy -an
            - record #-f segment -segment_time 60 -segment_format yuv420p -reset_timestamps 1 -strftime 1 -c copy -an
            - rtmp
        - path: rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - clips
          #  - record
          #  - rtmp
    objects: 
      track:
        - person
        - car
        - truck
        - bicycle
        - motorcycle
        - dog
        - cat
        # Optional: save clips configuration
    clips:
      # Required: enables clips for the camera (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: Number of seconds before the event to include in the clips (default: shown below)
      pre_capture: 5
      # Optional: Number of seconds after the event to include in the clips (default: shown below)
      post_capture: 5
      # Optional: Objects to save clips for. (default: all tracked objects)
      objects:
        - person
      # Optional: Restrict clips to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain_days: 30
    width: 640
    height: 480
    #width: 3840
    #height: 2160
    fps: 5
trythatagain commented 3 years ago

Sorry for the delay, bank holiday here, out on motorbike. Any way, I changed my config to match your var the 'clips' and it works. I used the sub stream resolution of 704*576 matching the settings from the camera.

But I do something difference on the camera setup itself, FPS 15, Max bit rate 512, I frame rate 50.

I also changed from my coral detector to cpu, I5 6600.

Each time the image comes up fine.

Perhaps you can try those settings and see if that improves it, I'll keep the test config so and can test more .

stu1811 commented 3 years ago

I updated the camera settings to 15 FPS, 30 I frame, and 512 kbps image


ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --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-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, rtsp, from 'rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 0.060000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 640x480, 100 tbr, 90k tbn, 180k tbc

I didn't change any settings in frigate.yml

 * Starting nginx nginx
   ...done.
frigate.app                    INFO    : Creating directory: /tmp/cache
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
frigate.app                    INFO    : Camera processor started for garage: 41
frigate.app                    INFO    : Capture process started for garage: 42
detector.cpu1                  INFO    : Starting detection process: 38
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
ffmpeg.garage.detect           ERROR   : [segment @ 0x55817ebd6080] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55817ecbaf40] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [mp4 @ 0x55817ecbaf40] pts has no value
ffmpeg.garage.detect           ERROR   : [flv @ 0x55817ebd9bc0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
ffmpeg.garage.detect           ERROR   : [flv @ 0x55817ebd9bc0] Packet is missing PTS
ffmpeg.garage.detect           ERROR   : av_interleaved_write_frame(): Invalid argument
ffmpeg.garage.detect           ERROR   : Finishing stream 2:0 without any data written to it.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55817ebd9bc0] Failed to update header with correct duration.
ffmpeg.garage.detect           ERROR   : [flv @ 0x55817ebd9bc0] Failed to update header with correct filesize.
frigate.video                  INFO    : garage: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : garage: ffmpeg process is not running. exiting capture thread...
{
  "cameras": {
    "garage": {
      "best_image_timeout": 60,
      "clips": {
        "enabled": true,
        "objects": [
          "person"
        ],
        "post_capture": 5,
        "pre_capture": 5,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {
            "person": 15
          }
        }
      },
      "detect": {
        "enabled": true,
        "max_disappeared": 25
      },
      "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://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /media/frigate/recordings/garage-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/garage -r 5 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect",
            "record",
            "rtmp"
          ]
        },
        {
          "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://admin:MYPASSWORD@192.168.42.220: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",
          "roles": [
            "clips"
          ]
        }
      ],
      "fps": 5,
      "frame_shape": [
        480,
        640
      ],
      "height": 480,
      "motion": {
        "contour_area": 100,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 80,
        "mask": null,
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "required_zones": [],
        "timestamp": true
      },
      "name": "garage",
      "objects": {
        "filters": {
          "bicycle": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "car": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "cat": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "dog": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "motorcycle": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "person": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "truck": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": null,
        "track": [
          "person",
          "car",
          "truck",
          "bicycle",
          "motorcycle",
          "dog",
          "cat"
        ]
      },
      "record": {
        "enabled": true,
        "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": 640,
      "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"
    }
  },
  "environment_vars": {},
  "logger": {
    "default": "INFO",
    "logs": {}
  },
  "model": {
    "height": 320,
    "width": 320
  },
  "mqtt": {
    "client_id": "frigate",
    "host": "core-mosquitto",
    "port": 1883,
    "stats_interval": 60,
    "topic_prefix": "frigate",
    "user": "mqtt_username"
  },
  "snapshots": {
    "retain": {
      "default": 10,
      "objects": {}
    }
  }
}
stu1811 commented 3 years ago

@trythatagain I got it working. I'll post my config tomorrow. Thanks for the help

stu1811 commented 3 years ago

Long story short RTFM. DOH! Last night it dawned on as I was reading through the docs that I should use the sample rtmp config (input args). I originally didn't use it because I was connecting via rtsp and didn't know the difference between rtsp and rtmp.

Side note: in the reolink sample config it has a rw_timeout variable. I tried to use it and it said unknown option. Maybe it's deprecated?

# frigate.yml
detectors:
  cpu1:
    type: cpu
mqtt:
  host: core-mosquitto
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: mqtt_username
  password: mqtt_password
  stats_interval: 60
cameras:
  garage:
    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: rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
            - record
            - rtmp
        - path: rtsp://admin:MYPASSWORD@192.168.42.220:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - clips
    objects:
      track:
        - person
        - car
        - truck
        - dog
        # Optional: save clips configuration
    clips:
      enabled: True
      pre_capture: 5
      post_capture: 5
      # Optional: Objects to save clips for. (default: all tracked objects)
      objects:
        - person
        - car
        - truck
        - dog
      # Optional: Restrict clips to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    record:
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain_days: 30
    width: 704
    height: 480
    fps: 5
trythatagain commented 3 years ago

Glad it's all sorted, I realise now I should of said I just use docker when running Frigate. Still thinking about Home Assistant. Nice to see something sorted, plus we all get to learn something. Again great it's all going well, hopefully the change to 0.9 won't be too hard :)