record script changes

This commit is contained in:
Luke Smith 2023-01-15 08:30:21 -05:00
parent 9385a569fe
commit c8aa0495eb

View file

@ -9,6 +9,8 @@
# #
# If there is already a running instance, user will be prompted to end it. # If there is already a running instance, user will be prompted to end it.
getdim() { xrandr | sed -n "s/\s*\([0-9]\+x[0-9]\+\).*\*.*/\1/p" ;}
updateicon() { \ updateicon() { \
echo "$1" > /tmp/recordingicon echo "$1" > /tmp/recordingicon
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
@ -16,26 +18,23 @@ updateicon() { \
killrecording() { killrecording() {
recpid="$(cat /tmp/recordingpid)" recpid="$(cat /tmp/recordingpid)"
# kill with SIGTERM, allowing finishing touches.
kill -15 "$recpid" kill -15 "$recpid"
rm -f /tmp/recordingpid rm -f /tmp/recordingpid
updateicon "" updateicon ""
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
sleep 3
kill -9 "$recpid"
exit
} }
screencast() { \ screencast() { \
ffmpeg -y \ ffmpeg -y \
-f x11grab \ -f x11grab \
-framerate 60 \ -framerate 30 \
-s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ -s "$(getdim)" \
-i "$DISPLAY" \ -i "$DISPLAY" \
-f alsa -i default \ -r 24 \
-r 30 \ -use_wallclock_as_timestamps 1 \
-c:v h264 -crf 0 -preset ultrafast -c:a aac \ -f alsa -thread_queue_size 1024 -i default \
-c:v h264 \
-crf 0 -preset ultrafast -c:a aac \
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" & "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
echo $! > /tmp/recordingpid echo $! > /tmp/recordingpid
updateicon "⏺️🎙️" updateicon "⏺️🎙️"
@ -43,7 +42,8 @@ screencast() { \
video() { ffmpeg \ video() { ffmpeg \
-f x11grab \ -f x11grab \
-s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ -framerate 30 \
-s "$(getdim)" \
-i "$DISPLAY" \ -i "$DISPLAY" \
-c:v libx264 -qp 0 -r 30 \ -c:v libx264 -qp 0 -r 30 \
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
@ -104,7 +104,7 @@ videoselected()
ffmpeg \ ffmpeg \
-f x11grab \ -f x11grab \
-framerate 60 \ -framerate 30 \
-video_size "$W"x"$H" \ -video_size "$W"x"$H" \
-i :0.0+"$X,$Y" \ -i :0.0+"$X,$Y" \
-c:v libx264 -qp 0 -r 30 \ -c:v libx264 -qp 0 -r 30 \