add optional bayerer

This commit is contained in:
legop3
2025-12-01 22:28:33 -05:00
parent 7a36d988ba
commit 4d57e679bf
2 changed files with 12 additions and 1 deletions
+1
View File
@@ -19,6 +19,7 @@ Lightweight systemd service that serves a JPEG snapshot from any MJPEG-capable w
- `QUALITY=5` (ffmpeg MJPEG quality; lower is higher quality)
- `PORT=8080`
- `WORKDIR=/run/roomcam`
- `INPUT_FORMAT=mjpeg` (use `bayer_grbg8` for OV534/raw Bayer cams; auto-converts to JPEG)
3) Point the server `roomCameras[].url` to `http://<host>:8080/snapshot.jpg`.
Notes:
+11 -1
View File
@@ -7,6 +7,8 @@ RESOLUTION="${RESOLUTION:-640x480}"
QUALITY="${QUALITY:-5}" # ffmpeg MJPEG quality (lower is better)
PORT="${PORT:-8088}"
WORKDIR="${WORKDIR:-/run/roomcam}"
# Optional: set INPUT_FORMAT=bayer_grbg8 to transcode raw Bayer cams (e.g., OV534) to JPEG.
INPUT_FORMAT="${INPUT_FORMAT:-mjpeg}"
mkdir -p "${WORKDIR}"
SNAPSHOT_PATH="${WORKDIR}/snapshot.jpg"
@@ -18,9 +20,17 @@ cleanup() {
trap cleanup EXIT
trap 'exit 0' SIGTERM INT
FFMPEG_INPUT_ARGS=(-f v4l2 -input_format "${INPUT_FORMAT}" -video_size "${RESOLUTION}" -i "${DEVICE}")
FFMPEG_FILTERS=()
if [[ "${INPUT_FORMAT}" == bayer_* ]]; then
# Convert raw Bayer to a JPEG-friendly pixel format.
FFMPEG_FILTERS=(-pix_fmt yuv420p)
fi
/usr/bin/ffmpeg \
-loglevel warning -nostats \
-f v4l2 -input_format mjpeg -video_size "${RESOLUTION}" -i "${DEVICE}" \
"${FFMPEG_INPUT_ARGS[@]}" \
"${FFMPEG_FILTERS[@]}" \
-q:v "${QUALITY}" \
-f image2 -update 1 "${SNAPSHOT_PATH}" &
FFMPEG_PID=$!