Skip to content

Instantly share code, notes, and snippets.

@Cdaprod
Created March 23, 2025 17:56
Show Gist options
  • Save Cdaprod/1fa1976f02feccc537e07e12cb417f7a to your computer and use it in GitHub Desktop.
Save Cdaprod/1fa1976f02feccc537e07e12cb417f7a to your computer and use it in GitHub Desktop.
Zero-state streaming: no saved files, pure pipeline: Stateless architecture, Portable: works from any Shellfish SSH session, OBS-ready: via browser source or v4l2 loopback (if needed)
#!/bin/bash
# === CONFIG ===
SESSION_NAME="shellfish"
DISPLAY_NAME=":0"
STREAM_PORT="8090"
FFMPEG_PATH=$(which ffmpeg)
WFREC_PATH=$(which wf-recorder)
GNOME_TERM=$(which gnome-terminal)
# === Check environment ===
if [ -z "$FFMPEG_PATH" ] || [ -z "$WFREC_PATH" ] || [ -z "$GNOME_TERM" ]; then
echo "Missing dependencies. Please install: ffmpeg, wf-recorder, gnome-terminal"
exit 1
fi
echo "[+] Spawning terminal on upstairs display for tmux session..."
DISPLAY=$DISPLAY_NAME $GNOME_TERM -- bash -c "tmux attach -t $SESSION_NAME || tmux new -s $SESSION_NAME" &
sleep 2 # give it time to render
# === Start stream ===
echo "[+] Starting MJPEG stream at http://<this-pi-ip>:$STREAM_PORT/"
$WFREC_PATH -x yuv420p -f - | \
$FFMPEG_PATH -f rawvideo -pix_fmt yuv420p -s 1920x1080 -i - \
-c:v mjpeg -f mjpeg "http://0.0.0.0:$STREAM_PORT/" &
echo "[✔] Stream active — connect OBS Browser Source to:"
echo " http://$(hostname -I | awk '{print $1}'):$STREAM_PORT/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment