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

[BUG] - ffmpeg exited with code 1 #47

Open jcbshw opened 4 years ago

jcbshw commented 4 years ago

FFmpeg errors out when trying to view the stream. I am able to view the stream with the same camera using homebridge-camera-ffmpeg. I compared the how both are starting the stream and the only difference seems to be "-vf scale=1280:720" while using dafang plugin.

homebridge-dafang ffmpeg -i rtsp://192.168.1.110:8554/unicast -map 0:0 -vcodec copy -pix_fmt yuv420p -r 15 -f rawvideo -fflags +genpts+discardcorrupt -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 8856484 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params w9Dkt+stdHMs8zvNkhl8izPxN93YgJzefq+Ot+bS srtp://192.168.1.120:55571?rtcpport=55571&localrtcpport=55571&pkt_size=1316

homebridge-camera-ffmpeg ffmpeg -i rtsp://192.168.1.110:8554/unicast -map 0:0 -vcodec copy -pix_fmt yuv420p -r 15 -f rawvideo -fflags +genpts+discardcorrupt -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 1222423 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params MXrm3B4GnA+FA4nY6j2YixqPu96AZaQvRVfDX6Jx srtp://192.168.1.120:54565?rtcpport=54565&localrtcpport=54565&pkt_size=1316 -loglevel debug

I've attached my config.json config.txt

jcbshw commented 4 years ago

Removing "-vf scale=1280:720" from camera.js fixed it

Wonder if it is due to the copy vcodec?

NoTrace-Kai commented 4 years ago

Do you mean this in Line 308? ' -vf scale=' + width + ':' + height + Thant won't fix my Error 01 Problem with the Camera Stream. And did you get the Motion Tracker working?

billyjacoby commented 4 years ago

I'm having this same issue, I just tried removing that line in camera.js to no avail. Here's my error:

[3/6/2020, 20:54:05] [Dafang] Start streaming video from Zen Room Dafang with 1280x720@299kBit ffmpeg -rtsp_transport tcp -re -i rtsp://10.0.1.57:8554/unicast -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 14656319 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params plpJrtFptHbJCNGF6ub9dgsUbe9QuMNXHqwe3s4o srtp://10.0.1.13:56689?rtcpport=56689&localrtcpport=56689&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 9453863 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params Zyc0/OFV29X5igxwQz3jrJTlfA3ULBJYKwzi0Y9s srtp://10.0.1.13:65413?rtcpport=65413&localrtcpport=65413&pkt_size=1316 [3/6/2020, 20:54:07] [Dafang] ERROR: FFmpeg exited with code 1

lemar89 commented 4 years ago

I'm having this same issue, I just tried removing that line in camera.js to no avail. Here's my error:

[3/6/2020, 20:54:05] [Dafang] Start streaming video from Zen Room Dafang with 1280x720@299kBit ffmpeg -rtsp_transport tcp -re -i rtsp://10.0.1.57:8554/unicast -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 14656319 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params plpJrtFptHbJCNGF6ub9dgsUbe9QuMNXHqwe3s4o srtp://10.0.1.13:56689?rtcpport=56689&localrtcpport=56689&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 9453863 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params Zyc0/OFV29X5igxwQz3jrJTlfA3ULBJYKwzi0Y9s srtp://10.0.1.13:65413?rtcpport=65413&localrtcpport=65413&pkt_size=1316 [3/6/2020, 20:54:07] [Dafang] ERROR: FFmpeg exited with code 1

Try “audio” : false in config.json in videoConfig section

billyjacoby commented 4 years ago

I'm having this same issue, I just tried removing that line in camera.js to no avail. Here's my error: [3/6/2020, 20:54:05] [Dafang] Start streaming video from Zen Room Dafang with 1280x720@299kBit ffmpeg -rtsp_transport tcp -re -i rtsp://10.0.1.57:8554/unicast -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 14656319 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params plpJrtFptHbJCNGF6ub9dgsUbe9QuMNXHqwe3s4o srtp://10.0.1.13:56689?rtcpport=56689&localrtcpport=56689&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 9453863 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params Zyc0/OFV29X5igxwQz3jrJTlfA3ULBJYKwzi0Y9s srtp://10.0.1.13:65413?rtcpport=65413&localrtcpport=65413&pkt_size=1316 [3/6/2020, 20:54:07] [Dafang] ERROR: FFmpeg exited with code 1

Try “audio” : false in config.json in videoConfig section

Nahh, still not working =/

billyjacoby commented 4 years ago

I'm having this same issue, I just tried removing that line in camera.js to no avail. Here's my error: [3/6/2020, 20:54:05] [Dafang] Start streaming video from Zen Room Dafang with 1280x720@299kBit ffmpeg -rtsp_transport tcp -re -i rtsp://10.0.1.57:8554/unicast -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 14656319 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params plpJrtFptHbJCNGF6ub9dgsUbe9QuMNXHqwe3s4o srtp://10.0.1.13:56689?rtcpport=56689&localrtcpport=56689&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 9453863 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params Zyc0/OFV29X5igxwQz3jrJTlfA3ULBJYKwzi0Y9s srtp://10.0.1.13:65413?rtcpport=65413&localrtcpport=65413&pkt_size=1316 [3/6/2020, 20:54:07] [Dafang] ERROR: FFmpeg exited with code 1

Try “audio” : false in config.json in videoConfig section

I think the most annoying part of all of this is that everything else is working so well. I got MQTT notifications working 100%, still images show just fine, its just the damn video that I cannot for the life of me get to stream correctly...

jcbshw commented 4 years ago

I'm having this same issue, I just tried removing that line in camera.js to no avail. Here's my error:

[3/6/2020, 20:54:05] [Dafang] Start streaming video from Zen Room Dafang with 1280x720@299kBit ffmpeg -rtsp_transport tcp -re -i rtsp://10.0.1.57:8554/unicast -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 15 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 14656319 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params plpJrtFptHbJCNGF6ub9dgsUbe9QuMNXHqwe3s4o srtp://10.0.1.13:56689?rtcpport=56689&localrtcpport=56689&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 9453863 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params Zyc0/OFV29X5igxwQz3jrJTlfA3ULBJYKwzi0Y9s srtp://10.0.1.13:65413?rtcpport=65413&localrtcpport=65413&pkt_size=1316 [3/6/2020, 20:54:07] [Dafang] ERROR: FFmpeg exited with code 1

Looks like yours is starting the stream with “vfscale” which was causing the issue for me.

Does your camera work with homebridge-camera-ffmpeg?

billyjacoby commented 4 years ago

@jcbshw Last time I tried it with ffmpeg it did.

It worked for about 30 seconds after one time of messing with the configs (didn't do anything really differently) then it just stopped working again.

Do you think this would work better if I ran a different homebridge instance on a Debian or Ubuntu VM, as opposed to running on the rPi?

jcbshw commented 4 years ago

@billyjacoby

I am running it on my RPi 4 using docker-homebride without any issue. If you use the "copy" codec it doesn't encode the video and just transmits it as it to homekit so the RPi is suitable for that. I'd try to get it working in homebridge-camera-ffmpeg first as they have more support with issues, then use those same settings with homebridge-dafang.

I've attached my latest config.json for my camera. I've also removed line 308 from camera.js.

dafang.json

billyjacoby commented 4 years ago

Your config hasn't worked for me either =/

I don't have a user/password setup yet, and I don't think my still image would be available via SSL.

I'm on a rPi 3 as well, im going to spin up a docker version and see if that works..

Edit: I rebooted the camera, and it seems to be working almost flawlessly now! Thanks so much!

velaar commented 4 years ago

@billyjacoby can you please share a working config? I'm trying to figure this one out.

And if possible the video settings on the camera itself (bitrate, resolution, codec, CBR/VBR, etc.)

billyjacoby commented 4 years ago

here's my whole config sans local IP addresses:

{
            "platform": "Dafang",
            "mqtt": {
                "hostBroker": false,
                "port": 1883,
                "host": "defang.local"
            },
            "cameras": [
                {
                    "cameraName": "Zen Room Dafang",
                    "cameraRTSPStreamUrl": "rtsp://CAMERA-IP-ADDRESS:8554/unicast",
                    "disableStream": false,
                    "mqttTopic": "myhome/dafang/#",
                    "folder": "/home/pi/dafang/recordings/",
                    "debug": true,
                    "accessories": [
                        {
                            "name": "Zen Room Rich Motion Sensor",
                            "type": "richMotionSensor",
                            "threshold": 300000
                        }
                    ],
                    "videoConfig": {
                        "audio": false,
                        "maxBitrate": 5000,
                        "maxWidth": 1280,
                        "maxHeight": 720,
                        "maxFPS": 15,
                        "maxStreams": 2,
                        "source": "-i rtsp://CAMERA-IP-ADDRESS:8554/unicast",
                        "stillImageSource": "-i https://CAMERA-IP-ADDRESS/cgi-bin/currentpic.cgi",
                        "vcodec": "copy",
                        "additionalCommandline": "-fflags +genpts+discardcorrupt",
                        "debug": false
                    }
                }
            ]
        }

Let me know if you have any other questions that I can help with!

mkormendy commented 4 years ago

By any chance, is "defang.local" meant to be "dafang.local"?

DietShasta commented 4 years ago

I ran into a very similar problem here. The few takeaways after using camera-ffmpeg and homebridge-dafang.

With camera-ffmpeg, I would always get exited with code 1 when audio was set to true. Changing it to false worked. It may have had to do with my original ffmpeg installation. I don't think I included the aac option.

With homebridge-dafang, I was able to get default video configuration to work after installing the ffmpeg variation with --with-openh264 --with-fdk-aac as stated in the plugin's read me. But when switching vcodec to copy, I would get the exited with code 1 error again. Commenting out -vf scale=' + width + ':' + height + from camera.js is what finally worked as suggested earlier.

I also tried switching from the default still image snapshot that uses the rtsp feed to the jpeg feed by using "stillImageSource": "-i https://CAMERA-IP-ADDRESS/cgi-bin/currentpic.cgi", but this too didn't work for me! You need to add the id:password@ of your camera's web ui (root:ismart12@ when you first set it up) to the address. This is different from the one you set in configuration>video in the camera's web ui. This speeds up the refresh by about 2 seconds..

clrmsc commented 4 years ago

here's my whole config sans local IP addresses:

{
            "platform": "Dafang",
            "mqtt": {
                "hostBroker": false,
                "port": 1883,
                "host": "defang.local"
            },
            "cameras": [
                {
                    "cameraName": "Zen Room Dafang",
                    "cameraRTSPStreamUrl": "rtsp://CAMERA-IP-ADDRESS:8554/unicast",
                    "disableStream": false,
                    "mqttTopic": "myhome/dafang/#",
                    "folder": "/home/pi/dafang/recordings/",
                    "debug": true,
                    "accessories": [
                        {
                            "name": "Zen Room Rich Motion Sensor",
                            "type": "richMotionSensor",
                            "threshold": 300000
                        }
                    ],
                    "videoConfig": {
                        "audio": false,
                        "maxBitrate": 5000,
                        "maxWidth": 1280,
                        "maxHeight": 720,
                        "maxFPS": 15,
                        "maxStreams": 2,
                        "source": "-i rtsp://CAMERA-IP-ADDRESS:8554/unicast",
                        "stillImageSource": "-i https://CAMERA-IP-ADDRESS/cgi-bin/currentpic.cgi",
                        "vcodec": "copy",
                        "additionalCommandline": "-fflags +genpts+discardcorrupt",
                        "debug": false
                    }
                }
            ]
        }

Let me know if you have any other questions that I can help with!

Can you post or do screenshot with video setting in your cam.

Снимок экрана 2020-07-28 в 0 28 03