summaryrefslogtreecommitdiff
path: root/dot/local/bin/screeny
blob: 8ecf2d0ce4f2982a864d3e3730ccdc20ceee5099 (plain)
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
#!/bin/bash
die() { printf '%s: Error: %s\n' "$0" "$*" >&2; exit 1; }
[ "$DISPLAY" ] || die 'no $DISPLAY set.  Try launching from a new xterm.'

AUDIO_DEVICE=pulse

NOW=$(date -Iseconds)

OUTPUT=screen-capture.${NOW//[:T]/.}.avi
OUTPUT_LINK=screen-capture.latest.avi

# ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0 out.mpg

record()
{
	local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
	ffmpeg -hide_banner -loglevel error -stats \
		$timeout -f x11grab -framerate 25 -video_size 1280x800 -i "$DISPLAY" \
		$timeout -f "$AUDIO_DEVICE" -i default \
		-c:a mp3 \
		-c:v libxvid -qscale:v 3 \
		"$1"
}

silently() { "$@" >/dev/null 2>&1; }

silently amixer-enable-mic
banish
record "$OUTPUT"

[ -h "$OUTPUT_LINK" -o ! -e "$OUTPUT_LINK" ] && ln -sf "$OUTPUT" "$OUTPUT_LINK"