Du screencast sous GNU/Linux partie 4

Le script *screencaster.sh* final qui semble fonctionner sur toute Buntu et dérivée, pour peu que l'on se conforme aux notes :

#!/bin/bash
#
# screencaster.sh - script to make screencasts on Linux 
#
# For information about using this script:
# http://okiebuntu.homelinux.com/blog/?p=175
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see .
# Nécessite libavcodec-extra-52
# Il faut peut-être ffmpeg depuis le dépôt Medibuntu. Il faudra aussi ajouter un peu de code pour faire en sorte que la taille et l'offset soit divisible par deux
# parec a besoin d'un monitor pour fonctionner : trouver un input avec pactl list | egrep -A2 '^(\*\*\* )?Source #'
# On peut arrêter l'enregistrement en configurant un raccourci clavier et en utilisant xdotool : xdotool search --onlyvisible --classname "gnome-terminal" key "Return"
#

# Config
monitor="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor"
echo "set-source-mute ${monitor} false" | pacmd >/dev/null
threads=2
volume=0.25

# list of programs we depend on
progs="xdpyinfo grep head sed ffmpeg pacat parec sox libavcodec-extra-52"

# check for programs we depend on
result=0
for prog in $progs
do
  type -p $prog > /dev/null
  if (( $? != 0 )); then
    echo "Error: Cannot find required program '$prog'"
    result=1
  fi
done
if (( $result != 0 )); then
  exit 1
fi

screenSize="$(xwininfo -root | grep 'geometry' | awk '{print $2;}')" # default if we cant detect it
screenOffset="0,0" # default to top-left corner
frameRate="24" # default frame rate
baseName="`date +%Y%m%d`-`date +%H%M%S`-screencast" # default base filename for capture

# attempt to detect the dimension of the screen for the default
dimensions=`xdpyinfo | grep 'dimensions:' | head -1 | \
  sed -e 's/^.* \([0-9]\+x[0-9]\+\) pixels.*$/\1/'`
if [[ "$dimensions" =~ [0-9]+x[0-9]+ ]]; then
  screenSize=$dimensions
fi

# collect command line settings
while getopts 'hs:o:t:r:p:w' param ; do
  case $param in
    s)
      screenSize="$OPTARG"
      ;;
    o)
      screenOffset="$OPTARG"
      ;;
    t)
      timeToRecord="$OPTARG"
      ;;
    w)
      INFO=$(xwininfo)
      WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+')
      WIN_XY=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' )
      screenOffset="$WIN_XY"
      screenSize="$WIN_GEO"
      ;;
    r)
      frameRate="$OPTARG"
      ;;
    *)
      echo ""
      echo "$0 - records screencast"
      echo ""
      echo "$0 [options] [base-filename]"
      echo ""
      echo "options:"
      echo "	-h            show brief help"
      echo "	-s      screensize to record as x"
      echo "	-o    offset off recording area as ,"
      echo "	-t 

Voilà, prochaine étape : un peu de python pour donner une interface simple. À noter que sous Gnome 3, un outil de screencast est incorporé d'office, via un raccourci-clavier dont personne ne se souvient, et qui n'est pas paramétrable ; il prend tout l'écran. Ma solution permet au moins de lancer un screencast à distance, selon des paramètres (30 fps pour une vidéo en HD, c'est un *must* ), et surtout de choisir une fenêtre d'un simple clic.

----

Accueil

Permaliens :