beele / homebridge-unifi-protect-camera-motion

Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Apache License 2.0
103 stars 12 forks source link

Software installed, cameras are adopted into homekit, but video feed is 1 frame every 8 seconds #15

Closed nicgraner closed 4 years ago

nicgraner commented 4 years ago

Figured we had strayed too far off the topic of "it wont install" to warrant a new issue thread. Thanks again for your continued help :)


[2/13/2020, 1:57:25 PM] [Unifi protect cameras & motion sensors] Start streaming video from Stairs with 640x360@132kBit
ffmpeg -rtsp_transport tcp -re -i rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW -map 0:1 -vcodec h264 -pix_fmt yuv420p -r 20 -f rawvideo -protocol_whitelist https,crypto,srtp,rtp,udp,tcp -b:v 132k -bufsize 132k -maxrate 132k -payload_type 99 -ssrc 9050101 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params 5VKb15bTdvrcz40gBtuPMVEMk7iPMeflXordbI/G srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376 -loglevel debug
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared

  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Splitting the commandline.
Reading option '-rtsp_transport' ...
 matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:1'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264'.

Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '20'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-protocol_whitelist' ...
 matched as AVOption 'protocol_whitelist' with argument 'https,crypto,srtp,rtp,udp,tcp'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '132k'.
Reading option '-bufsize' ...
 matched as AVOption 'bufsize' with argument '132k'.
Reading option '-maxrate' ...
 matched as AVOption 'maxrate' with argument '132k'.
Reading option '-payload_type' ...
 matched as AVOption 'payload_type' with argument '99'.
Reading option '-ssrc' ...
 matched as AVOption 'ssrc' with argument '9050101'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rtp'.
Reading option '-srtp_out_suite' ...
 matched as AVOption 'srtp_out_suite' with argument 'AES_CM_128_HMAC_SHA1_80'.
Reading option '-srtp_out_params' ...
 matched as AVOption 'srtp_out_params' with argument '5VKb15bTdvrcz40gBtuPMVEMk7iPMeflXordbI/G'.
Reading option 'srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.

Parsing a group of options: input url rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW.
[tcp @ 0x565444acbde0] No default whitelist set

Motion events #: 0
Known accessories #: 5
[rtsp @ 0x565444ac9c80] SDP:
v=0
o=- 2713 0 IN IP4 10.11.12.10
s=FCECDAD845D1_1
u=www.evostream.com
e=contact@evostream.com
c=IN IP4 10.11.12.10
t=0 0
a=recvonly
a=control:*
a=range:npt=now-
m=audio 0 RTP/AVP 96
a=recvonly
a=rtpmap:96 mpeg4-generic/44100/1
a=control:trackID=1
a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=1208; SizeLength=13; IndexLength=3; IndexDeltaLength=3;
m=video 0 RTP/AVP 97
a=recvonly
a=control:trackID=2
a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=4d401f; packetization-mode=1; sprop-parameter-sets=Z01AH5pkAgAk/4C3AQEBQAAA+gAAHUwl,aO48gA==

[rtsp @ 0x565444ac9c80] audio codec set to: aac
[rtsp @ 0x565444ac9c80] audio samplerate set to: 44100
[rtsp @ 0x565444ac9c80] audio channels set to: 1
[rtsp @ 0x565444ac9c80] video codec set to: h264
[rtsp @ 0x565444ac9c80] RTP Profile IDC: 4d Profile IOP: 40 Level: 1f
[rtsp @ 0x565444ac9c80] RTP Packetization Mode: 1
[rtsp @ 0x565444ac9c80] Extradata set to 0x565444aa7250 (size: 36)

[rtsp @ 0x565444ac9c80] setting jitter buffer size to 0

    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] hello state=0

[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 1, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] Reinit context to 1024x576, pix_fmt: yuvj420p

[h264 @ 0x565444ad09e0] Frame num gap 13 11

[h264 @ 0x565444ad09e0] nal_unit_type: 1, nal_ref_idc: 3

    Last message repeated 1 times
