zoukankan      html  css  js  c++  java
  • linux 使用 byzanz 生成 gif 图片程序

    参考:

    1、软件安装

    $ sudo apt-get install byzanz

    2、脚本下载

    1)byzanz-record-window.sh

    #!/bin/bash
    
    # Delay before starting
    DELAY=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 file
    if [ $# -gt 0 ]; then
        D="--duration=$@"
    else
        echo Default recording duration 10s 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
    
    beep
    byzanz-record --verbose --delay=0 --x=$X --y=$Y --width=$W --height=$H $D
    beep

    2)byzanz-record-region.sh

    #!/bin/bash
    
    # Delay before starting
    DELAY=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 file
    if [ $# -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/xrectsel
    ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1
    
    echo Delaying $DELAY seconds. After that, byzanz will start
    for (( i=$DELAY; i>0; --i )) ; do
        echo $i
        sleep 1
    done
    beep
    byzanz-record --verbose --delay=0 ${ARGUMENTS} $D
    beep

    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 date TIME=$(date +"%Y-%m-%d_%H%M%S") # Delay before starting DELAY=10 # Standard screencast folder FOLDER="$HOME/Pictures" # Default recording duration DEFDUR=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 user USERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1) # Duration and output file if [ $USERDUR -gt 0 ]; then D=$USERDUR else D=$DEFDUR fi # Window geometry 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") # Notify the user of recording time and delay notify-send "GIFRecorder" "Recording duration set to $D seconds. Recording will start in $DELAY seconds." #Actual recording sleep $DELAY beep byzanz-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)克隆代码

    2)编译安装

    ./bootstrap  # required if ./configure is not present
    ./configure --prefix=/usr
    make
    $ 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 duration-seconds save-file-name // 使用鼠标选择要记录的区域
    ./byzanz-record-window.sh duration-seconds save-file-name // 默认选择整个屏幕

    6、试用效果如下

    ./byzanz-record-region.sh

    7、为方便以后使用可以将其添加至环境变量中

    Enjoy it.

  • 相关阅读:
    FortiGate 硬件加速
    RSA modulus too small: 512 < minimum 768 bits
    VMXNET3 vs E1000E and E1000
    BZOJ 1432: [ZJOI2009]Function(新生必做的水题)
    BZOJ 2456: mode(新生必做的水题)
    BZOJ 1968: [Ahoi2005]COMMON 约数研究(新生必做的水题)
    BZOJ 2463: [中山市选2009]谁能赢呢?(新生必做的水题)
    海量数据处理算法总结【超详解】
    POJ 1659 Frogs' Neighborhood(可图性判定—Havel-Hakimi定理)【超详解】
    图的存储结构之邻接表(详解)
  • 原文地址:https://www.cnblogs.com/aqing1987/p/4209551.html
Copyright © 2011-2022 走看看