Skip to content

Instantly share code, notes, and snippets.

@nathan818fr
Last active October 23, 2024 10:20
Show Gist options
  • Save nathan818fr/663189a506152c97a8d1518a962e3e9b to your computer and use it in GitHub Desktop.
Save nathan818fr/663189a506152c97a8d1518a962e3e9b to your computer and use it in GitHub Desktop.
Real-time preview of Xvfb display using ffmpeg (w/ x11grab) and mpv. Note: ffplay works but offers too few options compared to mpv, notably the choice of fullscreen monitor via cli.
xvfb_display=':99.0'
xvfb_width=1920
xvfb_height=1080
xvfb_fps=30
xvfb_format='yuv420p'
ffmpeg \
-hide_banner \
-f x11grab -i "$xvfb_display" -video_size "${xvfb_width}x${xvfb_height}" -framerate "$xvfb_fps" \
-f rawvideo -pix_fmt "$xvfb_format" - |
mpv \
--no-config --no-terminal --no-osc --no-stop-screensaver \
--demuxer=rawvideo --demuxer-readahead-secs=0 --cache-secs=0 --untimed \
--demuxer-rawvideo-w="$xvfb_width" --demuxer-rawvideo-h="$xvfb_height" --demuxer-rawvideo-fps="$xvfb_fps" \
--demuxer-rawvideo-mp-format="$xvfb_format" \
--no-audio \
-- -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment