sahilchaddha / homebridge-dafang

Homebridge Plugin for Xiaomi Dafang / Wyze Cam IP Camera => Hey Siri, Start Video Recording
MIT License
204 stars 34 forks source link

FFmpeg issues and windows directory. #9

Open kaytek opened 5 years ago

kaytek commented 5 years ago

Hi all,

Currently trying to transition my setup of my hacked Xiaofang from using homebridge-ffmpeg to this as it allows for much better control of the camera, but I've run into a few issues.

At the moment whenever I try and stream from the camera the console will always spit out a FFmpeg exited with code 1 and the stream will fail to load. I haven't had this issue with homebridge-ffmpeg, so I'm not too sure where I've gone wrong. I've attached the config down below.

Here is the full error:

[2018-12-6 23:38:24] [Dafang] Start streaming video from XiaoFang with 1280x720@200kBit
ffmpeg -rtsp_transport tcp -i rtsp://root:ismart12@192.168.0.143:8554/unicast -map 0:0 -vcodec h264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 200k -bufsize 200k -maxrate 200k -payload_type 99 -ssrc 12344156 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params 1bhz+/cqXSwvd8nTZWupdlhND+LxQfeH0T9pQmQ6 srtp://192.168.0.126:54996?rtcpport=54996&localrtcpport=54996&pkt_size=752 -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 1269516 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params tF+nWT3bzXj/vLFy/qW8ThfKd6mSemN4Z5bwNvyi srtp://192.168.0.126:64875?rtcpport=64875&localrtcpport=64875&pkt_size=752
[2018-12-6 23:38:26] [Dafang] ERROR: FFmpeg exited with code 1

Another issue is that I'm not too sure how to translate a windows directory to absolute path to save the recordings. Currently I've just glossed over it and had something random but obviously I can't save anything.

My homebridge setup is currently running on our media PC which runs on windows 10, so any help would be greatly appreciated!

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "222-22-222"
    },

    "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

    "platforms": [{
            "platform": "AqaraPlatform",
            "sid": ["34ce008be6d5"],
            "password": ["qb5mefe7d5tssmy1"],
            "fakeLightBulbForLightSwitch": true
        },
        {

            "platform": "Dafang",

            "mqtt": {
                "hostBroker": true,
                "port": 1883,
                "host": "localhost",
                "debug": true,
                "mongoUrl": "mongodb://localhost:27017/mqtt"
            },
            "cameras": [{
                    "cameraName": "XiaoFang",
                    "cameraRTSPStreamUrl": "rtsp://192.168.0.143:8554/unicast",
                    "mqttTopic": "myhome/dafang/#",
                    "folder": "test/recordings",
                    "accessories": [{
                            "name": "Motion Sensor",
                            "type": "richMotionSensor",
                            "threshold": 300000
                        },
                        {
                            "name": "Auto Motion Tracking Switch",
                            "type": "autoMotionTrackingSwitch"
                        },
                        {
                            "name": "Night Vision Sensor",
                            "type": "nightVisionSensor",
                            "threshold": 0
                        },
                        {
                            "name": "Night Vision Switch",
                            "type": "nightVisionSwitch"
                        },
                        {
                            "name": "Auto Night Vision Switch",
                            "type": "autoNightVisionSwitch"
                        },
                        {
                            "name": "Record Video",
                            "type": "recordVideo"
                        },
                        {
                            "name": "Record Audio",
                            "type": "recordAudio"

                        },
                        {
                            "name": "Capture Image",
                            "type": "captureImage"
                        },
                        {
                            "name": "Clear Storage Switch",
                            "type": "clearStorage"
                        },
                        {
                            "name": "Reset Streaming",
                            "type": "resetFFMPEG"
                        },
                        {
                            "name": "Camera Brightness",
                            "type": "brightness"
                        }

                    ],
                    "videoConfig": {

                        "source": "-rtsp_transport tcp -i rtsp://root:ismart12@192.168.0.143:8554/unicast",
                        "stillImageSource": "-rtsp_transport tcp -i rtsp://root:ismart12@192.168.0.143:8554/unicast -vframes 1 -r 1",
                        "maxStreams": 5,
                        "maxWidth": 1280,
                        "maxHeight": 720,
                        "maxFPS": 15,
                        "vcodec": "h264",
                        "packetSize": 752,
                        "maxBitrate": 200,
                        "debug": true
                    }

                }]
            }

        ]

    }
