question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to get substream from Amcrest POE Camera

See original GitHub issue

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

  • OS: Ubuntu 20.04
  • Install method: Home assistant add on
  • Virtualization: Home assistant in docker
  • Coral Version: None
  • Network Setup: Wired POE camera connected to wired server via switch

Camera Info:

  • Manufacturer: Amcrest
  • Model: IP8M-2597EB-28MM
  • Resolution: 4K Main/ 704x420 Secondary
  • FPS: 5

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
trythatagaincommented, Sep 1, 2021

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 😃

0reactions
stu1811commented, Sep 1, 2021

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

Main stream will not load but sub stream does - Amcrest Forum
Recently loaded surveillance pro on a new Windows laptop and my P2P DVR cameras will display when sub stream is selected but main...
Read more >
Amcrest WebUI - How to Troubleshoot Sub stream Mode to ...
Your browser can't play this video. Learn more. Switch camera.
Read more >
BI 5.2.9.6 - can't get substream for Amcrest IP5M | IP Cam Talk
Nevermind. I deleted the cam and re-added it, and now BI is pulling the substream as configured. This cam entry in BI was...
Read more >
sub stream IP on amcrest cameras? : r/BlueIris - Reddit
Amcrest cameras have 2 streams - main stream and a sub stream. I cannot figure out the IP address or port for the...
Read more >
Amcrest IP Camera Component Enhancements - PTZ control ...
Having said that, there are actually multiple video output streams that can be individually enabled or disabled. (I.e., Main Stream, Sub Stream, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found