Skip to content

Instantly share code, notes, and snippets.

Last active September 12, 2023 04:18
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Screen recording with ffmpeg under Windows
#!/usr/bin/env bash
# capture screen with ffmpeg and stop it with CTRL-C
if [ -f "$VIDEO" ]; then rm "$VIDEO"; fi
# start video capture
ffmpeg -f gdigrab\
-offset_x 0 \
-offset_y 0 \
-video_size "$SIZE" \
-i desktop \
-show_region 1 \
-pix_fmt yuv420p \
"$VIDEO" > /dev/null 2>&1 &
# run program
echo "Running demo"
sleep 3
# stop video capture
WINPID=$(ps aux | grep ffmpeg | awk '{print $4}')
python -c "import os, signal; os.kill($WINPID, signal.CTRL_C_EVENT)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment