hyprwm / contrib

Community scripts and utilities for Hypr projects
MIT License
295 stars 40 forks source link

grimblast: screen recording #5

Open ThatOneCalculator opened 2 years ago

ThatOneCalculator commented 2 years ago

Screen recording with xdg-desktop-portal-wlr would be cool cuz Kooha sucks on Hyprland lol

fufexan commented 2 years ago

What should we record with? I've had mixed results with wf-recorder and regions/audio/odd-dimensions.

ThatOneCalculator commented 2 years ago

What about OBS headless?

fufexan commented 2 years ago

Didn't even know that was a thing, but sure sounds great.

rszyma commented 1 year ago

any progress on this?

fufexan commented 1 year ago

Nope. I figured we can't really use OBS, as it's inflexible with --startrecording --minimize-to-tray. We could use wf-recorder, but I forgot about this issue. If anyone wants to do it feel free, as I don't have time to do it myself.

kRHYME7 commented 1 year ago

Hello bumping this issue,

What should be better wf-recorder or wl-screenrec

wl-screenrec looks promising. What can be the caveats on both.

fufexan commented 1 year ago

Based on the benchmark, wl-screenrec would be more sensible to use. As for the caveats, I don't know.

ThatOneCalculator commented 1 year ago

I tried wl-screenrec and it works pretty great

rszyma commented 1 year ago

Here's a little script I wrote which uses wl-screenrec. It's bindable to a single key for start/stop. After stoping recording it shows notification that can be clicked to reveal recording in file explorer:

#!/bin/bash

# If wl-screenrec is already running, stop recording.
if pgrep -x "wl-screenrec" > /dev/null; then
    killall -s 2 wl-screenrec
    exit 0
fi

FILE="$(xdg-user-dir VIDEOS)/$(date +'screencast_%Y%m%d%H%M%S.mp4')"
dunstify "Starting screencast" --timeout=1000
wl-screenrec -g "$(slurp)" --filename $FILE &&
ffmpeg -i $FILE -ss 00:00:00 -vframes 1 /tmp/screenrec_thumbnail.png -y &&
printf -v out "`dunstify "Recording saved to $FILE" \
    --icon "/tmp/screenrec_thumbnail.png" \
    --action="default,Open"`" &&

# If the notification is clicked, reveal the recording in default file explorer.
case "$out" in
"default")
    gdbus call --session \
        --dest org.freedesktop.FileManager1 \
        --object-path /org/freedesktop/FileManager1 \
        --method org.freedesktop.FileManager1.ShowItems "['file://$FILE']" ""
    ;;
esac

I also wanted to add a tray icon that appears after starting recording and can be clicked to stop, but I couldn't find any good program to create tray icon. If anyone knows any, let me know!

ThatOneCalculator commented 1 year ago

Seems that the easiest way to get a tray indicator is with yad

rszyma commented 1 year ago

yad doesn't work natively on wayland https://github.com/v1cont/yad/issues/216

And even if I use GDK_BACKEND=x11 yad it still doesn't work for me.