diff options
| author | xAlpharax <42233094+xAlpharax@users.noreply.github.com> | 2026-08-04 01:21:17 +0300 |
|---|---|---|
| committer | xAlpharax <42233094+xAlpharax@users.noreply.github.com> | 2026-08-04 01:21:17 +0300 |
| commit | 9763dd58e32f5f4726dc0188ee9a0c17147be466 (patch) | |
| tree | 8311166c6777d9806bf789974c0dce05234b3de7 /xrec | |
| parent | 8579e0cdb54b5305bfbe167d19dea89b12f76575 (diff) | |
Changes to be committed:
modified: Vencord/settings/settings.json
modified: X11/xinit
modified: appimageupdate
deleted: backlight
modified: btop/btop.conf
modified: clockpower
modified: htop/htoprc
modified: keybinds
modified: lock
modified: nvim/init.vim
deleted: qBittorrent/ICEBERG.qbtheme
deleted: qBittorrent/ayuDark.qbtheme
deleted: vpn
modified: xrec
modified: zsh/aliases
modified: zsh/env
modified: zsh/zshrc
Diffstat (limited to 'xrec')
| -rwxr-xr-x | xrec | 51 |
1 files changed, 46 insertions, 5 deletions
@@ -2,18 +2,59 @@ set -e -recordingPATH=~/media/screenrecords/ +recordingPATH="$HOME/media/screenrecords" +PID_FILE="/tmp/ffmpeg_screenrecord.pid" + +mkdir -p "$recordingPATH" + +# Detect NVENC support; fallback to fast CPU encoding if no NVIDIA GPU is detected +if command -v nvidia-smi &> /dev/null && nvidia-smi &> /dev/null; then + ENCODER_FLAGS="-c:v h264_nvenc -preset p6 -tune hq -rc constqp -qp 17" +else + ENCODER_FLAGS="-c:v libx264 -preset ultrafast -crf 17" # or medium/slow to be on par with p6 but ehh +fi case $1 in start) - dunstify -t 3000 -i /dev/null " Recording Starts In 3 Seconds" + if [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then + dunstify -t 3000 -i /dev/null "⚠️ Recording is already running!" + exit 1 + fi + + dunstify -t 3000 -i /dev/null " Recording Starts In 3 Seconds" sleep 3 - ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0+0,0 -crf 16 ${recordingPATH}screenrecording_$(($(ls $recordingPATH | wc -l)+1)).mp4 ;; + + TIMESTAMP=$(date +'%Y-%m-%d_%H-%M-%S') + OUTPUT_FILE="${recordingPATH}/screenrecording_${TIMESTAMP}.mp4" + + # Standard yuv420p conversion allows players to auto-expand blacks properly + ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0+0,0 \ + $ENCODER_FLAGS -profile:v high -pix_fmt yuv420p -movflags +faststart \ + "$OUTPUT_FILE" >/dev/null 2>&1 & + + echo $! > "$PID_FILE" + ;; stop) - pkill ffmpeg - dunstify -t 3000 -i /dev/null " Recording Finished" + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if kill -0 "$PID" 2>/dev/null; then + kill -SIGINT "$PID" + rm -f "$PID_FILE" + dunstify -t 3000 -i /dev/null " Recording Finished" + else + dunstify -t 3000 -i /dev/null "⚠️ Process not running." + rm -f "$PID_FILE" + fi + else + dunstify -t 3000 -i /dev/null "⚠️ No active recording." + fi + ;; + + *) + echo "Usage: $0 {start|stop}" + exit 1 ;; esac |
