Skip to content

Instantly share code, notes, and snippets.

@mazurkin
Created November 23, 2024 14:20
Show Gist options
  • Save mazurkin/777fabe8725de43c549881c9bffe318b to your computer and use it in GitHub Desktop.
Save mazurkin/777fabe8725de43c549881c9bffe318b to your computer and use it in GitHub Desktop.
How to effectively share a smaller area of a huge display
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
set -o monitor
set -o noglob
# https://ffmpeg.org/ffmpeg-devices.html#x11grab
# https://ffmpeg.org/ffmpeg-filters.html#eq
# https://ffmpeg.org/ffmpeg-utils.html#Color
# https://trac.ffmpeg.org/wiki/Capture/Desktop
# https://superuser.com/questions/1776901/streaming-video-over-udp-with-ffmpeg-h264-low-latency
# https://stackoverflow.com/questions/16658873/how-to-minimize-the-delay-in-a-live-streaming-with-ffmpeg
# https://zayne.io/articles/vintage-camera-filters-with-ffmpeg
V_WIDTH=1920
V_HEIGHT=1080
V_FORMAT=apng
V_FPS=10
V_FILTER_FONT="/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf"
V_FILTER_EXPR="drawtext=fontfile=${V_FILTER_FONT}:text='Nick Mazurkin':fontcolor=CCCCCC:fontsize=24:box=1:[email protected]:boxborderw=10:x=(w-text_w-20):y=(h-text_h-20)"
#V_FILTER_EXPR="${V_FILTER_EXPR}, eq=brightness=0.0:saturation=0.7"
#V_FILTER_EXPR="${V_FILTER_EXPR}, colortemperature=temperature=5000:mix=0.5"
echo ">>> Press 'q' to exit the streamer"
/usr/bin/stdbuf -i0 -o0 -e0 \
ffmpeg \
-hide_banner -loglevel info -nostats \
-video_size "${V_WIDTH}x${V_HEIGHT}" \
-framerate "${V_FPS}" \
-follow_mouse 200 -draw_mouse 1 -show_region 1 -region_border 2 \
-f x11grab \
-i "${DISPLAY}" \
-vf "${V_FILTER_EXPR}" \
-f "${V_FORMAT}" \
- \
| ffplay \
-hide_banner -loglevel info -nostats \
-x "${V_WIDTH}" -y "${V_HEIGHT}" \
-window_title "screen" \
-autoexit -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 1 -strict experimental -framedrop \
-an \
-sn \
-vf setpts=0 \
-sync ext \
-f "${V_FORMAT}" \
-i -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment