Samfox2 / homebridge-videodoorbell

Video-Doorbell plugin based on homebridge-camera-ffmpeg for Homebridge.
Apache License 2.0
97 stars 17 forks source link

Video won't start to stream #17

Closed johan-de-jong closed 6 years ago

johan-de-jong commented 6 years ago

In the Apple Home app I correctly receive notifications and snapshots, but streaming won't start.

When I verify the specified rstp:// destinations in VLC streaming works just fine. The videodoorbell plugin adds a lot of parameters to each ffmpeg session to set up a video stream.

When I look at the logging it seems ffmpeg is complaining about some of the parameters.

Does anybody have any suggestions to resolve this issue?

    "platforms": [
        {
            "platform": "Video-doorbell",
            "videoProcessor": "/usr/local/bin/ffmpeg",
            "cameras": [
                {
                    "name": "IQeye IQD52W",
                    "port": 5005,
                    "button": false,
                    "videoConfig": {
                        "source": "-re -i rtsp://192.168.0.239/stream1",
                        "maxStreams": 2,
                        "audio": true,
                        "maxWidth": 1280,
                        "maxHeight": 1024,
                        "maxFPS": 30,
                        "debug": true
                    }
                },
                {
                    "name": "Ubiquity UniFi G3",
                    "port": 5006,
                    "videoConfig": {
                        "source": "-re -i rtsp://192.168.0.205/s0",
                        "maxStreams": 2,
                        "audio": true,
                        "maxWidth": 1280,
                        "maxHeight": 1024,
                        "maxFPS": 30,
                        "debug": true
                    }
                }
            ]
        },

Here's the logging where ffmpeg seems to complain:

apr 08 17:15:14 pi homebridge[23498]: Codec AVOption tune (Tune the encoding params (cf. x264 --fullhelp)) specified for output file #0 (srtp://1192.168.0.245:56766?rtcpport=56766&localrtcpport=56766&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (srtp://1192.168.0.245:56766?rtcpport=56766&localrtcpport=56766&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption b (set bitrate (in bits/s)) specified for output file #1 (srtp://1192.168.0.245:65168?rtcpport=65168&localrtcpport=65168&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption profile () specified for output file #1 (srtp://1192.168.0.245:65168?rtcpport=65168&localrtcpport=65168&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.

apr 08 17:15:14 pi homebridge[23498]: Finishing stream 1:0 without any data written to it.
apr 08 17:15:14 pi homebridge[23498]: [mpeg4 @ 0x30c9690] Either both buffer size and max rate or neither must be specified
apr 08 17:15:14 pi homebridge[23498]: Error initializing output stream 1:0 -- Error while opening encoder for output stream #1:0 - maybe incorrect parameters such as bit_rate, rate, width or height
apr 08 17:15:14 pi homebridge[23498]: Exiting normally, received signal 15.
apr 08 17:15:14 pi homebridge[23498]: [2018-4-8 17:15:14] [Video-doorbell] ERROR: FFmpeg exited with code 1

Here's all the logging:

apr 08 17:15:08 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.205/s0 -t 1 -s 480x270 -f image2 -
apr 08 17:15:08 pi homebridge[23498]: [2018-4-8 17:15:08] [Video-doorbell] Snapshot from IQeye IQD52W at 480x270
apr 08 17:15:08 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.239/stream1 -t 1 -s 480x270 -f image2 -
apr 08 17:15:12 pi homebridge[23498]: [2018-4-8 17:15:12] [Video-doorbell] Start streaming video from IQeye IQD52W with 640x360@132kBit
apr 08 17:15:12 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.239/stream1 -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 10 -f rawvideo -tune zerolatency -vf scale=640:360 -b:v 132k -bufsize 132k -payload_type 99 -ssrc 3647358 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params 8sju/UfwVjePSuMBivM/EKpe4D8/BIZZW/UocOth srtp://1192.168.0.245:56766?rtcpport=56766&localrtcpport=56766&pkt_size=1316 -map 0:1 -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 8783487 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params vWIVLjdj09gF3+LziJT2+AcEyZhmdPnjT0LZE+sS srtp://1192.168.0.245:65168?rtcpport=65168&localrtcpport=65168&pkt_size=1316
apr 08 17:15:12 pi homebridge[23498]: ffmpeg version N-90636-gc837918f50 Copyright (c) 2000-2018 the FFmpeg developers
apr 08 17:15:12 pi homebridge[23498]:   built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
apr 08 17:15:12 pi homebridge[23498]:   configuration: --prefix=/usr/local --arch=armel --target-os=linux --enable-omx-rpi --enable-nonfree --enable-gpl --enable-libfdk-aac --enable-mmal --enable-libx264 --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp
apr 08 17:15:12 pi homebridge[23498]:   libavutil      56. 13.100 / 56. 13.100
apr 08 17:15:12 pi homebridge[23498]:   libavcodec     58. 17.100 / 58. 17.100
apr 08 17:15:12 pi homebridge[23498]:   libavformat    58. 11.101 / 58. 11.101
apr 08 17:15:12 pi homebridge[23498]:   libavdevice    58.  2.100 / 58.  2.100
apr 08 17:15:12 pi homebridge[23498]:   libavfilter     7. 14.100 /  7. 14.100
apr 08 17:15:12 pi homebridge[23498]:   libswscale      5.  0.102 /  5.  0.102
apr 08 17:15:12 pi homebridge[23498]:   libswresample   3.  0.101 /  3.  0.101
apr 08 17:15:12 pi homebridge[23498]:   libpostproc    55.  0.100 / 55.  0.100
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 10 size 400 truncated at 24
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 310
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 310
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 310
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 310
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 310
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 310
apr 08 17:15:13 pi homebridge[23498]: [h264 @ 0x2f42620] SEI type 97 size 824 truncated at 336
apr 08 17:15:14 pi homebridge[23498]:     Last message repeated 4 times
apr 08 17:15:14 pi homebridge[23498]: Guessed Channel Layout for Input Stream #0.0 : mono
apr 08 17:15:14 pi homebridge[23498]: Input #0, rtsp, from 'rtsp://1192.168.0.239/stream1':
apr 08 17:15:14 pi homebridge[23498]:   Metadata:
apr 08 17:15:14 pi homebridge[23498]:     title           : Session streamed by IQStreamer
apr 08 17:15:14 pi homebridge[23498]:     comment         : unicast info here
apr 08 17:15:14 pi homebridge[23498]:   Duration: N/A, start: 0.000000, bitrate: N/A
apr 08 17:15:14 pi homebridge[23498]:     Stream #0:0: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
apr 08 17:15:14 pi homebridge[23498]:     Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 640x480 [SAR 360:271 DAR 480:271], 10 fps, 29.97 tbr, 90k tbn, 19.98 tbc
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption tune (Tune the encoding params (cf. x264 --fullhelp)) specified for output file #0 (srtp://1192.168.0.245:56766?rtcpport=56766&localrtcpport=56766&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (srtp://1192.168.0.245:56766?rtcpport=56766&localrtcpport=56766&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption b (set bitrate (in bits/s)) specified for output file #1 (srtp://1192.168.0.245:65168?rtcpport=65168&localrtcpport=65168&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Codec AVOption profile () specified for output file #1 (srtp://1192.168.0.245:65168?rtcpport=65168&localrtcpport=65168&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
apr 08 17:15:14 pi homebridge[23498]: Stream mapping:
apr 08 17:15:14 pi homebridge[23498]:   Stream #0:0 -> #0:0 (pcm_mulaw (native) -> pcm_mulaw (native))
apr 08 17:15:14 pi homebridge[23498]:   Stream #0:1 -> #1:0 (h264 (native) -> mpeg4 (native))
apr 08 17:15:14 pi homebridge[23498]: Press [q] to stop, [?] for help
apr 08 17:15:14 pi homebridge[23498]: Finishing stream 0:0 without any data written to it.
apr 08 17:15:14 pi homebridge[23498]: Output #0, rtp, to 'srtp://1192.168.0.245:56766?rtcpport=56766&localrtcpport=56766&pkt_size=1316':
apr 08 17:15:14 pi homebridge[23498]:   Metadata:
apr 08 17:15:14 pi homebridge[23498]:     title           : Session streamed by IQStreamer
apr 08 17:15:14 pi homebridge[23498]:     comment         : unicast info here
apr 08 17:15:14 pi homebridge[23498]:     encoder         : Lavf58.11.101
apr 08 17:15:14 pi homebridge[23498]:     Stream #0:0: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
apr 08 17:15:14 pi homebridge[23498]:     Metadata:
apr 08 17:15:14 pi homebridge[23498]:       encoder         : Lavc58.17.100 pcm_mulaw
apr 08 17:15:14 pi homebridge[23498]: Finishing stream 1:0 without any data written to it.
apr 08 17:15:14 pi homebridge[23498]: [mpeg4 @ 0x30c9690] Either both buffer size and max rate or neither must be specified
apr 08 17:15:14 pi homebridge[23498]: Error initializing output stream 1:0 -- Error while opening encoder for output stream #1:0 - maybe incorrect parameters such as bit_rate, rate, width or height
apr 08 17:15:14 pi homebridge[23498]: Exiting normally, received signal 15.
apr 08 17:15:14 pi homebridge[23498]: [2018-4-8 17:15:14] [Video-doorbell] ERROR: FFmpeg exited with code 1
apr 08 17:15:22 pi homebridge[23498]: [2018-4-8 17:15:22] [Video-doorbell] Snapshot from IQeye IQD52W at 480x270
apr 08 17:15:22 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.239/stream1 -t 1 -s 480x270 -f image2 -
apr 08 17:15:22 pi homebridge[23498]: [2018-4-8 17:15:22] [Video-doorbell] Snapshot from Ubiquity UniFi G3 at 480x270
apr 08 17:15:22 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.205/s0 -t 1 -s 480x270 -f image2 -
apr 08 17:15:35 pi homebridge[23498]: [2018-4-8 17:15:35] [Video-doorbell] Snapshot from Ubiquity UniFi G3 at 480x270
apr 08 17:15:35 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.205/s0 -t 1 -s 480x270 -f image2 -
apr 08 17:15:36 pi homebridge[23498]: [2018-4-8 17:15:36] [Video-doorbell] Snapshot from IQeye IQD52W at 480x270
apr 08 17:15:36 pi homebridge[23498]: ffmpeg -re -i rtsp://1192.168.0.239/stream1 -t 1 -s 480x270 -f image2 -
Samfox2 commented 6 years ago

Looks like a typo in your ip address? Is it really rtsp://1192.xxx not rtsp://192.xxx?

wilhar0046 commented 6 years ago

Johan did you ever get your issue resolved? I am also having similar issues.I get snap shots from the camera just fine but when I try to stream video it doesn’t work. I double checked my IPs in the config.json. When I use the exact same settings for this camera in the original ffmpeg plugin streaming and snapshots work great. I am also not getting the feature rich notification when I trigger the bell event from http. Just a pop up which takes me directly to camera feed. In homekit it’s in the same room as a August lock so I thought I would see the option to open the lock.

Samfox2 commented 6 years ago

If the stream is working with ffmpeg plugin it should also work within video doorbell as the ffmpeg part is basically the same. Could you please try to remove and re-add your video doorbell with a different name? Do snapshots work with the trigger? Could you try the "vcodec": "copy" option?

wilhar0046 commented 6 years ago

I will try that when I get back home tonight. When I trigger it from the curl statement I get home kit notification comedown from top of screen with the Ring A Dong message and the snapshot on the right. When I click it takes me to full screen streaming of the camera which after 30 sec or so fails.

wilhar0046 commented 6 years ago

Here is the original ffmpeg home bridge config that I was using to stream the camera:

"platform": "Camera-ffmpeg", "cameras": [{ "name": "Front Door", "uploader": true, "videoConfig": { "source": "-rtsp_transport tcp -re -i rtsp://10.200.1.2:554/s0", "maxStreams": 2, "maxWidth": 1920, "maxHeight": 1080, "maxFPS": 30

I have removed that camera and config from the old ffmpeg plugin. Here is my current config that I am using:

"platform": "Video-doorbell", "videoProcessor": "/usr/local/bin/ffmpeg", "cameras": [{ "name": "Front Doot", "port": 5005, "videoConfig": { "source": "-rtsp_transport tcp -re -i rtsp://10.200.1.2:554/s0", "button": false, "maxStreams": 2, "maxWidth": 1280, "maxHeight": 1024, "maxFPS": 30, "vcodec": "copy", "debug": true

Here is the terminal debug output I am getting when trying to stream the camera after which the No Response - The Camera is not responding message appears on my phone:

[2018-6-7 16:42:19] [Camera-ffmpeg] Snapshot from Front Lawn at 480x270 [2018-6-7 16:42:32] [Video-doorbell] Start streaming video from Front Doot with 1280x720@299kBit ffmpeg -rtsp_transport http -re -i rtsp://10.200.1.2:554/s0 -map 0:0 -vcodec copy -pix_fmt yuv420p -r 30 -f rawvideo -tune zerolatency -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 4918380 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params CFup8PK24+jfOZgn4umR5uu/XleP5H6xn6gcr+0D srtp://10.0.1.33:62412?rtcpport=62412&localrtcpport=62412&pkt_size=1316 [2018-6-7 16:43:31] [Video-doorbell] Stopped streaming [2018-6-7 16:43:35] [Video-doorbell] Snapshot from Front Doot at 480x270 ffmpeg -rtsp_transport http -re -i rtsp://10.200.1.2:554/s0 -t 1 -s 480x270 -f image2 - [2018-6-7 16:43:37] [Camera-ffmpeg] Snapshot from Front Lawn at 480x270

johan-de-jong commented 6 years ago

I did get it to work after some fiddling. I had immediate success with another plugin for the PiCam (/dev/video0). It passes fewer parameters to ffmpeg.

That led me to experimenting with removing parameters from the ffmpeg command in the ffmpeg.js file. I first got video streaming to work by removing ' -map 0:0' from the ffmpeg.js file. As you can see in the config below, I pass the desired -map argument back in the config.json where required.

As an exercise I've taken input from an ip network camera (mjpeg), my tv decoder (mpegts) and a Raspberry Pi Cam (h264). The ip network camera also supports rtsp/h.264, but ultimately I got better results with mjpeg. Re-encoding/sizing the h.264 stream seems to much to handle for my Pi.

I tried to duplicate my results by copying the config.json and modified ffmpeg.js to another Raspberry Pi. I have not had time to look into this further. On the new Raspberry Pi streaming fails. Which leads me to believe something probably went wrong in building ffmpeg.

Has anybody gotten audio to work smoothly? Mine is rather choppy. As an experiment I discovered that video is (obviously) smoothest when I use de -vcodec copy and removed the re-encoding/sizing parameters from ffmpeg.js.

$ diff /usr/lib/node_modules/homebridge-videodoorbell/ffmpeg.js.org /usr/lib/node_modules/homebridge-videodoorbell/ffmpeg.js
282c282
<         let ffmpegCommand = this.ffmpegSource + ' -map 0:0' +
---
>         let ffmpegCommand = this.ffmpegSource +
        {
            "platform": "Video-doorbell",
            "cameras": [
                {
                    "name": "IQeye IQD52W",
                    "Manufacturer": "IQeye",
                    "uploader": false,
                    "port": 5005,
                    "button": false,
                    "videoConfig": {
                        "source": "-f mjpeg -i http://192.168.0.239/now.jpg?snap=spush",
                        "stillImageSource": "-i http://192.168.0.239/now.jpg",
                        "vcodec": "h264_omx",
                        "maxWidth": 1280,
                        "maxHeight": 720,
                        "maxStreams": 2,
                        "maxFPS": 15,
                        "audio": false,
                        "button": false,
                        "debug": false
                    }
                },
                {
                    "name": "piCam",
                    "uploader": false,
                    "port": 5006,
                    "videoConfig": {
                        "source": "-f video4linux2 -vcodec h264_mmal -i /dev/video0",
                        "stillImageSource": "-f video4linux2 -ss 0.9 -i /dev/video0 -vframes 1",
                        "maxStreams": 2,
                        "maxWidth": 1280,
                        "maxHeight": 720,
                        "maxFPS": 30,
                        "vcodec": "h264_omx",
                        "button": false,
                        "debug": false
                    }
                },
                {
                    "name": "NPO1",
                    "uploader": false,
                    "port": 5007,
                    "videoConfig": {
                        "source": "-f mpegts -acodec mp2 -vcodec mpeg2video -i http://decoder.local:8001/1:0:1:4A61:807:600:FFFF0000:0:0:0: -map 0:0",
                        "maxStreams": 2,
                        "maxWidth": 1024,
                        "maxHeight": 576,
                        "maxBitrate": 512,
                        "maxFPS": 5,
                        "vcodec": "h264_omx",
                        "button": false,
                        "audio": true,
                        "debug": true
                    }
                }
            ]
        },
Samfox2 commented 6 years ago

Great that it is working for you. I suggested the "copy" option as it uses the stream as it is without re-encoding. So this should be the optimal solution if your cam stream is compatible.