homebridge / docker-homebridge

Homebridge Docker. HomeKit support for the impatient using Docker on x86_64, Raspberry Pi (armhf) and ARM64. Includes ffmpeg + libfdk-aac.
https://hub.docker.com/r/homebridge/homebridge/
GNU General Public License v3.0
2.58k stars 242 forks source link

Synology (DSM 6.2.2-24922 Update 4) Homebridge on Docker - FFMPEG and Unifi Cameras #247

Closed jwebbstevens closed 4 years ago

jwebbstevens commented 5 years ago

Describe Your Problem: Love this build of Homebridge for Docker. It's brilliant. I've connected several services easily but like a lot of end users hit a wall when it comes to FFMPEG.

I installed FFMPEG directly in the Docker container. I added ffmpeg,ffmepg-libs to the Container environment variables, as well as the startup.sh using apt-get update apt-get install -y ffmpeg

Screen Shot 2019-11-15 at 11 26 07 AM

These are the principle error messages from the log

Invalid argument and ERROR: FFmepg exited with code1

[NULL @ 0x55b6a7744200] Unable to find a suitable output format for 're'
re: Invalid argument

[11/15/2019, 11:36:00 AM] [Camera-ffmpeg] ERROR: FFmpeg exited with code 1```

***No default whitelist***
```Opening an input file: rtsp://XXX.
[tcp @ 0x55b6a7565400] No default whitelist set```

**Logs:**
```[11/15/2019, 11:35:55 AM] [Camera-ffmpeg] Start streaming video from  Camera with 640x360@132kBit
ffmpeg re -rtsp_transport tcp -i rtsp://XXX/XXX -map 0:1 -vcodec h264_omx -pix_fmt yuv420p -r 20 -f rawvideo -preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0 -b:v 132k -bufsize 132k -maxrate 132k -payload_type 99 -ssrc 8293918 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params mhoVFUlUIaXzFnsX0I68VDktRGUjgk6vyOMGZ25p srtp://XXX
?rtcpportXXX&localrtcpportXXX&pkt_size=188 -map 0:0 -acodec libfdk_aac -profile:a aac_eld -flags +global_header -f null -ar 16k -b:a 24k -bufsize 24k -ac 1 -payload_type 110 -ssrc 10291758 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params tg/2oaLL9DGapaxNKxFuY+onrHNcgYH3t3fjd1f/ srtp://XXX?rtcpport=50290&localrtcpport=50290&pkt_size=188 -loglevel debug
ffmpeg version 3.2.14-1~deb9u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1' --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-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --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-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared

  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Splitting the commandline.
Reading option 're' ... matched as output url.
Reading option '-rtsp_transport' ...
 matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-i' ... matched as input url with argument 'rtsp://XXX'.
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_omx'.
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 '-preset' ...
 matched as AVOption 'preset' with argument 'slow'.
Reading option '-profile:v' ...
 matched as option 'profile' (set profile) with argument 'high'.
Reading option '-level' ...
 matched as AVOption 'level' with argument '4.2'.
Reading option '-x264-params' ...
 matched as AVOption 'x264-params' with argument 'intra-refresh=1:bframes=0'.
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 '8293918'.
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 'mhoVFUlUIaXzFnsX0I68VDktRGUjgk6vyOMGZ25p'.
Reading option 'srtp://XXX?rtcpportXXX&localrtcpportXXX&pkt_size=188' ... matched as output url.
Reading option '-map' ...
 matched as option 'map' (set input stream mapping) with argument '0:0'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'libfdk_aac'.
Reading option '-profile:a' ... matched as option 'profile' (set profile) with argument 'aac_eld'.
Reading option '-flags' ...
 matched as AVOption 'flags' with argument '+global_header'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.
Reading option '-ar' ...
 matched as option 'ar' (set audio sampling rate (in Hz)) with argument '16k'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '24k'.
Reading option '-bufsize' ...
 matched as AVOption 'bufsize' with argument '24k'.
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '1'.
Reading option '-payload_type' ...
 matched as AVOption 'payload_type' with argument '110'.
Reading option '-ssrc' ...
 matched as AVOption 'ssrc' with argument '10291758'.
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 'tg/2oaLL9DGapaxNKxFuY+onrHNcgYH3t3fjd1f/'.
Reading option 'srtp://XXX?rtcpport=50290&localrtcpport=50290&pkt_size=188' ... 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://XXX.
Successfully parsed a group of options.
Opening an input file: rtsp://XXX.
[tcp @ 0x55b6a7565400] No default whitelist set

