homebridge-plugins / homebridge-camera-ffmpeg

Homebridge Plugin Providing FFmpeg-based Camera Support
https://homebridge-plugins.github.io/homebridge-camera-ffmpeg/
Apache License 2.0
1.09k stars 227 forks source link

Raspberry Pi v3 NOIR Camera - Config Being Halted? #1427

Closed MattGeale closed 10 months ago

MattGeale commented 11 months ago

Manufacturer/Model: Raspberry Pi Noir v3 Camera

Homebridge Config:

        {
            "name": "livestream",
            "cameras": [
                {
                    "name": "livestream",
                    "unbridge": true,
                    "videoConfig": {
                        "source": "-i rtmp://172.22.20.81:1935/live/app",
                        "stillImageSource": "still -video_size 1920x1080 -input_format mjpeg"
                    }
                }
            ],
            "_bridge": {
                "username": "<mac addr>",
                "port": 34354
            },
            "platform": "Camera-ffmpeg"
        }

Additional Information: This might not be something to do with the homebridge service, and might not be anything to do with the ffmpeg config on homebridge so apologies if not. Anyway, the following is the script that I use to livestream the footage from the pi to homebridge. When the script first launches, runs like a tank. No issues. Only when exiting the stream, it errors with exit code 1.


Width=1920
Height=1080

Framerate=24

Bitrate=3500000

Preset=veryfast

HDR=0

libcamera-vid -t 0 -n --inline \
 --width $Width --height $Height \
 --framerate $Framerate \
 --hdr $HDR --bitrate $Bitrate -o - | \
ffmpeg -re -f lavfi -i anullsrc -c:a aac -r 30 \
-i pipe: -g $(($Framerate * 2)) \
-strict experimental -vcodec copy -map 0:a -map 1:v -b:v $Bitrate -preset veryfast \
-f flv -listen 1 rtmp://0.0.0.0:1935/live/app

Whenever I stop watching the stream on either VLC or on homekit, I get this error:

livestream.service - Custom Raspberry Pi Camera Livestreaming Service
     Loaded: loaded (/lib/systemd/system/livestream.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2023-11-15 19:29:55 AEST; 3s ago
   Duration: 34min 37.129s
    Process: 2758 ExecStart=/home/pi/livestream.sh (code=exited, status=1/FAILURE)
   Main PID: 2758 (code=exited, status=1/FAILURE)
        CPU: 13.545s

Nov 15 19:29:55 raspberrypi livestream.sh[2760]: Error writing trailer of rtmp://0.0.0.0:1935/live/app: Connection reset by peer
Nov 15 19:29:55 raspberrypi livestream.sh[2760]: frame=  288 fps= 23 q=-1.0 Lsize=    5274kB time=00:00:09.71 bitrate=4445.8kbits/s speed=0.782x
Nov 15 19:29:55 raspberrypi livestream.sh[2760]: video:5134kB audio:152kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Nov 15 19:29:55 raspberrypi livestream.sh[2760]: Error closing file rtmp://0.0.0.0:1935/live/app: Broken pipe
Nov 15 19:29:55 raspberrypi livestream.sh[2760]: Conversion failed!
Nov 15 19:29:55 raspberrypi livestream.sh[2759]: terminate called after throwing an instance of 'std::runtime_error'
Nov 15 19:29:55 raspberrypi livestream.sh[2759]:   what():  failed to write output bytes
Nov 15 19:29:55 raspberrypi systemd[1]: livestream.service: Main process exited, code=exited, status=1/FAILURE
Nov 15 19:29:55 raspberrypi systemd[1]: livestream.service: Failed with result 'exit-code'.
Nov 15 19:29:55 raspberrypi systemd[1]: livestream.service: Consumed 13.545s CPU time.

Any help would be hugely appreciated <3

Sunoo commented 11 months ago

I’m not sure I fully understand your setup, but it looks like it’s probably an issue with livestream.sh?

MattGeale commented 11 months ago

I’m not sure I fully understand your setup, but it looks like it’s probably an issue with livestream.sh?

Livestream.sh is the above script. I thought that could be it, but I'm not 100% sure what it could be.

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.