sahilchaddha commented 5 years ago

Hey @kaytek , homebridge-dafang internally uses little modified version of homebridge-camera-ffmpeg. So technically if you can watch stream using homebridge-camera-ffmpeg, homebridge-dafang should also work.

Can u check logs for differences between ffmpeg commands posted by homebridge-camera-ffmpeg & homebridge-dafang.

Also make sure you have installed all ffmpeg dependencies.

You can set custom config in videoConfig in config.json.

For your absolute path issue, i dont have a windows machine to test it but can you try absolute path like C:\Documents\Recordings\ also make sure the folder has right permissions for homebridge to write data to that folder.

sahilchaddha commented 5 years ago

I would also appreciate if you can help me test

https://github.com/sahilchaddha/homebridge-dafang/pull/6

tarbychark commented 5 years ago

Also having the same issue on macOS 10.14.2.

When using normal homebridge-camera-ffmpeg plugin, I can get the stream to load fine. When using just homebridge-dafang, I get '[Dafang] ERROR: FFmpeg exited with code 1'

All other functions appear to work fine.

sahilchaddha commented 5 years ago

Hey @tarbychark ,

Can u share logs for differences between ffmpeg commands posted by homebridge-camera-ffmpeg & homebridge-dafang ?

Make sure to enable debug flag in videoConfig in config.json for both the plugins.

tarbychark commented 5 years ago

Hey @sahilchaddha ,

Here is when running the camera from the Dafang plugin:

[2018-12-10 17:23:53] [Dafang] Snapshot from Kitchen Camera at 480x270 [2018-12-10 17:23:54] [Dafang] Start streaming video from Kitchen Camera with 1280x720@299kBit [2018-12-10 17:23:56] [Dafang] ERROR: FFmpeg exited with code 1

From Camera-FFmpeg after I switched the config:

[2018-12-10 17:24:39] [Camera-ffmpeg] Snapshot from Kitchen Cam at 480x270 [2018-12-10 17:24:44] [Camera-ffmpeg] Start streaming video from Kitchen Cam with 1280x720@299kBit [2018-12-10 17:24:56] [Camera-ffmpeg] Snapshot from Kitchen Cam at 480x270

Let me know if there are any other logs you’d like.

sahilchaddha commented 5 years ago

Hi @tarbychark , These are just basic logs, for command output u will need to enable debug flag in videoConfig.

To enable debug on homebridge-dafang :

{...}
                {
                                        "name": "Camera Brightness",
                                        "type": "brightness"
                                    }
                    ],
                    "videoConfig": {
                        "source": "-rtsp_transport tcp -i rtsp://DAFANG_IP:8554/unicast",
                        "stillImageSource": "-rtsp_transport http -i rtsp://DAFANG_IP:8554/unicast -vframes 1 -r 1",
                        "maxStreams": 5,
                        "maxWidth": 1280,
                        "maxHeight": 720,
                        "maxFPS": 25,
                        "vcodec": "h264",
                        "debug": true
                }

For camera-ffmpeg

     "videoConfig": {
        "source": "-re -i rtsp://myfancy_rtsp_stream",
        "stillImageSource": "-i http://faster_still_image_grab_url/this_is_optional.jpg",
        "maxStreams": 2,
        "maxWidth": 1280,
        "maxHeight": 720,
        "maxFPS": 30,
        "maxBitrate": 200,
        "vcodec": "h264_omx",
        "audio": true,
        "packetSize": 188,
        "debug": true
      }

The debug key needs to be set true in order to print command logs.

tarbychark commented 5 years ago

hey @sahilchaddha ,

Sorry about that. Here are some logs with debug enabled for Dafang:

[2018-12-11 13:42:49] [Dafang] Snapshot from Kitchen Camera at 480x270 ffmpeg -rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast -vframes 1 -r 1 -t 1 -s 480x270 -f image2 - [2018-12-11 13:42:54] [Dafang] Start streaming video from Kitchen Camera with 1280x720@200kBit ffmpeg -rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast -map 0:0 -vcodec h264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 200k -bufsize 200k -maxrate 200k -payload_type 99 -ssrc 6522845 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params v2oxlhmAOcZEiJ8kRH4hIh7zEnfqTPTYeiQCcEbR srtp://10.0.1.22:52789?rtcpport=52789&localrtcpport=52789&pkt_size=752 -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 12189420 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params jaFu2YSbMwXwrC2Ngg3ft5QuXCWNr6r3KRaCV2N7 srtp://10.0.1.22:65081?rtcpport=65081&localrtcpport=65081&pkt_size=752 [2018-12-11 13:42:56] [Dafang] ERROR: FFmpeg exited with code 1

Here is just Camera-ffmpeg with debug enabled:

[2018-12-11 13:44:10] [Camera-ffmpeg] Snapshot from Kitchen Cam at 480x270 ffmpeg -i rtsp://10.0.1.44:8554/unicast -t 1 -s 480x270 -f image2 - [2018-12-11 13:44:13] [Camera-ffmpeg] Start streaming video from Kitchen Cam with 1280x720@200kBit ffmpeg -re -i rtsp://10.0.1.44:8554/unicast -map 0:0 -vcodec h264 -pix_fmt yuv420p -r 25 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 200k -bufsize 200k -payload_type 99 -ssrc 3135441 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params VcZY8X/m81EW/lB7rVplcIaIggxfSLA/3juUpSRy srtp://10.0.1.22:61056?rtcpport=61056&localrtcpport=61056&pkt_size=1316 ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 10.0.0 (clang-1000.11.45.5) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox

libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100

[mp3float @ 0x7fb4a2813000] Header missing

Input #0, rtsp, from 'rtsp://10.0.1.44:8554/unicast': Metadata: title : LIVE555 Streaming Media v2017.10.28

comment         : LIVE555 Streaming Media v2017.10.28

Duration: N/A, start: -0.182522, bitrate: N/A Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1280x720, 15 fps, 25 tbr, 90k tbn, 30 tbc

Stream #0:1: Audio: mp3, 44100 Hz, mono, fltp, 64 kb/s

Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Press [q] to stop, [?] for help

frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
[libx264 @ 0x7fb4a2834a00] VBV maxrate unspecified, assuming CBR

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

[libx264 @ 0x7fb4a2834a00] profile High, level 3.1

Output #0, rtp, to 'srtp://10.0.1.22:61056?rtcpport=61056&localrtcpport=61056&pkt_size=1316': Metadata: title : LIVE555 Streaming Media v2017.10.28 comment : LIVE555 Streaming Media v2017.10.28 encoder : Lavf58.20.100

Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720, q=-1--1, 200 kb/s, 25 fps, 90k tbn, 25 tbc
Metadata:
  encoder         : Lavc58.35.100 libx264
Side data:

cpb: bitrate max/min/avg: 0/0/200000 buffer size: 200000 vbv_delay: -1

frame= 17 fps= 17 q=34.0 size= 15kB time=00:00:00.64 bitrate= 188.8kbits/s dup=12 drop=0 speed=0.638x
frame= 31 fps= 21 q=35.0 size= 26kB time=00:00:01.20 bitrate= 177.3kbits/s dup=18 drop=0 speed=0.796x
frame= 44 fps= 22 q=33.0 size= 35kB time=00:00:01.72 bitrate= 164.9kbits/s dup=23 drop=0 speed=0.853x
frame= 58 fps= 23 q=34.0 size= 46kB time=00:00:02.28 bitrate= 164.9kbits/s dup=28 drop=4 speed=0.905x
send hb to: 0x00000000045699d7 {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} frame= 68 fps= 22 q=30.0 size= 54kB time=00:00:02.68 bitrate= 165.5kbits/s dup=31 drop=4 speed=0.886x
[rtsp @ 0x7fb4a2803a00] max delay reached. need to consume packet [rtsp @ 0x7fb4a2803a00] RTP: missed 25 packets

