#!/bin/bash # Dependencies: libav-tools # Usage: ./script to start and ./script again to stop # set -x rate="25" area="1920x1080" res="1280x720" screen="0" display="0" outdir="$HOME/Videos/Screencasts" outfile="$outdir/$(date +'%Y-%m-%d_%H-%M-%S').flv" pidfile="/tmp/screencast.pid" if [ ! -d "$outdir" ] then mkdir -p "$outdir" notify-send -i folder-videos "SCREENCAST DIRECTORY" \ "A directory for screencast was created at: $outdir" fi if [ -e "$pidfile" ] then kill "$(cat $pidfile)" rm "$pidfile" notify-send -i gnome-screenshot "SCREENCAST STOPPED" \ "The screencast was saved to: $outfile" else notify-send -i gnome-screenshot "SCREENCAST STARTED" \ "The screencast will be saved to: $outfile" avconv -v quiet -f x11grab -r "$rate" -s "$area" -i :"$screen"."$display" \ -s "$res" -vcodec libx264 "$outfile" & echo $! > /tmp/screencast.pid fi