Last active
December 13, 2022 14:51
-
-
Save megumintyan/7d9267458a1fc7b635e92223523913fe to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
FILENAME="ffscrec_`date +%F_%T`.mp4" | |
QUALITY="-qp 30" | |
FPS=60 | |
get_dimensions() { | |
DIM=`slop` | |
W=`echo $DIM | cut -d x -f 1` | |
H=$(echo $(((`echo $DIM | cut -d x -f 2 | cut -d + -f 1`/2)*2))) | |
X=`echo $DIM | cut -d + -f 2` | |
Y=`echo $DIM | cut -d + -f 3` | |
} | |
help() { | |
echo "usage: $0 {options}" | |
echo " without options starts recording without audio" | |
echo "options:" | |
echo " -h, --help show help" | |
echo " -a, --audio record with audio" | |
echo " -d=, --dir= set output directory" | |
echo " -hw, --hwacc hardware acceleration(no audio)" | |
exit 1 | |
} | |
for i in "$@"; do | |
case $i in | |
-h|--help) | |
help | |
;; | |
-a|--audio) | |
AUDIO="-f pulse -ac 2 -i default -c:a aac" | |
;; | |
-d=*|--dir=*) | |
DIR="${i#*=}/" | |
;; | |
-hw|--hwacc) | |
HW1="-vaapi_device /dev/dri/renderD128" | |
HW2="-vf format=nv12,hwupload -c:v h264_vaapi" | |
;; | |
*) | |
help | |
;; | |
esac | |
done | |
get_dimensions | |
ffmpeg $HW1 -video_size ${W}x${H} -framerate $FPS -f x11grab -i :0.0+${X},${Y} $AUDIO $HW2 $QUALITY ${DIR}${FILENAME} | |
# Local Variables: | |
# tab-width: 4 | |
# c-basic-offset: 4 | |
# indent-tabs-mode: t | |
# End: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment