Here's the modified/improved version of a screencast (record a video+audio track of your current desktop session) script which i originally posted on FreeBSD Forums.
- the script relies on ffmpeg for recording and xinput to get $DISPLAY size;
- user aragats@ on FBSD Forums contributed refining it;
- plain OSS is assumed to be the default audio backend;
- the script also provides auto-naming for the new record (depending on date), with exponential indexing
#!/usr/bin/env bash
mouse=6 # get this ID from "xinput --list"
audio=/dev/dsp5
today=$(date +"%Y%m%d")
fname_prefix="/tmp/screen_"
number=0
echo Select top left corner by clicking button 1
while true ; do
#sleep 1
eval `xinput --query-state $mouse | grep 'button\|valuator'`
if [ "down" = "${button[1]}" ] ; then
X0=${valuator[0]}
Y0=${valuator[1]}
break
fi
done
echo Got: X0=$X0 Y0=$Y0
echo Select bottom right corner by clicking button 3
while true ; do
#sleep 1
eval `xinput --query-state $mouse | grep 'button\|valuator'`
if [ "down" = "${button[3]}" ] ; then
X1=${valuator[0]}
Y1=${valuator[1]}
break
fi
done
echo Got: X1=$X1 Y1=$Y1
X=$((X1-X0))
Y=$((Y1-Y0))
if [ $X -le 0 ] || [ $Y -le 0 ] ; then
echo You got negative dimensions: ${X}x${Y}
exit 1
fi
echo Video size: ${X}x${Y}
while [ -f $fname_prefix$today$count.mkv ]
do
$((number+=1))
count=$(printf -- '-%02d' $number)
done
fname="$fname_prefix$today$count.mkv"
ffmpeg -y \
-thread_queue_size 1024 \
-f oss -i $audio -ac 2 \
-f x11grab -r 60 \
-s ${X}x${Y} \
-i :0.0+$X0,$Y0 -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \
$fname
echo $fname