blob: 0088ceaa9753a4dbe3089edb8912763b502a39bf (
plain) (
tree)
|
|
#!/bin/sh
output_dir=~/videos/screencasts
#sound_device=/dev/dsp4.0
#-thread_queue_size 512 -f oss -i "$sound_device" \
prompt_transcode() {
choice=$(dmenu -p "Transcode now?" << EOF
no
yes
EOF
)
output_file="$output_dir"/cast_"$(date '+%F-%H-%M-%S')"
if [ $choice == "yes" ]
then
transcode_now "$output_file".mp4
else
transcode_later "$output_file".mkv
fi
}
transcode_now() {
notify-send "Transcoding..." "$1"
ffmpeg -i /tmp/cast.mkv "$1" && rm /tmp/cast.mkv
notify-send "Transcode done!" "$1"
}
transcode_later() {
mv /tmp/cast.mkv "$1"
notify-send "Screencast saved!" "$1"
}
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 \
-vcodec libx264rgb -crf 0 -preset:v ultrafast \
-acodec pcm_s16le \
-af aresample=async=1:first_pts=0 \
-y \
/tmp/cast.mkv
}
stop_recording() {
pkill -2 ffmpeg
notify-send "Screencast stopped."
prompt_transcode
pkill -76 i3blocks
exit
}
# main
mkdir -p "$output_dir"
[ -f /tmp/cast.mkv ] && stop_recording || start_recording
|