Last active
September 12, 2023 04:18
-
-
Save elsamuko/9c3fe69f00a0f847251ffa3ef1d080a2 to your computer and use it in GitHub Desktop.
Screen recording with ffmpeg under Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# capture screen with ffmpeg and stop it with CTRL-C | |
# https://trac.ffmpeg.org/ticket/6336 | |
# https://bugs.python.org/issue42962 | |
SIZE="1920x1080" | |
VIDEO="video.mp4" | |
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