summaryrefslogtreecommitdiff
path: root/toggle-screencast.sh
diff options
context:
space:
mode:
Diffstat (limited to 'toggle-screencast.sh')
-rwxr-xr-xtoggle-screencast.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/toggle-screencast.sh b/toggle-screencast.sh
new file mode 100755
index 0000000..dc26d63
--- /dev/null
+++ b/toggle-screencast.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+## Config
+output_dir=~/videos/screencasts
+sound_device=/dev/dsp6
+
+
+## Start recording
+start_recording() {
+ touch /tmp/cast.mkv
+ notify-send -t 3000 "Starting screencast." "3...2...1..."
+ sleep 4
+ pkill -76 i3blocks
+ ffmpeg -video_size 1920x1080 \
+ -framerate 50 \
+ -thread_queue_size 512 -f x11grab -i :0.0+0,0 \
+ -thread_queue_size 512 -f oss -i "$sound_device" \
+ -vcodec libx264rgb -crf 0 -preset:v ultrafast \
+ -acodec pcm_s16le \
+ -af aresample=async=1:first_pts=0 \
+ -y \
+ /tmp/cast.mkv
+}
+
+
+## Stop recording
+stop_recording() {
+ pkill -2 ffmpeg
+ output_file="$output_dir"/cast_"$(date '+%F-%H-%M-%S')".mkv
+ mv /tmp/cast.mkv "$output_file"
+ notify-send "Screencast saved" "$output_file"
+ pkill -76 i3blocks
+ exit
+}
+
+
+## Main
+mkdir -p "$output_dir"
+[ -f /tmp/cast.mkv ] && stop_recording || start_recording