Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcamera for raspberry pi configuration #1426

Open
nsayer opened this issue Nov 14, 2023 · 3 comments
Open

libcamera for raspberry pi configuration #1426

nsayer opened this issue Nov 14, 2023 · 3 comments
Labels
tested config A new tested configuration

Comments

@nsayer
Copy link

nsayer commented Nov 14, 2023

Manufacturer/Model:

Raspberry Pi camera with the new libcamera support enabled.

This allows you to use the tuning files for noir cameras (among other things).

It's a particularly ugly hack - you use a shell script that pipes the output of either libcamera-vid or libcamera-jpeg into ffmpeg

Homebridge Config:

"videoConfig": {
                        "videoProcessor": "/path_to_bin_directory/fakeffmpeg",
                        "source": "video -video_size 1640x1232 -framerate 30 -input_format h264",
                        "stillImageSource": "still -video_size 1640x1232 -input_format mjpeg",
                        "maxStreams": 1,
                        "maxWidth": 1640,
                        "maxHeight": 1232,
                        "maxFPS": 30,
                        "vcodec": "copy"
                    }

Additional Information:

This is the fakeffmpeg script:

#! /bin/sh

killall libcamera-vid
option=$1; shift
if [ $option = video ]; then
exec libcamera-vid -n --tuning-file /usr/share/libcamera/ipa/rpi/vc4/imx219_noir.json --width 1640 --height 1232 -t 0 -o - | ffmpeg -i - $@
elif [ $option = still ]; then
exec libcamera-jpeg -n --tuning-file /usr/share/libcamera/ipa/rpi/vc4/imx219_noir.json --width 1640 --height 1232 -t 1 -o - | ffmpeg -i - $@
else
exec ffmpeg $option $@
fi
@nsayer nsayer added the tested config A new tested configuration label Nov 14, 2023
@Sarahlizzy
Copy link

The config didn't work for me. I had to move videoProcessor to the top level.

@i0ntempest
Copy link

Process does not terminate after video stops. Any workarounds?

@nsayer
Copy link
Author

nsayer commented May 12, 2024

A new and improved version.

First, here's the fake FFmpeg script:

#! /bin/sh

export TUNE=/usr/share/libcamera/ipa/rpi/pisp/imx219_noir.json 
killall libcamera-vid
option=$1; shift
if [ $option = video ]; then
libcamera-vid -n --tuning-file $TUNE --codec yuv420 --width 1280 --height 720 --framerate 15 -t 0 -o - | exec ffmpeg -f rawvideo -pix_fmt yuvj420p -s:v 1280x720 -framerate 15 -i - "$@"
elif [ $option = still ]; then
libcamera-jpeg -n --tuning-file $TUNE --width 1280 --height 720 -t 1 -o - | exec ffmpeg -i - "$@"
else
exec ffmpeg $option $@
fi

And simply use "video" as the "source" and "still" as the "stillImageSource". Lastly, use "libx264" as the "vcodec".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested config A new tested configuration
Projects
None yet
Development

No branches or pull requests

3 participants