blakeblackshear / frigate

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

No web Page is loading #268

Closed wuast94 closed 3 years ago

wuast94 commented 4 years ago

i have created the container and set the config up, all seems good as you can see in the logs:

On connect called
ffprobe -v panic -show_error -show_streams -of json "rtsp://192.168.178.127"
Starting detection process: 31
Attempting to load TPU as usb
No EdgeTPU detected. Falling back to CPU.

But i cant load any web page, i was trying some of the urls mentioned in dokus but nothing.

on MQTT i see the "frigate" topic with "available = online" .. not more there

blakeblackshear commented 4 years ago

How are you running it? Can you post your docker command?

wuast94 commented 4 years ago

docker run -d --name='frigate' --net='bridge' -e TZ="Europe/Berlin" -e HOST_OS="Unraid" -p '5000:5000/tcp' -v '/mnt/user/appdata/frigate':'/config':'rw' -v '/etc/localtime':'/etc/localtime':'rw' --device='/dev/bus/usb' --shm-size=512m 'blakeblackshear/frigate:stable-amd64'

the funny thing, after i disconnect the camera i get some other massages (see below) and the web service is reachable .. but it dont reconnect to the cam after that...

On connect called
ffprobe -v panic -show_error -show_streams -of json "rtsp://192.168.178.127"
Starting detection process: 34
Attempting to load TPU as usb
No EdgeTPU detected. Falling back to CPU.
{'error': {'code': -111, 'string': 'Connection refused'}}

