Video stream not starting or having a huge delay and low frame rate in the Home app
**Describe The Problem:**
I'm running Octoprint and Homebridge in separate docker containers on a Raspberry Pi 3 Model B and I have got a HD camera connected to the Pi. While Octoprint manages to provide a video stream in 1920*1080/30 FPS, I'm struggling to integrate this stream into the Home app using the homebridge-camera-ffmpeg for Homebridge. This might be related to the CPU power available I'm afraid, but searching the web I've found many other post describing similar issues, but no solution so far.

The copy codec did not work - the stream did not even start in the Home app. This is probably related to resolution/frame rate conflicts, because each iOS devices might request different solutions while Octoprint only provides the configured one (1920*1080/30FPS). So I went for the default option libx264 and set all parameters to "whatever Homekit requests".  This way there's started a stream in the Home app, but only with a very low resolution (or high compression artifacts?) and a delay of 15-30 seconds - at around 3 FPS. Still - according to Homebridge the CPU load is around 40% only (though top shows a FFmpeg process slightly above 100% load).
 
I've tried a lot of other configuration combinations (Octoprint/Homebridge/homebridge-camera-ffmpeg) but they all ended up in either the stream not starting or having a huge delay and very low frame rate in the Home app. Snapshots work fine by the way and are updated around every 10 seconds.

**To Reproduce:**
High level steps:
* install Octoprint and Homebridge on a RaspberryPi 3 Model B via docker-compose
* connect a HD USB Webcam (I use Tecknet TK-CA001)
* install homebridge-camera-ffmpeg for Homebridge based on the video stream provided by Octoprint
* start stream in the Home app and stop it a couple of seconds later to get a log like below

**Logs:**
Excerpt from Homebridge log upon starting a stream in the Home app and stopping it a few seconds later:
```
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] Video stream requested: 1280 x 720, 30 fps, 299 kbps
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] Starting video stream: 1280 x 720, 30 fps, 299 kbps
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] Stream command: /homebridge/node_modules/homebridge-camera-ffmpeg/node_modules/ffmpeg-for-homebridge/ffmpeg -i http://raspberrypi/webcam/?action=stream -an -sn -dn -codec:v libx264 -pix_fmt yuv420p -color_range mpeg -r 30 -f rawvideo -preset ultrafast -tune zerolatency -filter:v scale='min(1280,iw)':'min(720,ih)':force_original_aspect_ratio=decrease,scale=trunc(iw/2)*2:trunc(ih/2)*2 -b:v 299k -payload_type 99 -ssrc 15269903 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params vUR7hcviNYr1RZEp3WZW0iRvbTCQwHsCYI6dQWU+ srtp://192.168.178.43:52144?rtcpport=52144&pkt_size=1316 -loglevel level+verbose -progress pipe:1
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info] ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   built with gcc 9.3.0 (Alpine 9.3.0)
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   configuration: --pkgconfigdir=/build/workspace/lib/pkgconfig --prefix=/build/workspace --pkg-config-flags=--static --extra-cflags=-I/build/workspace/include --extra-ldflags=-L/build/workspace/lib --extra-libs='-lpthread -lm' --enable-static --disable-debug --disable-shared --disable-ffplay --disable-doc --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-runtime-cpudetect --enable-libfdk-aac --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-libspeex --enable-demuxer=rtsp --enable-indev=alsa --enable-outdev=alsa
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libavutil      56. 51.100 / 56. 51.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libavcodec     58. 91.100 / 58. 91.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libavformat    58. 45.100 / 58. 45.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libavdevice    58. 10.100 / 58. 10.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libavfilter     7. 85.100 /  7. 85.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libswscale      5.  7.100 /  5.  7.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libswresample   3.  7.100 /  3.  7.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   libpostproc    55.  7.100 / 55.  7.100
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [tcp @ 0x76f2a710] [verbose] Starting connection attempt to 127.0.1.1 port 80
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [tcp @ 0x76f2a710] [verbose] Successfully connected to 127.0.1.1 port 80
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info] Input #0, mpjpeg, from 'http://raspberrypi/webcam/?action=stream':
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   Duration: N/A, bitrate: N/A
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]     Stream #0:0: Video: mjpeg (Baseline), 1 reference frame, yuvj420p(pc, bt470bg/unknown/unknown, center), 1920x1080, 25 tbr, 25 tbn, 25 tbc
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info] Stream mapping:
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info]   Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [info] Press [q] to stop, [?] for help
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [Parsed_scale_0 @ 0x492ee00] [verbose] w:min(1280,iw) h:min(720,ih) flags:'bicubic' interl:0
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [Parsed_scale_1 @ 0x492eb10] [verbose] w:trunc(iw/2)*2 h:trunc(ih/2)*2 flags:'bicubic' interl:0
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [graph 0 input from stream 0:0 @ 0x48f6c30] [verbose] w:1920 h:1080 pixfmt:yuvj420p tb:1/25 fr:25/1 sar:0/1
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [swscaler @ 0x492f000] [warning] deprecated pixel format used, make sure you did set range correctly
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [Parsed_scale_0 @ 0x492ee00] [verbose] w:1920 h:1080 fmt:yuvj420p sar:0/1 -> w:1280 h:720 fmt:yuvj420p sar:0/1 flags:0x4
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [swscaler @ 0x4962f80] [warning] deprecated pixel format used, make sure you did set range correctly
[10/3/2021, 12:03:56 PM] [Camera FFmpeg] [3D-Drucker] [Parsed_scale_1 @ 0x492eb10] [verbose] w:1280 h:720 fmt:yuvj420p sar:0/1 -> w:1280 h:720 fmt:yuv420p sar:0/1 flags:0x4
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] using cpu capabilities: ARMv6 NEON
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] profile Constrained Baseline, level 3.1, 4:2:0, 8-bit
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info] Output #0, rtp, to 'srtp://192.168.178.43:52144?rtcpport=52144&pkt_size=1316':
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]   Metadata:
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]     encoder         : Lavf58.45.100
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]     Stream #0:0: Video: h264 (libx264), 1 reference frame, yuv420p(tv, center), 1280x720, q=-1--1, 299 kb/s, 30 fps, 90k tbn, 30 tbc
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]     Metadata:
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]       encoder         : Lavc58.91.100 libx264
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]     Side data:
[10/3/2021, 12:03:57 PM] [Camera FFmpeg] [3D-Drucker] [info]       cpb: bitrate max/min/avg: 0/0/299000 buffer size: 0 vbv_delay: N/A
[10/3/2021, 12:03:58 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=    2 fps=0.0 q=54.0 size=       5kB time=00:00:00.03 bitrate=1334.7kbits/s speed=0.0379x    
[10/3/2021, 12:03:58 PM] [Camera FFmpeg] [3D-Drucker] Getting the first frames took 1.625 seconds.
[10/3/2021, 12:03:58 PM] [Camera FFmpeg] [3D-Drucker] [verbose] *** 1 dup!
[10/3/2021, 12:03:58 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=    4 fps=2.7 q=48.0 size=       7kB time=00:00:00.10 bitrate= 541.9kbits/s dup=1 drop=0 speed=0.0672x    
[10/3/2021, 12:03:59 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=    6 fps=2.7 q=45.0 size=       8kB time=00:00:00.16 bitrate= 396.1kbits/s dup=1 drop=0 speed=0.074x    
[10/3/2021, 12:03:59 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=    8 fps=2.7 q=47.0 size=      10kB time=00:00:00.23 bitrate= 364.6kbits/s dup=1 drop=0 speed=0.0792x    
[10/3/2021, 12:04:00 PM] [Camera FFmpeg] [3D-Drucker] [verbose] *** 1 dup!
[10/3/2021, 12:04:00 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   11 fps=3.2 q=46.0 size=      13kB time=00:00:00.33 bitrate= 316.2kbits/s dup=2 drop=0 speed=0.0958x    
[10/3/2021, 12:04:01 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   13 fps=3.0 q=44.0 size=      15kB time=00:00:00.40 bitrate= 307.3kbits/s dup=2 drop=0 speed=0.0921x    
[10/3/2021, 12:04:01 PM] [Camera FFmpeg] [3D-Drucker] Received request to reconfigure: 640 x 360, 30 fps, 132 kbps (Ignored)
[10/3/2021, 12:04:02 PM] [Camera FFmpeg] [3D-Drucker] [verbose] *** 1 dup!
[10/3/2021, 12:04:02 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   16 fps=3.2 q=44.0 size=      18kB time=00:00:00.50 bitrate= 301.5kbits/s dup=3 drop=0 speed=0.0995x    
[10/3/2021, 12:04:02 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   17 fps=3.0 q=45.0 size=      20kB time=00:00:00.53 bitrate= 301.6kbits/s dup=3 drop=0 speed=0.094x    
[10/3/2021, 12:04:03 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   18 fps=2.9 q=46.0 size=      21kB time=00:00:00.56 bitrate= 300.2kbits/s dup=3 drop=0 speed=0.0904x    
[10/3/2021, 12:04:04 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   20 fps=2.9 q=44.0 size=      23kB time=00:00:00.63 bitrate= 296.0kbits/s dup=3 drop=0 speed=0.0917x    
[10/3/2021, 12:04:04 PM] [Camera FFmpeg] [3D-Drucker] [verbose] *** 1 dup!
[10/3/2021, 12:04:04 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   22 fps=3.0 q=43.0 size=      25kB time=00:00:00.70 bitrate= 294.4kbits/s dup=4 drop=0 speed=0.0943x    
[10/3/2021, 12:04:05 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   23 fps=2.9 q=45.0 size=      26kB time=00:00:00.73 bitrate= 293.7kbits/s dup=4 drop=0 speed=0.0909x    
[10/3/2021, 12:04:05 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   24 fps=2.8 q=46.0 size=      27kB time=00:00:00.76 bitrate= 292.5kbits/s dup=4 drop=0 speed=0.0888x    
[10/3/2021, 12:04:06 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   25 fps=2.7 q=46.0 size=      28kB time=00:00:00.80 bitrate= 291.1kbits/s dup=4 drop=0 speed=0.0869x    
[10/3/2021, 12:04:06 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   26 fps=2.7 q=46.0 size=      30kB time=00:00:00.83 bitrate= 290.0kbits/s dup=4 drop=0 speed=0.0858x    
[10/3/2021, 12:04:07 PM] [Camera FFmpeg] [3D-Drucker] [verbose] *** 1 dup!
[10/3/2021, 12:04:07 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   29 fps=2.8 q=44.0 size=      34kB time=00:00:00.93 bitrate= 297.6kbits/s dup=5 drop=0 speed=0.0898x    
[10/3/2021, 12:04:08 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   30 fps=2.7 q=45.0 size=      35kB time=00:00:00.96 bitrate= 296.9kbits/s dup=5 drop=0 speed=0.0882x    
[10/3/2021, 12:04:08 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   31 fps=2.7 q=46.0 size=      36kB time=00:00:01.00 bitrate= 296.0kbits/s dup=5 drop=0 speed=0.0865x    
[10/3/2021, 12:04:09 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   32 fps=2.6 q=46.0 size=      37kB time=00:00:01.03 bitrate= 294.6kbits/s dup=5 drop=0 speed=0.0852x    
[10/3/2021, 12:04:09 PM] [Camera FFmpeg] [3D-Drucker] [verbose] *** 1 dup!
[10/3/2021, 12:04:09 PM] [Camera FFmpeg] [3D-Drucker] Stopped video stream.
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   35 fps=2.7 q=41.0 size=      40kB time=00:00:01.13 bitrate= 290.4kbits/s dup=6 drop=0 speed=0.0875x    
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [info] frame=   35 fps=2.6 q=41.0 Lsize=      40kB time=00:00:01.13 bitrate= 290.4kbits/s dup=6 drop=0 speed=0.0849x    
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [AVIOContext @ 0x291ac30] [verbose] Statistics: 0 seeks, 21 writeouts
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [info] video:40kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.076061%
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [verbose] Input file #0 (http://raspberrypi/webcam/?action=stream):
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [verbose]   Input stream #0:0 (video): 29 packets read (6619404 bytes); 29 frames decoded; 
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [verbose]   Total: 29 packets (6619404 bytes) demuxed
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [verbose] Output file #0 (srtp://192.168.178.43:52144?rtcpport=52144&pkt_size=1316):
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [verbose]   Output stream #0:0 (video): 35 frames encoded; 35 packets muxed (40704 bytes); 
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [verbose]   Total: 35 packets (40704 bytes) muxed
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [AVIOContext @ 0x492be00] [verbose] Statistics: 0 seeks, 45 writeouts
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] frame I:1     Avg QP:47.00  size:  5416
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] frame P:34    Avg QP:45.56  size:  1038
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] mb I  I16..4: 100.0%  0.0%  0.0%
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] mb P  I16..4:  7.4%  0.0%  0.0%  P16..4:  5.5%  0.0%  0.0%  0.0%  0.0%    skip:87.0%
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] final ratefactor: 42.75
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] coded y,uvDC,uvAC intra: 0.5% 38.5% 0.2% inter: 0.1% 5.6% 0.0%
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] i16 v,h,dc,p: 86%  7%  6%  1%
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] i8c dc,h,v,p: 86%  8%  6%  0%
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [libx264 @ 0x490a150] [info] kb/s:279.11
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] [AVIOContext @ 0x76f2a7e0] [verbose] Statistics: 6622360 bytes read, 0 seeks
[10/3/2021, 12:04:10 PM] [Camera FFmpeg] [3D-Drucker] FFmpeg exited with code: 0 and signal: null (Expected)
```

**Homebridge Config:**
```
{
    "bridge": {
        "name": "Homebridge",
        "username": "XX:XX:XX:XX:XX:XX",
        "port": 52216,
        "pin": "XXX-XX-XXX"
    },
    "accessories": [
        {
            "name": "Anycubic I3 Mega S",
            "server": "http://raspberrypi",
            "api_key": "XXX",
            "accessory": "Octoprint-Temp"
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "instances": [
                {
                    "name": "Anycubic I3 Mega S",
                    "manufacturer": "Anycubic",
                    "model": "I3 Mega S",
                    "url": "http://raspberrypi",
                    "api_key": "XXX",
                    "occupancy_sensor": true
                }
            ],
            "name": "Octoprint Motion",
            "platform": "octoprint"
        },
        {
            "name": "Camera FFmpeg",
            "cameras": [
                {
                    "name": "3D-Drucker",
                    "manufacturer": "Tecknet",
                    "model": "TK-CA001",
                    "serialNumber": "XXX",
                    "unbridge": true,
                    "videoConfig": {
                        "source": "-i http://raspberrypi/webcam/?action=stream",
                        "stillImageSource": "-i http://raspberrypi/webcam/?action=snapshot",
                        "maxStreams": 2,
                        "forceMax": false,
                        "vcodec": "libx264",
                        "audio": false,
                        "debug": true
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        }
    ]
}
```

**Screenshots:**
Not applicable.

**Environment:**

* **Node.js Version**: 14.17.6
* **NPM Version**: 6.14.15
* **Homebridge Version**: 1.3.4
* **Homebridge Camera FFmpeg Version**: 3.1.3
* **Homebridge Config UI X Plugin Version**: 4.41.2
* **Operating System**: Docker