[rtsp @ 0x7fb4a2803a00] max delay reached. need to consume packet [rtsp @ 0x7fb4a2803a00] RTP: missed 2 packets [rtsp @ 0x7fb4a2803a00] max delay reached. need to consume packet [rtsp @ 0x7fb4a2803a00] RTP: missed 3 packets [rtsp @ 0x7fb4a2803a00] max delay reached. need to consume packet [rtsp @ 0x7fb4a2803a00] RTP: missed 10 packets [rtsp @ 0x7fb4a2803a00] max delay reached. need to consume packet [rtsp @ 0x7fb4a2803a00] RTP: missed 40 packets

[h264 @ 0x7fb4a2891800] Increasing reorder buffer to 10

[2018-12-11 13:44:18] [Dafang] Snapshot from Kitchen Camera at 480x270 ffmpeg -rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast -vframes 1 -r 1 -t 1 -s 480x270 -f image2 - frame= 71 fps= 20 q=28.0 size= 56kB time=00:00:02.80 bitrate= 163.2kbits/s dup=32 drop=4 speed=0.793x
frame= 71 fps= 19 q=28.0 Lsize= 56kB time=00:00:02.80 bitrate= 163.2kbits/s dup=32 drop=4 speed=0.734x
video:55kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.337876%

[libx264 @ 0x7fb4a2834a00] frame I:1 Avg QP:45.25 size: 3994 [libx264 @ 0x7fb4a2834a00] frame P:70 Avg QP:31.16 size: 748 [libx264 @ 0x7fb4a2834a00] mb I I16..4: 22.4% 77.5% 0.1% [libx264 @ 0x7fb4a2834a00] mb P I16..4: 0.7% 0.6% 0.0% P16..4: 4.3% 0.3% 0.2% 0.0% 0.0% skip:94.0%

