Synology NAS and docker-homebridge: Camera stream doesn't work on LAN but works on WAN while using homebridge-simplisafe3
Hi everyone,

I have been using the [homebridge-simplisafe3](https://github.com/nzapponi/homebridge-simplisafe3) plugin for my security system. The system supports cameras, and the guys working on the module made some pretty good progress to implement the new HomeKit Camera API. However, since the beginning (even with the old camera API) one big issue with it is that, once it runs with docker, the cameras don't stream when connected via a LAN client. Outside the network it works fine. When it is installed native on a Raspberry, it works just fine on WAN and LAN.

The app completely starts the stream and works, and terminates correctly. It just can't communicate while I am in the LAN. However, the HomeKit hub is also on the LAN. It doesn't have an issue connecting to and streaming outside of the network via the hub. It is a weird problem.

It is also in the known issues part of the readme file. I did some diagnosing but can't figure out where the issue is coming from. Things I have tested and none made a difference so far:
1) Disable all firewalls.
2) Change some ffmpeg parameters.
3) Investigated network settings for docker, it is sharing the host network, can't change it.
4) Tried adding ports for forwarding, but obviously disabled because of item 3.
5) Upgraded docker-homebridge to the latest version.
6) Contacted the developer, and helooked into it, he seems to think it is related to docker and the way network is set-up. He is able to replicate the problem in a docker container.

**Logs:**
**1) When I am connected via WAN.**
[37m[10/26/2019, 6:27:06 PM][39m [36m[Home Alarm][39m Start streaming video from Office
[37m[10/26/2019, 6:27:06 PM][39m [36m[Home Alarm][39m ffmpeg version N-47683-g0e8eb07980-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 42.100 / 58. 42.100
  libavformat    58. 24.100 / 58. 24.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100

[37m[10/26/2019, 6:27:06 PM][39m [36m[Home Alarm][39m [https @ 0x571ea80] 
[37m[10/26/2019, 6:27:06 PM][39m [36m[Home Alarm][39m No trailing CRLF found in HTTP header.

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m Input #0, flv, from 'https://52.2.241.141/v1/xxxxxxxxxxxxxxx/flv?x=640':
  Duration: N/A, start: 0.000000, bitrate: N/A

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m     Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 20 fps, 20 tbr, 1k tbn, 40 tbc
    Stream #0:1: Audio: speex, 16000 Hz, mono, s16, 3 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #1:0 (speex (libspeex) -> opus (libopus))
Press [q] to stop, [?] for help

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m Output #1, rtp, to 'srtp://192.168.1.74:57129?rtcpport=57129&localrtcpport=57129&pkt_size=1316':
  Metadata:
    encoder         : Lavf58.24.100

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m     Stream #1:0: Audio: opus (libopus), 16000 Hz, mono, s16, 24 kb/s
    Metadata:
      encoder         : Lavc58.42.100 libopus

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m [swscaler @ 0x5dc2940] deprecated pixel format used, make sure you did set range correctly

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m [libx264 @ 0x5aceb40] using SAR=1/1

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m [libx264 @ 0x5aceb40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m [libx264 @ 0x5aceb40] profile High, level 2.2, 4:2:0, 8-bit

[37m[10/26/2019, 6:27:11 PM][39m [36m[Home Alarm][39m Output #0, rtp, to 'srtp://192.168.1.74:65369?rtcpport=65369&localrtcpport=65369&pkt_size=1316':
  Metadata:
    encoder         : Lavf58.24.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 132 kb/s, 20 fps, 90k tbn, 20 tbc
    Metadata:
      encoder         : Lavc58.42.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 132000/0/132000 buffer size: 132000 vbv_delay: -1

[37m[10/26/2019, 6:27:12 PM][39m [36m[Home Alarm][39m frame=    6 fps=0.0 q=34.0 size=       7kB time=00:00:00.48 bitrate= 123.8kbits/s speed=0.963x    
[37m[10/26/2019, 6:27:12 PM][39m [36m[Home Alarm][39m frame=   16 fps= 16 q=30.0 size=      14kB time=00:00:00.98 bitrate= 112.9kbits/s speed=0.978x    
[37m[10/26/2019, 6:27:13 PM][39m [36m[Home Alarm][39m frame=   26 fps= 17 q=28.0 size=      20kB time=00:00:01.52 bitrate= 107.1kbits/s speed=1.01x    
[37m[10/26/2019, 6:27:13 PM][39m [36m[Home Alarm][39m frame=   36 fps= 18 q=21.0 size=      26kB time=00:00:02.02 bitrate= 105.7kbits/s speed=   1x    
[37m[10/26/2019, 6:27:14 PM][39m [36m[Home Alarm][39m frame=   46 fps= 18 q=23.0 size=      32kB time=00:00:02.52 bitrate= 104.1kbits/s speed=   1x    
[37m[10/26/2019, 6:27:14 PM][39m [36m[Home Alarm][39m frame=   56 fps= 18 q=19.0 size=      38kB time=00:00:03.04 bitrate= 102.1kbits/s speed=   1x    
[37m[10/26/2019, 6:27:15 PM][39m [36m[Home Alarm][39m frame=   66 fps= 19 q=18.0 size=      44kB time=00:00:03.54 bitrate= 100.8kbits/s speed=   1x    
[37m[10/26/2019, 6:27:15 PM][39m [36m[Home Alarm][39m frame=   76 fps= 19 q=17.0 size=      50kB time=00:00:04.04 bitrate= 100.5kbits/s speed=   1x    
[37m[10/26/2019, 6:27:16 PM][39m [36m[Home Alarm][39m frame=   86 fps= 19 q=21.0 size=      56kB time=00:00:04.54 bitrate= 101.6kbits/s speed=0.999x    
[37m[10/26/2019, 6:27:16 PM][39m [36m[Home Alarm][39m frame=   96 fps= 19 q=16.0 size=      63kB time=00:00:05.04 bitrate= 101.6kbits/s speed=0.999x    
[37m[10/26/2019, 6:27:17 PM][39m [36m[Home Alarm][39m frame=  106 fps= 19 q=17.0 size=      69kB time=00:00:05.56 bitrate= 101.3kbits/s speed=   1x    

video:127kB audio:23kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

[37m[10/26/2019, 6:27:21 PM][39m [36m[Home Alarm][39m [libx264 @ 0x5aceb40] frame I:1     Avg QP:35.65  size:  4428
[libx264 @ 0x5aceb40] frame P:187   Avg QP:18.04  size:   674
[libx264 @ 0x5aceb40] mb I  I16..4: 56.5% 39.7%  3.8%

[37m[10/26/2019, 6:27:21 PM][39m [36m[Home Alarm][39m [libx264 @ 0x5aceb40] mb P  I16..4:  0.7%  0.2%  0.0%  P16..4:  9.5%  0.0%  0.0%  0.0%  0.0%    skip:89.6%
[libx264 @ 0x5aceb40] 8x8 transform intra:27.8% inter:22.2%
[libx264 @ 0x5aceb40] coded y,uvDC,uvAC intra: 23.4% 28.0% 8.9% inter: 3.1% 2.5% 0.1%
[libx264 @ 0x5aceb40] i16 v,h,dc,p: 76%  8% 13%  3%
[libx264 @ 0x5aceb40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 10% 38%  5%  3%  5%  5%  3%  4%
[libx264 @ 0x5aceb40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46%  8% 32%  2%  2%  2%  5%  1%  3%
[libx264 @ 0x5aceb40] i8c dc,h,v,p: 74%  8% 17%  2%
[libx264 @ 0x5aceb40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x5aceb40] kb/s:110.99

[37m[10/26/2019, 6:27:21 PM][39m [36m[Home Alarm][39m Exiting normally, received signal 15.

[37m[10/26/2019, 6:27:21 PM][39m [36m[Home Alarm][39m Stopped streaming

**2. When I am connected via LAN**

**The only difference I noticed is the IP address of the target. Previously it streamed to the HomeKit Hub (which is the IP address for the Apple TV). Now the output stream goes directly to the iPhone with the new IP. Don't mind the port number change because it changes everytime the stream is requrested. Didn't change because of WAN/LAN.**

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m Input #0, flv, from 'https://52.2.241.141/v1/xxxxxxxxxxxxxxx/flv?x=1280':
  Duration: N/A, start: 0.000000, bitrate: N/A

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m     Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 20 fps, 20 tbr, 1k tbn, 40 tbc
    Stream #0:1: Audio: speex, 16000 Hz, mono, s16, 35 kb/s

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m Stream mapping:

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m   Stream #0:0 -> #0:0
[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m  (h264 (native) -> h264 (libx264))
[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m 

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m   Stream #0:1 -> #1:0
[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m  (speex (libspeex) -> opus (libopus))
[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m 

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m Press [q] to stop, [?] for help

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m Output #1, rtp, to 'srtp://192.168.1.199:52722?rtcpport=52722&localrtcpport=52722&pkt_size=1316':
  Metadata:
    encoder         : Lavf58.24.100

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m     Stream #1:0: Audio: opus (libopus), 16000 Hz, mono, s16, 24 kb/s
    Metadata:
      encoder         : Lavc58.42.100 libopus

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m [swscaler @ 0x6fb4280] deprecated pixel format used, make sure you did set range correctly

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m [libx264 @ 0x6c75c80] using SAR=1/1

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m [libx264 @ 0x6c75c80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m [libx264 @ 0x6c75c80] profile High, level 3.1, 4:2:0, 8-bit

[37m[10/27/2019, 12:38:45 AM][39m [36m[Home Alarm][39m Output #0, rtp, to 'srtp://192.168.1.199:49610?rtcpport=49610&localrtcpport=49610&pkt_size=1316':
  Metadata:
    encoder         : Lavf58.24.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 284 kb/s, 20 fps, 90k tbn, 20 tbc
    Metadata:
      encoder         : Lavc58.42.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 284000/0/284000 buffer size: 284000 vbv_delay: -1

[37m[10/27/2019, 12:38:46 AM][39m [36m[Home Alarm][39m frame=    6 fps=0.0 q=40.0 size=      12kB time=00:00:00.47 bitrate= 212.0kbits/s speed=0.943x    
[37m[10/27/2019, 12:38:46 AM][39m [36m[Home Alarm][39m frame=   15 fps= 15 q=36.0 size=      24kB time=00:00:01.01 bitrate= 189.4kbits/s speed=1.01x    
[37m[10/27/2019, 12:38:47 AM][39m [36m[Home Alarm][39m frame=   26 fps= 17 q=37.0 size=      45kB time=00:00:01.51 bitrate= 241.2kbits/s speed=0.999x    
[37m[10/27/2019, 12:38:47 AM][39m [36m[Home Alarm][39m frame=   36 fps= 18 q=37.0 size=      63kB time=00:00:02.03 bitrate= 255.2kbits/s speed=1.01x    
[37m[10/27/2019, 12:38:48 AM][39m [36m[Home Alarm][39m frame=   47 fps= 19 q=37.0 size=      82kB time=00:00:02.51 bitrate= 265.9kbits/s speed=0.994x    
[37m[10/27/2019, 12:38:48 AM][39m [36m[Home Alarm][39m frame=   56 fps= 18 q=37.0 size=      98kB time=00:00:03.03 bitrate= 263.5kbits/s speed=   1x    
[37m[10/27/2019, 12:38:49 AM][39m [36m[Home Alarm][39m frame=   66 fps= 19 q=37.0 size=     115kB time=00:00:03.55 bitrate= 263.9kbits/s speed=   1x    
[37m[10/27/2019, 12:38:49 AM][39m [36m[Home Alarm][39m frame=   76 fps= 19 q=36.0 size=     130kB time=00:00:04.05 bitrate= 263.5kbits/s speed=   1x    
[37m[10/27/2019, 12:38:50 AM][39m [36m[Home Alarm][39m frame=   85 fps= 19 q=33.0 size=     144kB time=00:00:04.55 bitrate= 259.5kbits/s speed=   1x    
[37m[10/27/2019, 12:38:50 AM][39m [36m[Home Alarm][39m frame=   96 fps= 19 q=31.0 size=     158kB time=00:00:05.05 bitrate= 256.6kbits/s speed=0.999x    
[37m[10/27/2019, 12:38:51 AM][39m [36m[Home Alarm][39m frame=  107 fps= 19 q=28.0 size=     173kB time=00:00:05.55 bitrate= 255.6kbits/s speed=0.998x    
[37m[10/27/2019, 12:38:51 AM][39m [36m[Home Alarm][39m frame=  116 fps= 19 q=25.0 size=     183kB time=00:00:06.07 bitrate= 247.3kbits/s speed=   1x    
[37m[10/27/2019, 12:38:52 AM][39m [36m[Home Alarm][39m frame=  127 fps= 19 q=25.0 size=     197kB time=00:00:06.57 bitrate= 244.9kbits/s speed=0.998x    
[37m[10/27/2019, 12:38:52 AM][39m [36m[Home Alarm][39m frame=  137 fps= 19 q=23.0 size=     209kB time=00:00:07.09 bitrate= 240.8kbits/s speed=   1x    

[37m[10/27/2019, 12:39:12 AM][39m [36m[Home Alarm][39m [libx264 @ 0x6c75c80] frame I:3     Avg QP:26.64  size: 12109
[libx264 @ 0x6c75c80] frame P:532   Avg QP:20.98  size:  1594
[libx264 @ 0x6c75c80] mb I  I16..4: 61.0% 34.1%  4.9%
[libx264 @ 0x6c75c80] mb P  I16..4:  1.5%  1.2%  0.0%  P16..4:  7.6%  0.0%  0.0%  0.0%  0.0%    skip:89.7%

[37m[10/27/2019, 12:39:12 AM][39m [36m[Home Alarm][39m [libx264 @ 0x6c75c80] 8x8 transform intra:43.5% inter:13.8%
[libx264 @ 0x6c75c80] coded y,uvDC,uvAC intra: 21.1% 0.0% 0.0% inter: 2.2% 0.0% 0.0%
[libx264 @ 0x6c75c80] i16 v,h,dc,p: 49% 20% 25%  6%
[libx264 @ 0x6c75c80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 11% 33% 10%  3%  4%  3%  5%  7%
[libx264 @ 0x6c75c80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 13% 21%  4%  3%  5%  2%  4%  3%
[libx264 @ 0x6c75c80] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 0x6c75c80] Weighted P-Frames: Y:0.6% UV:0.0%
[libx264 @ 0x6c75c80] kb/s:264.42

[37m[10/27/2019, 12:39:12 AM][39m [36m[Home Alarm][39m Exiting normally, received signal 15.

--------------------

**Docker Start Command:**
Using the default.. Network is set as host.

* **Host Operating System**: Linux, Synology.
* **Docker Version**: 18.09.00-0506
