diff --git a/.local/bin/dmenurecord b/.local/bin/dmenurecord index b83a7c5..990b7b3 100755 --- a/.local/bin/dmenurecord +++ b/.local/bin/dmenurecord @@ -9,6 +9,8 @@ # # 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() { \ echo "$1" > /tmp/recordingicon pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" @@ -16,26 +18,23 @@ updateicon() { \ killrecording() { recpid="$(cat /tmp/recordingpid)" - # kill with SIGTERM, allowing finishing touches. kill -15 "$recpid" rm -f /tmp/recordingpid updateicon "" pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" - # even after SIGTERM, ffmpeg may still run, so SIGKILL it. - sleep 3 - kill -9 "$recpid" - exit } screencast() { \ ffmpeg -y \ -f x11grab \ - -framerate 60 \ - -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ + -framerate 30 \ + -s "$(getdim)" \ -i "$DISPLAY" \ - -f alsa -i default \ - -r 30 \ - -c:v h264 -crf 0 -preset ultrafast -c:a aac \ + -r 24 \ + -use_wallclock_as_timestamps 1 \ + -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" & echo $! > /tmp/recordingpid updateicon "⏺️🎙️" @@ -43,7 +42,8 @@ screencast() { \ video() { ffmpeg \ -f x11grab \ - -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ + -framerate 30 \ + -s "$(getdim)" \ -i "$DISPLAY" \ -c:v libx264 -qp 0 -r 30 \ "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & @@ -104,7 +104,7 @@ videoselected() ffmpeg \ -f x11grab \ - -framerate 60 \ + -framerate 30 \ -video_size "$W"x"$H" \ -i :0.0+"$X,$Y" \ -c:v libx264 -qp 0 -r 30 \