安装 byzanz
sudo apt-get install byzanz
如果软件不存在,先添加下面的软件源再安装
sudo add-apt-repository ppa:fossfreedom/byzanzsudo apt-get update && sudo apt-get install byzanz
直接录制
byzanz-record –duration=10 –x=100 –y=100 –width=600 –height=600 output.gif
–duration 录制时长
–x x坐标
–y y坐标
–width 录制宽度
–height 录制高度
–output.gif 录制生成文件名
新建脚本byzanz-record-window.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #!/bin/bash
DELAY=5
if [ $# -gt 0 ]; then D="--duration=$@" else echo Default recording duration 5s to /tmp/recorded.gif D="--duration=10 /tmp/recorded.gif" fi XWININFO=$(xwininfo) read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO") read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO") read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO") read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")
echo Delaying $DELAY seconds. After that, byzanz will start for (( i=$DELAY; i>0; --i )) ; do echo $i sleep 1 done
byzanz-record --verbose --delay=0 --x=$X --y=$Y --width=$W --height=$H $D
|
记得加上执行权限
chmod a+x byzanz-record-window.sh
录制视频
./byzanz-record-window 5 -c output.gif