[rtsp @ 0x55b6a75635c0] SDP:
v=0
o=- 607 0 IN IP4 XXX
s=FCECDA8FE837_1
u=www.evostream.com
e=contact@evostream.com
c=IN IP4 XXX
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 @ 0x55b6a75635c0] audio codec set to: aac
[rtsp @ 0x55b6a75635c0] audio samplerate set to: 44100
[rtsp @ 0x55b6a75635c0] audio channels set to: 1
[rtsp @ 0x55b6a75635c0] video codec set to: h264
[rtsp @ 0x55b6a75635c0] RTP Profile IDC: 4d Profile IOP: 40 Level: 1f
[rtsp @ 0x55b6a75635c0] RTP Packetization Mode: 1
[rtsp @ 0x55b6a75635c0] Extradata set to 0x55b6a756a2a0 (size: 36)

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

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

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

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

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

[h264 @ 0x55b6a7569e20] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x55b6a7569e20] nal_unit_type: 1, nal_ref_idc: 3

[h264 @ 0x55b6a7569e20] Reinit context to 1024x576, pix_fmt: yuvj420p
[h264 @ 0x55b6a7569e20] Frame num gap 15 13

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

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

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

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

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

    Last message repeated 5 times
[rtsp @ 0x55b6a75635c0] All info found
[rtsp @ 0x55b6a75635c0] rfps: 14.666667 0.016419

[rtsp @ 0x55b6a75635c0] rfps: 14.750000 0.009235
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 14.833333 0.004104
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 14.916667 0.001026
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 15.000000 0.000000
[rtsp @ 0x55b6a75635c0] rfps: 15.083333 0.001026
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 15.166667 0.004105
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 15.250000 0.009237
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 15.333333 0.016421
[rtsp @ 0x55b6a75635c0] rfps: 29.666667 0.016418
[rtsp @ 0x55b6a75635c0] rfps: 29.750000 0.009235
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 29.833333 0.004104
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 29.916667 0.001026
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 30.000000 0.000000
[rtsp @ 0x55b6a75635c0] rfps: 45.000000 0.000000
[rtsp @ 0x55b6a75635c0] rfps: 60.000000 0.000000
[rtsp @ 0x55b6a75635c0] rfps: 120.000000 0.000000
[rtsp @ 0x55b6a75635c0] rfps: 240.000000 0.000002
[rtsp @ 0x55b6a75635c0] rfps: 29.970030 0.000133
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 59.940060 0.000530
    Last message repeated 1 times
[rtsp @ 0x55b6a75635c0] rfps: 14.985015 0.000033

    Last message repeated 1 times
Input #0, rtsp, from 'rtsp://XXX':
  Metadata:
    title           : FCECDA8FE837_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 re.
Successfully parsed a group of options.
Opening an output file: re.
[NULL @ 0x55b6a7744200] Unable to find a suitable output format for 're'
re: Invalid argument