[libx264 @ 0x7fb4a2834a00] 8x8 transform intra:63.9% inter:79.3% [libx264 @ 0x7fb4a2834a00] coded y,uvDC,uvAC intra: 7.7% 17.4% 0.1% inter: 0.7% 1.3% 0.0% [libx264 @ 0x7fb4a2834a00] i16 v,h,dc,p: 31% 37% 16% 16% [libx264 @ 0x7fb4a2834a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 7% 53% 1% 1% 1% 1% 1% 1% [libx264 @ 0x7fb4a2834a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 34% 38% 2% 3% 3% 5% 2% 2% [libx264 @ 0x7fb4a2834a00] i8c dc,h,v,p: 88% 5% 7% 0% [libx264 @ 0x7fb4a2834a00] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 0x7fb4a2834a00] ref P L0: 82.7% 12.3% 3.9% 1.1% [libx264 @ 0x7fb4a2834a00] kb/s:158.75

Exiting normally, received signal 15.

[2018-12-11 13:44:19] [Camera-ffmpeg] Stopped streaming

Hope this helps. Thanks!

sahilchaddha commented 5 years ago

Hey @tarbychark , Thanks for the logs. I will check them once i get little free time. Meanwhile can you also share your config.json for both the plugins ?

tarbychark commented 5 years ago

Hey @sahilchaddha ,

Here’s the Dafang config:

{ "platform": "Dafang", "mqtt": { "hostBroker": true, "port": 1883, "host": "localhost", "debug": false, "mongoUrl": "mongodb://localhost:27017/mqtt" }, "cameras": [ { "cameraName": "Kitchen Camera", "cameraRTSPStreamUrl": "rtsp://10.0.1.44:8554/unicast", "mqttTopic": "Hizzy/KitchenCamera/#", "folder": "/Users/stevethompson/Documents/Camera/Recordings", "accessories": [ { "name": "Kitchen Motion Sensor", "type": "richMotionSensor", "threshold": 200000 }, { "name": "Kitchen Auto Motion Tracking Switch", "type": "autoMotionTrackingSwitch" }, { "name": "Kitchen Night Vision Sensor", "type": "nightVisionSensor", "threshold": 0 }, { "name": "Kitchen Night Vision Switch", "type": "nightVisionSwitch" }, { "name": "Kitchen Auto Night Vision Switch", "type": "autoNightVisionSwitch" }, { "name": "Kitchen Record Video", "type": "recordVideo" }, { "name": "Kitchen Record Audio", "type": "recordAudio" }, { "name": "Kitchen Capture Image", "type": "captureImage" }, { "name": "Kitchen Clear Storage Switch", "type": "clearStorage" }, { "name": "Kitchen Reset Streaming", "type": "resetFFMPEG" }, { "name": "Kitchen Camera Brightness", "type": "brightness" } ] }, { "cameraName": "Living Room Camera", "cameraRTSPStreamUrl": "rtsp://10.0.1.42:8554/unicast", "mqttTopic": "Hizzy/LRCam/#", "folder": "/Users/stevethompson/Documents/Camera/Recordings", "accessories": [ { "name": "Living Room Motion Sensor", "type": "richMotionSensor", "threshold": 200000 }, { "name": "Living Room Auto Motion Tracking Switch", "type": "autoMotionTrackingSwitch" }, { "name": "Living Room Night Vision Sensor", "type": "nightVisionSensor", "threshold": 0 }, { "name": "Living Room Night Vision Switch", "type": "nightVisionSwitch" }, { "name": "Living Room Auto Night Vision Switch", "type": "autoNightVisionSwitch" }, { "name": "Living Room Record Video", "type": "recordVideo" }, { "name": "Living Room Record Audio", "type": "recordAudio" }, { "name": "Living Room Capture Image", "type": "captureImage" }, { "name": "Living Room Clear Storage Switch", "type": "clearStorage" }, { "name": "Living Room Reset Streaming", "type": "resetFFMPEG" }, { "name": "Living Room Camera Brightness", "type": "brightness" } ] }, { "cameraName": "Family Room Camera", "cameraRTSPStreamUrl": "rtsp://10.0.1.91:8554/unicast", "mqttTopic": "Hizzy/FRCam/#", "folder": "/Users/stevethompson/Documents/Camera/Recordings", "accessories": [ { "name": "Family Room Motion Sensor", "type": "richMotionSensor", "threshold": 200000 }, { "name": "Family Room Auto Motion Tracking Switch", "type": "autoMotionTrackingSwitch" }, { "name": "Family Room Night Vision Sensor", "type": "nightVisionSensor", "threshold": 0 }, { "name": "Family Room Night Vision Switch", "type": "nightVisionSwitch" }, { "name": "Horizontal Left", "type": "moveCamera", "axis": "horizontal", "direction": "left" }, { "name": "Horizontal Right", "type": "moveCamera", "axis": "horizontal", "direction": "right" }, { "name": "Vertical Up", "type": "moveCamera", "axis": "vertical", "direction": "up" }, { "name": "Vertical Down", "type": "moveCamera", "axis": "vertical", "direction": "down" }, { "name": "Family Room Auto Night Vision Switch", "type": "autoNightVisionSwitch" }, { "name": "Family Room Record Video", "type": "recordVideo" }, { "name": "Family Room Record Audio", "type": "recordAudio" }, { "name": "Family Room Capture Image", "type": "captureImage" }, { "name": "Family Room Clear Storage Switch", "type": "clearStorage" }, { "name": "Family Room Reset Streaming", "type": "resetFFMPEG" }, { "name": "Family Room Camera Brightness", "type": "brightness" } ] }, { "cameraName": "Laundry Room Camera", "cameraRTSPStreamUrl": "rtsp://10.0.1.38:8554/unicast", "mqttTopic": "Hizzy/LaundryCam/#", "folder": "/Users/stevethompson/Documents/Camera/Recordings", "accessories": [ { "name": "Laundry Room Motion Sensor", "type": "richMotionSensor", "threshold": 200000 }, { "name": "Laundry Room Auto Motion Tracking Switch", "type": "autoMotionTrackingSwitch" }, { "name": "Laundry Room Night Vision Sensor", "type": "nightVisionSensor", "threshold": 0 }, { "name": "Laundry Room Night Vision Switch", "type": "nightVisionSwitch" }, { "name": "Laundry Room Auto Night Vision Switch", "type": "autoNightVisionSwitch" }, { "name": "Laundry Room Record Video", "type": "recordVideo" }, { "name": "Laundry Room Record Audio", "type": "recordAudio" }, { "name": "Laundry Room Capture Image", "type": "captureImage" }, { "name": "Laundry Room Clear Storage Switch", "type": "clearStorage" }, { "name": "Laundry Room Reset Streaming", "type": "resetFFMPEG" }, { "name": "Laundry Room Camera Brightness", "type": "brightness" } ], "videoConfig": { "source": "-rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast", "stillImageSource": "-rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast -vframes 1 -r 1", "maxStreams": 5, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 15, "vcodec": "h264", "packetSize": 752, "maxBitrate": 200, "debug": true } } ] },

Here’s the Camera-FFmpeg config:

{ "platform": "Camera-ffmpeg", "cameras": [ { "name": "Kitchen Cam", "videoConfig": { "source": "-re -i rtsp://10.0.1.44:8554/unicast", "stillImageSource": "-i rtsp://10.0.1.44:8554/unicast", "maxStreams": 5, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 25, "vcodec": "h264", "maxBitrate": 256, "debug": true } }, { "name": "Laundry Room Cam", "videoConfig": { "source": "-re -i rtsp://10.0.1.38:8554/unicast", "stillImageSource": "-i rtsp://10.0.1.38:8554/unicast", "maxStreams": 5, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 25, "vcodec": "h264", "maxBitrate": 256, "debug": true } }, { "name": "Family Room Cam", "videoConfig": { "source": "-re -i rtsp://10.0.1.91:8554/unicast", "stillImageSource": "-i rtsp://10.0.1.91:8554/unicast", "maxStreams": 5, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 25, "vcodec": "h264", "maxBitrate": 256, "debug": true } }, { "name": "Living Room Cam", "videoConfig": { "source": "-re -i rtsp://10.0.1.42:8554/unicast", "stillImageSource": "-i rtsp://10.0.1.42:8554/unicast", "maxStreams": 5, "maxWidth": 1280, "maxHeight": 720, "maxFPS": 25, "vcodec": "h264", "maxBitrate": 256, "debug": true } } ] },

Thanks for looking into it!

sahilchaddha commented 5 years ago

Hey @tarbychark ,

Can you try this attached config ? I have set audio to false to disable audio stream. homebridge-dafang by default enables audio whereas camera-ffmpeg is audio disabled by default.

      "videoConfig": {
        "source": "-rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast",
        "stillImageSource": "-rtsp_transport http -i rtsp://10.0.1.44:8554/unicast -vframes 1 -r 1",
        "maxStreams": 5,
        "maxWidth": 1280,
        "maxHeight": 720,
        "maxFPS": 15,
        "debug": true,
        "audio": false
      }

Looks like you are missing audio codecs for ffmpeg. If it works meaning you need to install ffmpeg dependencies for your audio codec.

Keep us updated. And do share the logs.

tarbychark commented 5 years ago

Hey @sahilchaddha ,

Thanks for all of your prompt responses. Which audio codecs should I be installing for macOS? I’d be happy to test the video config both with the audio codecs installed and with audio disabled when I get out of work later today.

Thanks!

sahilchaddha commented 5 years ago

Usually Dafang hacks stream with h264 video codec and aac audio codec. You can try installing audio codec by brew install ffmpeg --with-openh264 --with-fdk-aac

myusuf3 commented 5 years ago

also looking for help with this.

sahilchaddha commented 5 years ago

@myusuf3 , Try setting audio to false as stated in https://github.com/sahilchaddha/homebridge-dafang/issues/9#issuecomment-446594705.

Do share the logs with debug enabled.

joemulray commented 5 years ago

@sahilchaddha I installed ffme library sudo apt-get install ffmpeg that seemed to get the still image working but still throwing the same error with the configuration in https://github.com/sahilchaddha/homebridge-dafang/issues/9#issuecomment-446099366 Still same issue


Dec 19 03:44:48 localhost homebridge[4574]: [12/19/2018, 3:44:48 AM] [Dafang] Start streaming video from REXCAMERA with 1280x720@299kBit
Dec 19 03:44:48 localhost homebridge[4574]: ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.105:8554/unicast -map 0:0 -vcodec h264 -pix_fmt yuv420p -r 25 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 328165 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params zV2Fga8zKpx6W1iApAsvYSL68P9smO9z8OJx0k2t srtp://192.168.1.105:53056?rtcpport=53056&localrtcpport=53056&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 1540808 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params /HWWRdqbZsRxeLqs01hDiQeZ0gT7iCIHLbvo/SVS srtp://192.168.1.105:57413?rtcpport=57413&localrtcpport=57413&pkt_size=1316
Dec 19 03:44:50 localhost homebridge[4574]: [12/19/2018, 3:44:50 AM] [Dafang] ERROR: FFmpeg exited with code 1
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4758-REXCAMERA
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/leds/blue : OFF
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4758-REXCAMERA
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4762-REXCAMERA
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/leds/yellow : OFF
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4762-REXCAMERA
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4766-REXCAMERA
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/leds/ir : OFF
Dec 19 03:44:58 localhost homebridge[4574]: [12/19/2018, 3:44:58 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4766-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4769-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/ir_cut : ON
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4769-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4775-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/brightness : 40
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4775-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4780-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/rtsp_h264_server : ON
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4780-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4785-REXCAMERA
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/rtsp_mjpeg_server : OFF
Dec 19 03:44:59 localhost homebridge[4574]: [12/19/2018, 3:44:59 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4785-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4788-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/night_mode : OFF
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4788-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4790-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/night_mode/auto : ON
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4790-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4794-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/motion/detection : ON
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4794-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4799-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/motion/send_mail : ON
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4799-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4802-REXCAMERA
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/motion/tracking : OFF
Dec 19 03:45:00 localhost homebridge[4574]: [12/19/2018, 3:45:00 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4802-REXCAMERA
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4810-REXCAMERA
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/motors/vertical : 0
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4810-REXCAMERA
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4818-REXCAMERA
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA/motors/horizontal : 0
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4818-REXCAMERA
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/new/clients : mosqpub|4850-REXCAMERA
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : REXHOME/REXCAMERA : {"uptime":" 03:45:01 up 26 min,  0 users,  load average: 3.21, 3.02, 2.39",  "ssid":"HOME-WIFI", "bitrate":"72.2 Mb/s", "signal_level":"100%", "link_quality":"81%", "noise_level":"0%" }
Dec 19 03:45:01 localhost homebridge[4574]: [12/19/2018, 3:45:01 AM] [Dafang] MQTT Server Publish : $SYS/7iSZPwI/disconnect/clients : mosqpub|4850-REXCAMERA
Dec 19 03:45:05 localhost homebridge[4574]: [12/19/2018, 3:45:05 AM] [Dafang] Snapshot from REXCAMERA at 480x270
Dec 19 03:45:05 localhost homebridge[4574]: ffmpeg -rtsp_transport http -i rtsp://192.168.1.105:8554/unicast -vframes 1 -r 1 -t 1 -s 480x270 -f image2 -```
enz1ey commented 5 years ago

Any news on this? I have the same issue it seems. When pulling up the Home app, I can see the current snapshot, but tapping on the video then only shows a still image, no video. My logs on my server show ffmpeg exiting with error code 1 as well. I'm using an OptiPlex 3020 as a server, so it's not exactly under-powered.

sahilchaddha commented 5 years ago

Hey @joemulray, As i can see from the logs. Looks like audio is still enabled. Command still provides audio codec to ffmpeg. Kindly set debug to true & audio to false.

   "videoConfig": {
        "source": "-rtsp_transport tcp -i rtsp://10.0.1.44:8554/unicast",
        "stillImageSource": "-rtsp_transport http -i rtsp://10.0.1.44:8554/unicast -vframes 1 -r 1",
        "maxStreams": 5,
        "maxWidth": 1280,
        "maxHeight": 720,
        "maxFPS": 15,
        "debug": true,
        "audio": false
      }

@enz1ey Make sure all ffmpeg dependencies are installed. You will also need to enable h264 and aac codecs in ffmpeg. Each OS has different commands for that.

To self-debug try running the ffmpeg command printed in logs manually. You will be able to see the exact error more clearly.

You can also try reinstalling ffmpeg. Refer to https://gist.github.com/codyeatworld/3794218 (This will install fdk-aac and libx264 which is required video and audio codecs)

Required ffmpeg Codecs :

You can google how to install ffmpeg with libx264 and libfdk_aac according to your OS. e.g. Ubuntu install ffmpeg with libx264 libfdk_aac

Kindly provide :

  1. FFMPEG Version by running ffmpeg -version
  2. Homebridge Logs with debug enabled and audio disabled during stream start
  3. Try running ffmpeg command manually and share error printed out. You can get ffmpeg command from homebridge logs printed after starting a stream.
  4. FFMPEG Encoders by running ffmpeg -encoders
  5. FFMPEG Decoders by running ffmpeg -decoders
sahilchaddha commented 5 years ago

@joemulray Try running this command manually

ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.105:8554/unicast -map 0:0 -vcodec h264 -pix_fmt yuv420p -r 25 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 328165 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params zV2Fga8zKpx6W1iApAsvYSL68P9smO9z8OJx0k2t "srtp://192.168.1.105:53056?rtcpport=53056&localrtcpport=53056&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 1540808 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params /HWWRdqbZsRxeLqs01hDiQeZ0gT7iCIHLbvo/SVS "srtp://192.168.1.105:57413?rtcpport=57413&localrtcpport=57413&pkt_size=1316"

This ffmpeg command will throw the real error. It will also display missing dependencies

netRunner0 commented 5 years ago

{ "platform":"Camera-ffmpeg", "cameras":[ { "name":"Camera 1", "videoConfig":{ "source":"-i rtsp://ip-address/unicast", "stillImageSource":"-rtsp_transport tcp -i rtsp://ip-address/unicast -vframes 1 -r 1", "maxStreams":5, "maxWidth":1280, "maxHeight":720, "maxFPS":25, "vcodec":"h264_omx" } } ] }

joemulray commented 5 years ago

Seems to be an issue with ffmpeg with missing packages, im working on a snippet that would solve this issue ill post it on here if im able to resolve everything

netRunner0 commented 5 years ago

kaytek

Use the homebridge-ffmpeg plugin to stream the stream and my configuration, and leave this plugin for the camera control. In this case, everything is perfect without streaming the stream.

joemulray commented 5 years ago

Okay this is what I did to get it working from this same issue. I installed this version of ffmpeg ffmpeg 3.1.4

sudo dpkg -i ffmpeg_3.1.4-1_armhf.deb
ln -sfn bin/ffmpeg /usr/bin/ffmpeg 
systemctl restart homebridge && tail -f /var/log/syslog

This did the trick for me solved this issue I was seeing

ffmpeg version N-92817-gc268712 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.11) 20160609
  configuration: --prefix=/home/ubuntu/ffmpeg_build --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-nonfree
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 42.104 / 58. 42.104
  libavformat    58. 25.100 / 58. 25.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
Unrecognized option 'tune'.
Error splitting the argument list: Option not found

let me know if that helped

Finch106 commented 5 years ago

I'm on a pi and am experiencing the same issues. I compiled with aac and mp3 just in case, using this: http://morituri.co.nf/raspberry-pi/how-to-compile-ffmpeg-on-a-raspberry-pi-with-x264-mp3-and-aac-encoding/ and am getting an error unless I set audio to false. I'll try your fix @joemulray and will report back.

EDIT: It didn't help in my case. This is the output of my ffmpeg -version: ffmpeg version N-81800-gf013ba4 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.9.2 (Raspbian 4.9.2-10) configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-omx --enable-omx-rpi libavutil 55. 30.100 / 55. 30.100 libavcodec 57. 58.103 / 57. 58.103 libavformat 57. 51.100 / 57. 51.100 libavdevice 57. 0.102 / 57. 0.102 libavfilter 6. 63.100 / 6. 63.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 2.100 / 2. 2.100 libpostproc 54. 0.100 / 54. 0.100

EDIT 2: Completely recompiled ffmpeg using an Ubuntu guide, minus h.265 and libaom, and everything works. Sound however cuts out after about 5 seconds, and the stream appears to pause but it doesn't crash ffmpeg. I can leave the cam and come back and the same will happen, so I don't know what audio settings to use or if changing them would help.

joemulray commented 5 years ago

@Gamer106 can you please provide the steps you took to recompile ffmpeg to solve this issue 👍