blakeblackshear / frigate

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

issues with ubiquiti camera #321

Closed ebaschiera closed 3 years ago

ebaschiera commented 3 years ago

Describe the bug ffmpeg cannot decode the stream coming from my ubiquiti camera unless that stream is already open with another client (for example VLC Player). Is it a matter of ffmpeg timeouts or something like that? Please note that the rtsp ip address is the ubiquiti video controller, not the direct camera url.

Thanks!

Version of frigate Home Assistant Add-on: Frigate NVR 1.3

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

web_port: 5000
detectors:
  coral:
    type: edgetpu
    device: 'usb:0'
save_clips:
  clips_dir: /media/frigate
mqtt:
  host: core-mosquitto.local.hass.io
  user: username
  password: password
ffmpeg:
  global_args:
    - '-hide_banner'
    - '-loglevel'
    - debug
cameras:
  ingresso:
    ffmpeg:
      input: 'rtsp://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1'
    save_clips:
      enabled: true
      pre_capture: 5
    snapshots:
      show_timestamp: false
objects:
  track:
    - person
    - car
    - cat

Logs

Fontconfig error: Cannot load default config file
On connect called
ffprobe -v panic -show_error -show_streams -of json "rtsp://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1"
Starting detection process: 19
Attempting to load TPU as usb:0
No EdgeTPU detected. Falling back to CPU.
{'streams': [{'index': 0, 'codec_name': 'aac', 'codec_long_name': 'unknown', 'codec_type': 'audio', 'codec_time_base': '1/11025', 'codec_tag_string': '[0][0][0][0]', 'codec_tag': '0x0000', 'sample_fmt': 'fltp', 'sample_rate': '11025', 'channels': 1, 'channel_layout': 'mono', 'bits_per_sample': 0, 'r_frame_rate': '0/0', 'avg_frame_rate': '0/0', 'time_base': '1/11025', 'disposition': {'default': 0, 'dub': 0, 'original': 0, 'comment': 0, 'lyrics': 0, 'karaoke': 0, 'forced': 0, 'hearing_impaired': 0, 'visual_impaired': 0, 'clean_effects': 0, 'attached_pic': 0, 'timed_thumbnails': 0}}, {'index': 1, 'codec_name': 'h264', 'codec_long_name': 'unknown', 'codec_type': 'video', 'codec_time_base': '0/2', 'codec_tag_string': '[0][0][0][0]', 'codec_tag': '0x0000', 'width': 0, 'height': 0, 'coded_width': 0, 'coded_height': 0, 'closed_captions': 0, 'has_b_frames': 0, 'level': -99, 'refs': 1, 'is_avc': 'false', 'nal_length_size': '0', 'r_frame_rate': '90000/1', 'avg_frame_rate': '0/0', 'time_base': '1/90000', 'disposition': {'default': 0, 'dub': 0, 'original': 0, 'comment': 0, 'lyrics': 0, 'karaoke': 0, 'forced': 0, 'hearing_impaired': 0, 'visual_impaired': 0, 'clean_effects': 0, 'attached_pic': 0, 'timed_thumbnails': 0}}]}
Traceback (most recent call last):
  File "detect_objects.py", line 441, in <module>
    main()
  File "detect_objects.py", line 235, in main
    frame_shape = get_frame_shape(ffmpeg_input)
  File "/opt/frigate/frigate/video.py", line 48, in get_frame_shape
    frame_shape = frame.shape
AttributeError: 'NoneType' object has no attribute 'shape'

Frigate debug stats

-

FFprobe from your camera

This is run from another machine, based on Ubuntu 20.04

ffprobe -show_error -show_streams -of json "rtsp://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1"
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://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1':
  Metadata:
    title           : FCECDA8FC971_1
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: aac (LC), 11025 Hz, mono, fltp
    Stream #0:1: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1024x576 [SAR 189:190 DAR 168:95], 5 fps, 5 tbr, 90k tbn, 10 tbc
    "streams": [
        {
            "index": 0,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/11025",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "fltp",
            "sample_rate": "11025",
            "channels": 1,
            "channel_layout": "mono",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/11025",
            "start_pts": 0,
            "start_time": "0.000000",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            }
        },
        {
            "index": 1,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "Main",
            "codec_type": "video",
            "codec_time_base": "1/10",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 1024,
            "height": 576,
            "coded_width": 1024,
            "coded_height": 576,
            "has_b_frames": 0,
            "sample_aspect_ratio": "189:190",
            "display_aspect_ratio": "168:95",
            "pix_fmt": "yuvj420p",
            "level": 31,
            "color_range": "pc",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "false",
            "nal_length_size": "0",
            "r_frame_rate": "5/1",
            "avg_frame_rate": "5/1",
            "time_base": "1/90000",
            "start_pts": 127710,
            "start_time": "1.419000",
            "bits_per_raw_sample": "8",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            }
        }
    ]
}