[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 5, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 1, nal_ref_idc: 3

    Last message repeated 5 times
[rtsp @ 0x565444ac9c80] All info found
[rtsp @ 0x565444ac9c80] rfps: 14.666667 0.016418
[rtsp @ 0x565444ac9c80] rfps: 14.750000 0.009235
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] 
rfps: 14.833333 0.004104
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 14.916667 0.001026
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 15.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 15.083333 0.001027
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 15.166667 0.004106
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 15.250000 0.009238
[rtsp @ 0x565444ac9c80] rfps: 15.333333 0.016422
[rtsp @ 0x565444ac9c80] rfps: 29.666667 0.016416
[rtsp @ 0x565444ac9c80] rfps: 29.750000 0.009233
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 29.833333 0.004103
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 29.916667 0.001025
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 30.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 45.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 60.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 120.000000 0.000001
[rtsp @ 0x565444ac9c80] rfps: 240.000000 0.000002
[rtsp @ 0x565444ac9c80] rfps: 29.970030 0.000132
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 59.940060 0.000530
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 14.985015 0.000033

    Last message repeated 1 times
Input #0, rtsp, from 'rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW':
  Metadata:
    title           : FCECDAD845D1_1
  Duration: N/A, start: 0.000000, bitrate: N/A

    Stream #0:0, 88, 1/44100: Audio: aac (LC), 44100 Hz, mono, fltp
    Stream #0:1, 31, 1/90000: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1024x576 [SAR 1:1 DAR 16:9], 0/1, 15 fps, 15 tbr, 90k tbn, 30 tbc
Successfully opened the file.
Parsing a group of options: output url srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376.
Applying option map (set input stream mapping) with argument 0:1.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 20.
Applying option f (force format) with argument rawvideo.
Applying option b:v (video bitrate (please use -b:v)) with argument 132k.
Applying option f (force format) with argument rtp.
Successfully parsed a group of options.
Opening an output file: srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376.

Matched encoder 'libx264' for codec 'h264'.

Successfully opened the file.

detected 4 logical cores
[h264 @ 0x565444b07fe0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x565444b07fe0] nal_unit_type: 8, nal_ref_idc: 3

Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 346 times
[h264 @ 0x565444b07fe0] nal_unit_type: 7, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 225 times
[h264 @ 0x565444b07fe0] nal_unit_type: 8, nal_ref_idc: 3
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 257 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 174 times
[h264 @ 0x565444b07fe0] Reinit context to 1024x576, pix_fmt: yuvj420p
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 236 times
[h264 @ 0x565444b07fe0] Frame num gap 13 11
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 1206026 times
cur_dts is invalid (this is harmless if it occurs once at the start per stream)bits/s speed=N/A    

    Last message repeated 241903 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 4 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 4 times
[h264 @ 0x565444b24be0] nal_unit_type: 7, nal_ref_idc: 3

[h264 @ 0x565444b24be0] 
nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444b24be0] nal_unit_type: 5, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

[h264 @ 0x565444b20840] 
nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 2 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 6 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'video_size' to value '1024x576'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'pix_fmt' to value '12'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'time_base' to value '1/90000'

[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'frame_rate' to value '15/1'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] w:1024 h:576 pixfmt:yuvj420p tb:1/90000 fr:15/1 sar:1/1 sws_param:flags=2
[format @ 0x565444cf45e0] compat: called with args=[yuv420p]
[format @ 0x565444cf45e0] Setting 'pix_fmts' to value 'yuv420p'
[auto_scaler_0 @ 0x565444cef880] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x565444cef880] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x565444cf45e0] 
auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x565444c9a2a0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed

[swscaler @ 0x565444b92100] deprecated pixel format used, make sure you did set range correctly

[auto_scaler_0 @ 0x565444cef880] w:1024 h:576 fmt:yuvj420p sar:1/1 -> w:1024 h:576 fmt:yuv420p sar:1/1 flags:0x4

