summaryrefslogtreecommitdiff
path: root/dot/local/bin/selfie
blob: 5046fad6fbb0279cb5d70d9102c9847cd27d964d (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

AUDIO_DEVICE=pulse
VIDEO_DEVICE=/dev/video0

MAX_RECORDING_TIME=00:05:00

NOW=$(date -Iseconds)

OUTPUT=recording.${NOW//[:T]/.}.avi
OUTPUT_LINK=recording.latest.avi

record()
{
	local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
	ffmpeg -hide_banner -loglevel error -stats \
		$timeout -f video4linux2    -i "$VIDEO_DEVICE" \
		$timeout -f "$AUDIO_DEVICE" -i default \
		-f xv win \
		-c:a mp3 \
		-c:v libxvid \
		"$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"