Traceback (most recent call last):
File "detect_objects.py", line 480, in <module>
main()
File "detect_objects.py", line 254, in main
frame_shape = get_frame_shape(ffmpeg_input)
File "/opt/frigate/frigate/video.py", line 40, in get_frame_shape
video_info = [s for s in info['streams'] if s['codec_type'] == 'video'][0]
KeyError: 'streams'
On connect called
ffprobe -v panic -show_error -show_streams -of json "rtsp://192.168.178.127"
Starting detection process: 31
Attempting to load TPU as usb
No EdgeTPU detected. Falling back to CPU.
{'streams': [{'index': 0, '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': 352, 'height': 288, 'coded_width': 352, 'coded_height': 288, '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}}]}
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -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.178.127 -f rawvideo -pix_fmt yuv420p pipe:
Camera_process started for back: 38
Starting process for back: 38
* Serving Flask app "detect_objects" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.

Use a production WSGI server instead.
* Debug mode: off
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -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.178.127 -f rawvideo -pix_fmt yuv420p pipe:
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...

and so on ...

blakeblackshear commented 4 years ago

Looks like something is causing the process to hang indefinitely and preventing the web server from starting. I am guessing it is the ffprobe command trying to auto detect your width and height. Try setting those values for your camera in the config. If you get a bunch of Creating ffmpeg process... messages, that means ffmpeg isnt able to connect with the input you provided.

wuast94 commented 4 years ago

ok that worked half.. now the web server starts but ffmpeg seems to have issues right now:

On connect called
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -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.178.127 -r 15 -f rawvideo -pix_fmt yuv420p pipe:
Starting detection process: 34
Attempting to load TPU as usb
Camera_process started for back: 37
Starting process for back: 37
No EdgeTPU detected. Falling back to CPU.
* Serving Flask app "detect_objects" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.

Use a production WSGI server instead.
* Debug mode: off
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -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.178.127 -r 15 -f rawvideo -pix_fmt yuv420p pipe:
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -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.178.127 -r 15 -f rawvideo -pix_fmt yuv420p pipe:
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...

and when i try to load http://domain:port/back i get an internal server error and this output in log:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.8/dist-packages/werkzeug/serving.py", line 314, in execute
for data in application_iter:
File "/usr/local/lib/python3.8/dist-packages/werkzeug/wsgi.py", line 506, in __next__
return self._next()
File "/usr/local/lib/python3.8/dist-packages/werkzeug/wrappers/base_response.py", line 45, in _iter_encoded
for item in iterable:
File "/opt/frigate/detect_objects.py", line 464, in imagestream
frame = object_processor.get_current_frame(camera_name, draw=True)
File "/opt/frigate/frigate/object_processing.py", line 357, in get_current_frame
return self.camera_states[camera].get_current_frame(draw)
File "/opt/frigate/frigate/object_processing.py", line 73, in get_current_frame
frame_copy = cv2.cvtColor(frame_copy, cv2.COLOR_YUV2BGR_I420)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-a98tlsvg/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<1>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::FROM_YUV; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'

> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 3
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
blakeblackshear commented 4 years ago

Increase the logging for ffmpeg and post your logs again.

ffmpeg:
  global_args:
    - -hide_banner
    - -loglevel
    - info
blakeblackshear commented 4 years ago

Also, please post your config file.

wuast94 commented 4 years ago

i get "rtsp://192.168.178.127: Server returned 4XX Client Error, but not one of 40{0,1,3,4}" i can open the stream with VLC just fine .. so why this client sends a 4XX ?

For your info im using an Iphone app to get an rtsp stream .. i dont have any rtsp cameras right now but would like to tinker a bit with this and when it work i will integrate it to Home Assistant for automation

wuast94 commented 4 years ago

config.txt

blakeblackshear commented 4 years ago

Try running ffmpeg to connect to the stream instead of VLC for testing.

wuast94 commented 4 years ago

i installed ffmpeg on windows and run: C:\Users\Wuast\ffmpeg-2020-10-21-git-289e964873-full_build\bin>ffmpeg -i "rtsp://192.168.178.127" -hls_time 3 -hls_wrap 10 "C:\Users\Wuast\streaming.m3u8"

and this is the output:

ffmpeg version 2020-10-21-git-289e964873-full_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.0 (Rev3, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.111.101 / 58.111.101
  libavformat    58. 62.100 / 58. 62.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.100 /  7. 88.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, rtsp, from 'rtsp://192.168.178.127':
  Metadata:
    title           : Live stream from iOS
  Duration: N/A, start: -0.066667, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(tv, smpte170m/bt709/bt709, progressive), 640x480, 15 fps, 15 tbr, 90k tbn, 180k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 00000142cb2b4f00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000142cb2b4f00] profile High, level 2.2, 4:2:0, 8-bit
[libx264 @ 00000142cb2b4f00] 264 - core 161 r3018 db0d417 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=15 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, hls, to 'C:\Users\Wuast\streaming.m3u8':
  Metadata:
    title           : Live stream from iOS
    encoder         : Lavf58.62.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 640x480, q=-1--1, 15 fps, 90k tbn, 15 tbc
    Metadata:
      encoder         : Lavc58.111.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A

I Opend the generated files without any issue

blakeblackshear commented 4 years ago

OpenCV is complaining that your frame does not have the right number of channels. I'm not sure why.

blakeblackshear commented 4 years ago

Are you still seeing this with 0.7.3?

RealKanashii commented 4 years ago

I'm not sure but In my case I can connect to my cam with only the IP: rtsp://xxxxxx:xxxxxx$@192.168.2.47:554 with VLC.

But to use with frigate I define the stream channel I want to use as there are 2 possible streams with different resolutions and frames: rtsp://xxxxxx:xxxxxx@192.168.2.47:554/h264Preview_01_main ( 4k 30fps) rtsp://xxxxxx:xxxxxx@192.168.2.47:554/h264Preview_01_sub (set to 640x480 10fps)

@wuast94 Have you two different streams on you cam?

Also I define the exact resolution in the config file.

wuast94 commented 4 years ago

@blakeblackshear so i am on blakeblackshear/frigate:stable-amd64, when this is version 0.7.3 than i still have this error

@RealKanashii testet this .. i checked if i had the same url as you and i connect to it with vlc too, changed the config and still the same error

EDIT: Sry for late reply .. i am a bit busy atm

blakeblackshear commented 4 years ago

What iPhone app are you using?

wuast94 commented 4 years ago

https://apps.apple.com/de/app/ip4k-phone-als-ip-kamera/id1448959807

I think its the app that isnt implemented rtsp right .. will retest it with a webcam on linux .. there should be an app for that :D