[libx264 @ 0x565444b07b20] using mv_range_thread = 40
[libx264 @ 0x565444b07b20] using SAR=1/1

[libx264 @ 0x565444b07b20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2

[libx264 @ 0x565444b07b20] profile High, level 3.1

Output #0, rtp, to 'srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376':
  Metadata:
    title           : FCECDAD845D1_1
    encoder         : Lavf57.83.100
    Stream #0:0, 0, 1/90000: Video: h264 (libx264), 1 reference frame, yuv420p(left), 1024x576 [SAR 1:1 DAR 16:9], 0/1, q=-1--1, 132 kb/s, 20 fps, 90k tbn, 20 tbc
    Metadata:

      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 132000/0/132000 buffer size: 132000 vbv_delay: -1
*** 4 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 4 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 14 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
cur_dts is invalid (this is harmless if it occurs once at the start per stream)op=0 speed=   0x    

    Last message repeated 2 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 13 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 14 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

Motion events #: 0
Known accessories #: 5
[2/13/2020, 1:57:31 PM] [Unifi protect cameras & motion sensors] Snapshot from Stairs at 480x270
ffmpeg -i http://10.11.12.169/snap.jpeg -t 1 -s 480x270 -f image2 -
    Last message repeated 16 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 8 times
cur_dts is invalid (this is harmless if it occurs once at the start per stream)op=0 speed=   0x    

    Last message repeated 3 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 18 times
[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 5 times
[libx264 @ 0x565444b07b20] frame=   0 QP=29.86 NAL=3 Slice:I Poc:0   I:2304 P:0    SKIP:0    size=12928 bytes

[rtp @ 0x565444b05460] Sending NAL 7 of len 26 M=0
[rtp @ 0x565444b05460] Sending NAL 8 of len 5 M=0
[rtp @ 0x565444b05460] Sending NAL 6 of len 755 M=0
[rtp @ 0x565444b05460] NAL size 755 > 350
[rtp @ 0x565444b05460] Sending NAL 5 of len 12128 M=1
[rtp @ 0x565444b05460] NAL size 12128 > 350

[libx264 @ 0x565444b07b20] frame=   1 QP=26.74 NAL=2 Slice:P Poc:8   I:9    P:121  SKIP:2174 size=198 bytes
[rtp @ 0x565444b05460] 
Sending NAL 1 of len 194 M=1

[libx264 @ 0x565444b07b20] frame=   2 QP=43.00 NAL=2 Slice:B Poc:4   I:0    P:3    SKIP:2301 size=29 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 25 M=1

[libx264 @ 0x565444b07b20] frame=   3 QP=45.00 NAL=0 Slice:B Poc:2   I:0    P:0    SKIP:2304 size=26 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1
[libx264 @ 0x565444b07b20] frame=   4 QP=45.00 NAL=0 Slice:B Poc:6   I:0    P:0    SKIP:2304 size=26 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1

[libx264 @ 0x565444b07b20] frame=   5 QP=24.59 NAL=2 Slice:P Poc:16  I:11   P:90   SKIP:2203 size=223 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 219 M=1

[libx264 @ 0x565444b07b20] frame=   6 QP=42.00 NAL=2 Slice:B Poc:12  I:0    P:3    SKIP:2301 size=32 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 28 M=1
[libx264 @ 0x565444b07b20] 
frame=   7 QP=47.00 NAL=0 Slice:B Poc:10  I:0    P:2    SKIP:2302 size=29 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 25 M=1

[libx264 @ 0x565444b07b20] frame=   8 QP=44.00 NAL=0 Slice:B Poc:14  I:0    P:0    SKIP:2304 size=26 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1

[libx264 @ 0x565444b07b20] frame=   9 QP=31.79 NAL=2 Slice:P Poc:24  I:7    P:127  SKIP:2170 size=433 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 429 M=1
[rtp @ 0x565444b05460] NAL size 429 > 350

[libx264 @ 0x565444b07b20] frame=  10 QP=40.00 NAL=2 Slice:B Poc:20  I:0    P:34   SKIP:2270 size=52 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 48 M=1

[libx264 @ 0x565444b07b20] frame=  11 QP=45.00 NAL=0 Slice:B Poc:18  I:0    P:14   SKIP:2290 size=41 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 37 M=1

[libx264 @ 0x565444b07b20] frame=  12 QP=42.00 NAL=0 Slice:B Poc:22  I:0    P:0    SKIP:2304 size=26 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1

[libx264 @ 0x565444b07b20] frame=  13 QP=27.84 NAL=2 Slice:P Poc:32  I:17   P:181  SKIP:2106 size=674 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 670 M=1
[rtp @ 0x565444b05460] NAL size 670 > 350

[libx264 @ 0x565444b07b20] frame=  14 QP=38.00 NAL=2 Slice:B Poc:28  I:0    P:41   SKIP:2263 size=53 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 49 M=1

[libx264 @ 0x565444b07b20] frame=  15 QP=43.00 NAL=0 Slice:B Poc:26  I:0    P:1    SKIP:2303 size=29 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 25 M=1

[libx264 @ 0x565444b07b20] frame=  16 QP=40.00 NAL=0 Slice:B Poc:30  I:0    P:2    SKIP:2302 size=28 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 24 M=1

[libx264 @ 0x565444b07b20] frame=  17 QP=28.02 NAL=2 Slice:P Poc:40  I:37   P:256  SKIP:2011 size=1045 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 1041 M=1
[rtp @ 0x565444b05460] NAL size 1041 > 350

[libx264 @ 0x565444b07b20] frame=  18 QP=36.00 NAL=2 Slice:B Poc:36  I:0    P:111  SKIP:2193 size=102 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 98 M=1

[libx264 @ 0x565444b07b20] frame=  19 QP=41.00 NAL=0 Slice:B Poc:34  I:0    P:44   SKIP:2260 size=63 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 59 M=1

[libx264 @ 0x565444b07b20] frame=  20 QP=38.00 NAL=0 Slice:B Poc:38  I:0    P:1    SKIP:2303 size=27 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 23 M=1

[libx264 @ 0x565444b07b20] frame=  21 QP=27.43 NAL=2 Slice:P Poc:48  I:25   P:250  SKIP:2029 size=1250 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 1246 M=1
[rtp @ 0x565444b05460] NAL size 1246 > 350

[libx264 @ 0x565444b07b20] frame=  22 QP=34.00 NAL=2 Slice:B Poc:44  I:0    P:166  SKIP:2138 size=133 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 129 M=1

[libx264 @ 0x565444b07b20] frame=  23 QP=39.00 NAL=0 Slice:B Poc:42  I:0    P:46   SKIP:2258 size=64 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 60 M=1

[libx264 @ 0x565444b07b20] frame=  24 QP=36.00 NAL=0 Slice:B Poc:46  I:0    P:6    SKIP:2298 size=30 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 26 M=1

[libx264 @ 0x565444b07b20] frame=  25 QP=26.44 NAL=2 Slice:P Poc:56  I:21   P:231  SKIP:2052 size=1224 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 1220 M=1
[rtp @ 0x565444b05460] NAL size 1220 > 350

[libx264 @ 0x565444b07b20] frame=  26 QP=35.00 NAL=2 Slice:B Poc:52  I:0    P:181  SKIP:2123 size=150 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 146 M=1

[libx264 @ 0x565444b07b20] frame=  27 QP=37.00 NAL=0 Slice:B Poc:50  I:0    P:128  SKIP:2176 size=117 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 113 M=1

[libx264 @ 0x565444b07b20] frame=  28 QP=34.00 NAL=0 Slice:B Poc:54  I:0    P:15   SKIP:2289 size=41 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 37 M=1

[libx264 @ 0x565444b07b20] frame=  29 QP=26.29 NAL=2 Slice:P Poc:58  I:22   P:207  SKIP:2075 size=1098 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 1094 M=1
[rtp @ 0x565444b05460] NAL size 1094 > 350

frame=   30 fps= 16 q=-1.0 Lsize=      21kB time=00:00:01.35 bitrate= 125.5kbits/s dup=10 drop=0 speed=0.707x    
video:20kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.857157%
Input file #0 (rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW):
  Input stream #0:0 (audio): 76 packets read (13524 bytes); 
  Input stream #0:1 (video): 27 packets read (49353 bytes); 21 frames decoded; 
  Total: 103 packets (62877 bytes) demuxed
Output file #0 (srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376):
  Output stream #0:0 (video): 30 frames encoded; 30 packets muxed (20197 bytes); 

  Total: 30 packets (20197 bytes) muxed

21 frames successfully decoded, 0 decoding errors

[AVIOContext @ 0x565444b27be0] Statistics: 0 seeks, 82 writeouts

[libx264 @ 0x565444b07b20] frame I:1     Avg QP:29.86  size: 12928
[libx264 @ 0x565444b07b20] frame P:8     Avg QP:27.39  size:   768
[libx264 @ 0x565444b07b20] frame B:21    Avg QP:40.19  size:    54
[libx264 @ 0x565444b07b20] consecutive B-frames:  6.7%  0.0%  0.0% 93.3%
[libx264 @ 0x565444b07b20] mb I  I16..4: 44.1% 46.0%  9.9%

[libx264 @ 0x565444b07b20] mb P  I16..4:  0.5%  0.3%  0.0%  P16..4:  6.3%  0.9%  0.7%  0.0%  0.0%    skip:91.3%
[libx264 @ 0x565444b07b20] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.6%  0.0%  0.0%  direct: 0.0%  skip:98.4%  L0: 2.9% L1:97.1% BI: 0.0%
[libx264 @ 0x565444b07b20] 8x8 transform intra:45.7% inter:47.0%
[libx264 @ 0x565444b07b20] coded y,uvDC,uvAC intra: 26.0% 28.6% 0.7% inter: 0.4% 0.5% 0.0%
[libx264 @ 0x565444b07b20] i16 v,h,dc,p: 40% 27% 11% 23%
[libx264 @ 0x565444b07b20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 18% 32%  4%  2%  3%  5%  2%  7%
[libx264 @ 0x565444b07b20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 21% 25%  5%  5%  7%  3%  2%  5%
[libx264 @ 0x565444b07b20] i8c dc,h,v,p: 73% 13% 14%  1%
[libx264 @ 0x565444b07b20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x565444b07b20] ref P L0: 88.5%  7.4%  3.2%  0.9%
[libx264 @ 0x565444b07b20] ref B L0: 91.3%  8.7%
[libx264 @ 0x565444b07b20] ref B L1: 84.3% 15.7%
[libx264 @ 0x565444b07b20] kb/s:107.72

Exiting normally, received signal 15.

[2/13/2020, 1:57:32 PM] [Unifi protect cameras & motion sensors] Stopped streaming

I've been troubleshooting for a few hours now and have gotten to the point where the software doesn't exit with FFMPEG errors, but on the iPhone or iPad (tried with iPhone X, 11, and iPad Pro 11" as well as iPad 7th generation) the video stream only changes frames every 8 seconds. Almost as if it's grabbing the anonymous snaps or something lol. I attached logs from opening the stream then killing it as soon as it showed live, because otherwise the logs don't go back far enough. At the beginning you can see the error in:

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

however this occurs thousands of times at the beginning it seems. I'm not sure where to look for errors here as im not well versed in ffmpeg, and my googling doesn't really do much since im not sure what to look for.

the config I have for the plugin is as follows:


{
            "platform": "Unifi-Protect-Camera-Motion",
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "controller": "https://10.11.12.10:7443",
                "controller_rtsp": "rtsp://10.11.12.10:7447",
                "username": "homebridge",
                "password": "homebridge",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": false,
                "enhanced_motion_score": 50,
                "enhanced_classes": [
                    "Person - or any other COCO classes, look in src/coco/classes.ts"
                ],
                "debug": true,
                "save_snapshot": true
            },
            "driveUpload": false,
            "videoConfig": {
                "vcodec": "h264",
                "audio": true,
                "acodec": "libopus",
                "maxStreams": 2,
                "maxWidth": 1024,
                "maxHeight": 576,
                "maxFPS": 30,
                "mapvideo": "0:1",
                "mapaudio": "0:0",
                "maxBitrate": 6000,
                "packetSize": 376,
                "debug": true,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp,tcp"
            },
            "plugin_map": {
                "plugin_name": "homebridge-unifi-protect-camera-motion"
            }
        }
nicgraner commented 4 years ago

Progress has been made! after watching a video over HOOBS camera FFMPEG, the video poster mentioned changing the vcodec from h264 to "vcodec": "copy", and this worked! we have reliable video feeds from all cameras other than one thats being stubborn and not wanting to show up. Im going to test notifications next, but it seems like we made a huge leap forward today!

beele commented 4 years ago

@nicgraner Good to hear you got it working. I'll try with the copy as well and see if it's useful to mention this in the documentation.

Did you get the notifications working?

nicgraner commented 4 years ago

Notifications seem to be hit or miss, haven't really been able to pinpoint an exact trigger to make it work consistently, maybe just need to lower the score or something, and audio seems to be broken when I use copy, not sure why. final settings to achieve streamed video is here;


{
            "platform": "Unifi-Protect-Camera-Motion",
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "controller": "https://10.11.12.10:7443",
                "controller_rtsp": "rtsp://10.11.12.10:7447",
                "username": "",
                "password": "",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": false,
                "enhanced_motion_score": 50,
                "enhanced_classes": [
                    "Person - or any other COCO classes, look in src/coco/classes.ts"
                ],
                "debug": true,
                "save_snapshot": true
            },
            "driveUpload": false,
            "videoConfig": {
                "vcodec": "copy",
                "audio": true,
                "acodec": "libopus",
                "maxStreams": 1,
                "maxWidth": 1280,
                "maxHeight": 720,
                "maxFPS": 30,
                "mapvideo": "0:1",
                "mapaudio": "0:0",
                "maxBitrate": 1500,
                "packetSize": 1376,
                "debug": true,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp,tcp"
            },
            "plugin_map": {
                "plugin_name": "homebridge-unifi-protect-camera-motion"
            }
        }

however youll notice that even with the audio codec set manually, I still don't get audio. Not sure whats causing that.

nicgraner commented 4 years ago

https://github.com/markus-perl/ffmpeg-build-script using this FFmpeg build script I was able to build FFMPEG and use this config to get everything working:


        {
            "platform": "Unifi-Protect-Camera-Motion",
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "controller": "https://10.11.12.149:7443",
                "controller_rtsp": "rtsp://10.11.12.149:7447",
                "username": "",
                "password": "",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 35,
                "enhanced_motion": false,
                "enhanced_motion_score": 35,
                "enhanced_classes": [
                    "Person - or any other COCO classes, look in src/coco/classes.ts"
                ],
                "debug": true,
                "save_snapshot": true
            },
            "driveUpload": false,
            "videoConfig": {
                "vcodec": "h264",
                "audio": true,
                "maxStreams": 2,
                "maxWidth": 1280,
                "maxHeight": 720,
                "maxFPS": 30,
                "mapvideo": "0:1",
                "mapaudio": "0:0",
                "maxBitrate": 1500,
                "packetSize": 752,
                "debug": "true"
            },
            "plugin_map": {
                "plugin_name": "homebridge-unifi-protect-camera-motion"
            }

gonna keep tweaking to see if I can improve, but now im just working on fine tuning the notifications, Tensorflow seems to error out saying its using more than 10% of ram, so I disabled the motion event stuff for now