Files
scripts/scrv
2026-05-26 19:21:54 +09:00

42 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Video Quality
# The range of the CRF scale is 051, where 0 is lossless, 23 is the default,
# and 51 is worst quality possible. A lower value generally leads to higher
# quality, and a subjectively sane range is 1728
QUALITY=28
if ! command -v slop &> /dev/null
then
echo "slop command not found. Please install slop."
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: $0 <output.mp4>"
exit 1
fi
filename="$1"
echo "Select the desktop area to record."
coords=$(slop -f "%x %y %w %h" 2>/dev/null)
x=$(echo $coords | awk '{print $1}')
y=$(echo $coords | awk '{print $2}')
width=$(echo $coords | awk '{print $3}')
height=$(echo $coords | awk '{print $4}')
width=$((width / 2 * 2))
height=$((height / 2 * 2))
echo "Recording started. Press 'q' to stop recording."
#\#-f alsa -i pulse -c:v libx264 -preset ultrafast -crf ${QUALITY} \
#-c:v libx264 -preset ultrafast -crf ${QUALITY} \
#-tune zerolatency -pix_fmt yuv420p -f mp4 $filename
ffmpeg -f x11grab -loglevel quiet -s ${width}x${height} -i ${DISPLAY}+$x,$y \
-c:v libx264 -pix_fmt yuv420p -crf ${QUALITY} -preset ultrafast -f mp4 $filename
echo "Recording stopped."