summaryrefslogtreecommitdiff
path: root/.local/bin/reco
blob: acd977a6bccbd91d5dac292620cfd4f6ef20a48e (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/sh

# references:
# https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/dmenurecord
# https://wiki.archlinux.org/title/FFmpeg#Screen_capture
# https://trac.ffmpeg.org/wiki/Capture/Desktop

# better notify-send? keep send notify-send when recording? or not
# benchmark different encode codecs to choose a better one?
# consider audio, camera ...
# hardware acc? seems no for ffvhuff? see arch wiki

# use tmp instead?
infofile="/tmp/recoinfo"
recodir="$XDG_VIDEOS_DIR/recordings/"
mkdir -p "$recodir"

if [ -e "$infofile" ]; then
	notify-send 'finish recording, start converting'
	kill "$(head -n1 "$infofile")"
	tmpfile="$(tail -n1 "$infofile")"
	ffmpeg -i "$tmpfile" "$recodir/$(time.uuid).mkv" && notify-send 'finish converting'
	rm "$tmpfile" "$infofile"
else
	notify-send 'start recording'
	tmpfile="$(mktemp --suffix '.mkv')"
	# arch wiki way
	# no audio, less cpu use during capturing (fast?), large file size, need convert afterward
	ffmpeg -y -f x11grab -framerate 25 -i "$DISPLAY" -c:v ffvhuff "$tmpfile" &
	printf '%s\n%s' "$!" "$tmpfile" > "$infofile"
fi