[11/15/2019, 11:36:00 AM] [Camera-ffmpeg] ERROR: FFmpeg exited with code 1```

Show the Docker container logs here


**Docker Start Command:**
Run this directly through UI of Synology Package.

docker run --net=host ...

Not sure what this means.


**Homebridge Config:**

```{
    "bridge": {
        "name": "Homebridge",
        "username": "0E:C5:BF:22:17:65",
        "port": 52327,
        "pin": "XXX-XX-XXX" ///masked for security purposes
    },
    "accessories": [],
    "platforms": [
        {
            "platform": "DysonPureCoolPlatform",
            "username": "XXXXXX",
            "password": "XXXXXX",
            "countryCode": "US",
            "devices": [
                {
                    "ipAddress": "XXX.XXX.XX.XX",
                    "serialNumber": "XXX-XX-XXXXXXXX",
                    "enableAutoModeWhenActivating": true,
                    "isNightModeEnabled": true,
                    "isJetFocusEnabled": true,
                    "isTemperatureSensorEnabled": false,
                    "isHumiditySensorEnabled": true,
                    "isAirQualitySensorEnabled": true
                }
            ]
        },
        {
            "name": "Camera-ffmpeg",
            "cameras": [
                {
                    "name": "Camera",
                    "manufacturer": "Ubiquiti Networks",
                    "model": "UVC-G3-MICRO",
                    "serialNumber": "XX:XX:XX:XX:XX:XX", ///masked for security purposes
                    "firmwareRevision": "4.14.14",
                    "videoConfig": {
                        "source": "re -rtsp_transport tcp -i rtsp://XXX.XXX.X.X:XXXX/XXXXXXXXXX", ///masked for security purposes
                        "stillImageSource": "-i http://XX.XXX.XX.X/snap.jpg", ///masked for security purposes
                        "maxStreams": 2,
                        "maxWidth": 1024,
                        "maxHeight": 486,
                        "maxFPS": 20,
                        "maxBitrate": 300,
                        "vcodec": "h264_omx",
                        "packetSize": 188,
                        "audio": false,
                        "debug": true,
                        "mapvideo": "0:1",
                        "mapaudio": "0:0"
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        }
    ]
}

Screenshots:

Error Screenshots

Screen Shot 2019-11-15 at 11 36 46 AM

Environment:

Synology DS918+ DSM Version DSM 6.2.2-24922 Update 4 Homebridge Version Version 0.4.50 Docker oznu/homebridge:debian

Homebridge was installed via the SPK package homebridge-syno-spk

This is the version of FFMPEG


  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516                                 
  configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/
usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-st
ripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-li
bass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libeb
ur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi -
-enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenm
pt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-l
ibsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-l
ibtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal 
--enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprin
t --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared                    
  libavutil      55. 34.101 / 55. 34.101                                                 
  libavcodec     57. 64.101 / 57. 64.101                                                 
  libavformat    57. 56.101 / 57. 56.101                                                 
  libavdevice    57.  1.100 / 57.  1.100                                                 
  libavfilter     6. 65.100 /  6. 65.100                                                 
  libavresample   3.  1.  0 /  3.  1.  0                                                 
  libswscale      4.  2.100 /  4.  2.100                                                 
  libswresample   2.  3.100 /  2.  3.100                                                 
  libpostproc    54.  1.100 / 54.  1.100                                                 
Hyper fast Audio and Video encoder                                                       
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...   

Use -h to get full help or, even better, run 'man ffmpeg'```
jwebbstevens commented 5 years ago

FWIW I'm happy to document over on the Wiki here or over on the repo homebridge-camera-ffmpeg/wiki the full setup of FFMPEG on a docker container since it seems cameras are one of the main reasons folks install homebridge and link un-supported homekit devices for. If anyone on this repo has any insight on my errors that would be awesome to share.

oznu commented 4 years ago

I think you're missing the - at the start of this line:

 "source": "re -rtsp_transport tcp -i rtsp://XXX.XXX.X.X:XXXX/XXXXXXXXXX",

Should be:

 "source": "-re -rtsp_transport tcp -i rtsp://XXX.XXX.X.X:XXXX/XXXXXXXXXX",
jwebbstevens commented 4 years ago

@oznu

Thank you. Great catch!

Unfortunately after fixing that I'm getting the following error.


[udp @ 0x5633a57e4340] No default whitelist set
[udp @ 0x5633a59f5620] No default whitelist set
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:1 @ 0x5633a59f5280] Setting 'video_size' to value '1024x576'
[graph 0 input from stream 0:1 @ 0x5633a59f5280] Setting 'pix_fmt' to value '12'
[graph 0 input from stream 0:1 @ 0x5633a59f5280] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:1 @ 0x5633a59f5280] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:1 @ 0x5633a59f5280] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:1 @ 0x5633a59f5280] Setting 'frame_rate' to value '15/1'
[graph 0 input from stream 0:1 @ 0x5633a59f5280] w:1024 h:576 pixfmt:yuvj420p tb:1/90000 fr:15/1 sar:1/1 sws_param:flags=2
[format @ 0x5633a59f3160] compat: called with args=[yuv420p]
[format @ 0x5633a59f3160] Setting 'pix_fmts' to value 'yuv420p'
[auto-inserted scaler 0 @ 0x5633a58131a0] Setting 'flags' to value 'bicubic'
[auto-inserted scaler 0 @ 0x5633a58131a0] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x5633a59f3160] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x5633a58377e0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[swscaler @ 0x5633a5934120] deprecated pixel format used, make sure you did set range correctly

[auto-inserted scaler 0 @ 0x5633a58131a0] w:1024 h:576 fmt:yuvj420p sar:1/1 -> w:1024 h:576 fmt:yuv420p sar:1/1 flags:0x4
[h264 @ 0x5633a57f4500] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x5633a57f4500] nal_unit_type: 8, nal_ref_idc: 3
**[h264_omx @ 0x5633a582dfe0] libOMX_Core.so not found**
**[h264_omx @ 0x5633a582dfe0] libOmxCore.so not found**
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> h264 (h264_omx))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[AVIOContext @ 0x5633a59f3560] Statistics: 0 seeks, 0 writeouts

[11/18/2019, 3:25:15 PM] [Camera-ffmpeg] ERROR: FFmpeg exited with code 1```
oznu commented 4 years ago

Remove this:

"vcodec": "h264_omx",
FlyersPh9 commented 4 years ago

FWIW I'm happy to document over on the Wiki here or over on the repo homebridge-camera-ffmpeg/wiki the full setup of FFMPEG on a docker container since it seems cameras are one of the main reasons folks install homebridge and link un-supported homekit devices for. If anyone on this repo has any insight on my errors that would be awesome to share.

Are you still willing to document the steps you took to enabling FFmpeg?

jwebbstevens commented 4 years ago

Oh yes @FlyersPh9 I forgot completely about this. I actually have to re-implement because I made some changes to my setup. It will probably take a bit but I'll post my use case and setup methodology here when I can.