Skip to content

Instantly share code, notes, and snippets.

@phoboslab
Created August 1, 2026 17:31
Show Gist options
  • Select an option

  • Save phoboslab/dcebe3785f8b0992a6640b4a1597bd3f to your computer and use it in GitHub Desktop.

Select an option

Save phoboslab/dcebe3785f8b0992a6640b4a1597bd3f to your computer and use it in GitHub Desktop.
#!/bin/sh
mpv av://v4l2:/dev/video0 \
--profile=low-latency \
--untimed \
--no-cache \
--demuxer-lavf-o=input_format=yuyv422,video_size=720x576 \
--demuxer-readahead-secs=0 \
--vd-lavc-threads=1 \
--fps=30 \
--video-latency-hacks=yes \
>/dev/null 2>&1 &
VID_PID=$!
mpv av://alsa:hw:1,0 \
--profile=low-latency \
--no-cache \
--audio-buffer=0.05 \
--audio-samplerate=48000 \
--audio-channels=2 \
>/dev/null 2>&1 &
AUD_PID=$!
# Cleanup handler
cleanup() {
echo "Stopping mpv..."
kill "$VID_PID" "$AUD_PID" 2>/dev/null
wait "$VID_PID" "$AUD_PID" 2>/dev/null
exit 0
}
# Catch Ctrl-C, kill, terminal close
trap cleanup INT TERM EXIT
# Wait until one exits
wait "$VID_PID" "$AUD_PID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment