| manticore
"codito ergo sum"
Summary
Shell script for recording screen content in X11.Prerequisites
- FFMPEG
- libx264
- alsa
Usage
Execute the script (in a terminal console), click at the window to capture, record your action and press q to finish.
You can adjust ffmpeg's parameters like framerate, codecs and audio-device.
Script
1 #!/bin/bash
2 XWINFO=`xwininfo | grep -e Width -e Height -e Absolute`
3 X=`echo $XWINFO | grep -e "Absolute upper-left X:" | cut -d ':' -f 2 | cut -d ' ' -f 2`
4 Y=`echo $XWINFO | grep -e "Absolute upper-left X:" | cut -d ':' -f 3 | cut -d ' ' -f 2`
5 W=`echo $XWINFO | grep -e "Absolute upper-left X:" | cut -d ':' -f 4 | cut -d ' ' -f 2`
6 H=`echo $XWINFO | grep -e "Absolute upper-left X:" | cut -d ':' -f 5 | cut -d ' ' -f 2`
7
8 #ensure odd numbers
9 if [ $(( $W % 2 )) -eq 1 ]
10 then
11 W=$(($W+1))
12 fi
13
14 if [ $(( $H % 2 )) -eq 1 ]
15 then
16 H=$(($H+1))
17 fi
18
19 #capture screen content and sound
20 ffmpeg \
21 -f alsa -ac 2 -i hw:0,0 -acodec pcm_s16le \
22 -f x11grab -r 15 -s ${W}x${H} -i :0.0+${X},${Y} -vcodec libx264 -vpre lossless_ultrafast \
23 -threads 3 \
24 screencapture.mkv
25
26 #convert
27 ffmpeg \
28 -acodec libmp3lame -ab 96k -ac 2 \
29 -vcodec libx264 -vpre slow -crf 22 \
30 -threads 3 \
31 -i screencapture.mkv screencapture.mp4
32
33 #clean-up
34 rm -f screencapture.mkv