1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
RECORDER=avconv
THREADS=0
AUDIO=alsa
CHANNELS=2
SOUNDCARD=pulse
FPS=40
#Constant Rate Factor(0 is the highest quality 50 is the lowest)
CRF=18
PRESET=ultrafast # slow, fast, superfast, ultrafast
ACODEC=libmp3lame
DIRECTORY=$HOME/Videos/
FILENAME=video`date +%d-%m-%Y_%H.%M`.mp4

CMD=`xwininfo | awk '/Width/{printf"'$RECORDER' -f x11grab -s "$2"x"}/Height/{printf$2" -i '$DISPLAY'"}/Corners/{gsub(/\+/,",",$2);sub(/,/,"+",$2);print$2" -f '$AUDIO' -ac '$CHANNELS' -i '$SOUNDCARD' -r '$FPS' -vcodec libx264 -preset '$PRESET' -crf '$CRF' -acodec '$ACODEC' -ab 256k -async 0 -f mp4 -threads '$THREADS'"}'`
CMD="${CMD} -vf scale='iw+mod(iw,2):ih+mod(ih,2)' $DIRECTORY$FILENAME"
# -vf scale='iw+mod(iw,2):ih+mod(ih,2)'  makes sure the width and height are diviseable by 2 (needed for libx264)


$CMD