首页 > 代码库 > linux 使用 byzanz 生成 gif 图片程序
linux 使用 byzanz 生成 gif 图片程序
参考:
- http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast
1、软件安装
$ sudo apt-get install byzanz
2、脚本下载
1)byzanz-record-window.sh
#!/bin/bash# Delay before startingDELAY=10# Sound notification to let one know when recording is about to start (and ends)beep() { paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &}# Duration and output fileif [ $# -gt 0 ]; then D="--duration=$@"else echo Default recording duration 10s to /tmp/recorded.gif D="--duration=10 /tmp/recorded.gif"fiXWININFO=$(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 startfor (( i=$DELAY; i>0; --i )) ; do echo $i sleep 1donebeepbyzanz-record --verbose --delay=0 --x=$X --y=$Y --width=$W --height=$H $Dbeep
2)byzanz-record-region.sh
#!/bin/bash# Delay before startingDELAY=10# Sound notification to let one know when recording is about to start (and ends)beep() { paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &}# Duration and output fileif [ $# -gt 0 ]; then D="--duration=$@"else echo Default recording duration 10s to /tmp/recorded.gif D="--duration=10 /tmp/recorded.gif"fi# xrectsel from https://github.com/lolilolicon/xrectselARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1echo Delaying $DELAY seconds. After that, byzanz will startfor (( i=$DELAY; i>0; --i )) ; do echo $i sleep 1donebeepbyzanz-record --verbose --delay=0 ${ARGUMENTS} $Dbeep
3)byzanz-record-window-gui.sh
#!/bin/bash# AUTHOR: (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc)# NAME: GIFRecord 0.1# DESCRIPTION: A script to record GIF screencasts.# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)# DEPENDENCIES: byzanz,gdialog,notify-send (install via sudo add-apt-repository ppa:fossfreedom/byzanz;
# sudo apt-get update && sudo apt-get install byzanz gdialog notify-osd)# Time and dateTIME=$(date +"%Y-%m-%d_%H%M%S")# Delay before startingDELAY=10# Standard screencast folderFOLDER="$HOME/Pictures"# Default recording durationDEFDUR=10# Sound notification to let one know when recording is about to start (and ends)beep() { paplay /usr/share/sounds/freedesktop/stereo/message-new-instant.oga &}# Custom recording duration as set by userUSERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1)# Duration and output fileif [ $USERDUR -gt 0 ]; then D=$USERDURelse D=$DEFDURfi# Window geometryXWININFO=$(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")# Notify the user of recording time and delaynotify-send "GIFRecorder" "Recording duration set to $D seconds. Recording will start in $DELAY seconds."#Actual recordingsleep $DELAYbeepbyzanz-record -c --verbose --delay=0 --duration=$D --x=$X --y=$Y --width=$W --height=$H "$FOLDER/GIFrecord_$TIME.gif"beep# Notify the user of end of recording.notify-send "GIFRecorder" "Screencast saved to $FOLDER/GIFrecord_$TIME.gif"
3、安装脚本依赖的程序
1)克隆代码
- https://github.com/lolilolicon/xrectsel.git
2)编译安装
./bootstrap # required if ./configure is not present./configure --prefix=/usrmake$ sudo make instal
注:在执行
./bootstrap
时若出现以下错误
./bootstrap: line 1: autoreconf: command not found
解决办法是:
$ sudo apt-get install autoconf
4、配置脚本执行权限
$ sudo chmod 755 ./byzanz-record-region.sh $ sudo chmod 755 ./byzanz-record-window.sh $ sudo chmod 755 ./byzanz-record-window-gui.sh
5、试用效果如下
./byzanz-record-region.sh
6、为方便以后使用可以将其添加至环境变量中
Enjoy it.
linux 使用 byzanz 生成 gif 图片程序
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。