ubuntuusers.de

Screencast Toggle, avconv 2.0

Autor:
mrkramps
Datum:
29. Juli 2014 23:14
Code:
 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
28
29
30
31
32
33
34
35
36
37
#!/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