Screenshots None

Computer Hardware

Camera Info:

Additional context None

ebaschiera commented 3 years ago

An additional note: this the log of Frigade when ffmpeg can actually get the stream working.

Fontconfig error: Cannot load default config file
ffprobe -v panic -show_error -show_streams -of json "rtsp://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1"
Starting detection process: 19
Attempting to load TPU as usb:0
No EdgeTPU detected. Falling back to CPU.
On connect called
{'streams': [{'index': 0, 'codec_name': 'aac', 'codec_long_name': 'unknown', 'codec_type': 'audio', 'codec_time_base': '1/11025', 'codec_tag_string': '[0][0][0][0]', 'codec_tag': '0x0000', 'sample_fmt': 'fltp', 'sample_rate': '11025', 'channels': 1, 'channel_layout': 'mono', 'bits_per_sample': 0, 'r_frame_rate': '0/0', 'avg_frame_rate': '0/0', 'time_base': '1/11025', 'disposition': {'default': 0, 'dub': 0, 'original': 0, 'comment': 0, 'lyrics': 0, 'karaoke': 0, 'forced': 0, 'hearing_impaired': 0, 'visual_impaired': 0, 'clean_effects': 0, 'attached_pic': 0, 'timed_thumbnails': 0}}, {'index': 1, 'codec_name': 'h264', 'codec_long_name': 'unknown', 'codec_type': 'video', 'codec_time_base': '0/2', 'codec_tag_string': '[0][0][0][0]', 'codec_tag': '0x0000', 'width': 0, 'height': 0, 'coded_width': 0, 'coded_height': 0, 'closed_captions': 0, 'has_b_frames': 0, 'level': -99, 'refs': 1, 'is_avc': 'false', 'nal_length_size': '0', 'r_frame_rate': '90000/1', 'avg_frame_rate': '0/0', 'time_base': '1/90000', 'disposition': {'default': 0, 'dub': 0, 'original': 0, 'comment': 0, 'lyrics': 0, 'karaoke': 0, 'forced': 0, 'hearing_impaired': 0, 'visual_impaired': 0, 'clean_effects': 0, 'attached_pic': 0, 'timed_thumbnails': 0}}]}
Camera capture process started for ingresso: 28
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel info -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -map 0 /cache/ingresso-%Y%m%d%H%M%S.mp4 -f rawvideo -pix_fmt yuv420p pipe:
Camera process started for ingresso: 30
 * Serving Flask app "detect_objects" (lazy loading)
 * Environment: development
 * Debug mode: off
Input #0, rtsp, from 'rtsp://192.168.0.140:7447/5fc2196ee4b006a8bdc4307f_1':
  Metadata:
    title           : FCECDA8FC971_1
  Duration: N/A, start: 1606652420.322086, bitrate: N/A
    Stream #0:0: Audio: aac, 11025 Hz, mono, fltp
    Stream #0:1: Video: h264, yuvj420p(pc, bt709, progressive), 1024x576 [SAR 189:190 DAR 168:95], 5 fps, 35 tbr, 90k tbn, 10 tbc
[segment @ 0x557b2171a0] Opening '/cache/ingresso-20201129132024.mp4' for writing
Output #0, segment, to '/cache/ingresso-%Y%m%d%H%M%S.mp4':
  Metadata:
    title           : FCECDA8FC971_1
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 1024x576 [SAR 189:190 DAR 168:95], q=2-31, 5 fps, 35 tbr, 10240 tbn, 5 tbc
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:1 -> #1:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=-1.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
frame=    0 fps=0.0 q=-1.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
frame=    0 fps=0.0 q=-1.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
[swscaler @ 0x557b2e4130] deprecated pixel format used, make sure you did set range correctly
Output #1, rawvideo, to 'pipe:':
  Metadata:
    title           : FCECDA8FC971_1
    encoder         : Lavf58.45.100
    Stream #1:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1024x576 [SAR 189:190 DAR 168:95], q=2-31, 35389 kb/s, 5 fps, 5 tbn, 5 tbc
    Metadata:
      encoder         : Lavc58.91.100 rawvideo
blakeblackshear commented 3 years ago

Try specifying the width and height parameters for your camera in the config. It is failing when trying to autodetect the resolution.

ebaschiera commented 3 years ago

It works! Thanks!