Do you really need an instant replay program for Linux? Something similar to Shadowplay? GPU Screen Recorder is just that! Here's my little guide for setting it up.
NOTE: This guide was made for KDE Plasma. If you're on a different desktop environment, you'll have to find out startup scripts and keybinds on your own.
If you're on Arch Linux, use the AUR package.
The easiest method of installing GPU Screen Recorder on non-Arch distros is by installing the Flatpak. Go to Flathub for notes on installing Flatpaks.
To actually use the replay functionality, you can have the replay program start when your computer starts by having KDE Plasma run the startup script upon logon. You can do that in system settings under Autostart. The start replay script:
#!/bin/sh
output_path="$HOME/Videos/Replays"
# You can get the name(s) of your monitor by running xrandr.
video_source="DisplayPort-1"
mkdir -p "$output_path"
# "-w" is video source. This can be a window or a monitor. I'd recommend a monitor, as window captures can get complicated.
# "-c" is video output type, "-f" is framerate, "-a" is audio sources(the current arguments will capture your mic and desktop audio on separate tracks),
# "-q" is quality, "-r" is replay save time in seconds, "-k" is video codec, and "-o" is output directory.
# The notify-send will run if the start replay command fails.
gpu-screen-recorder -w "$video_source" -c mp4 -f 60 -a "$(pactl get-default-sink).monitor" -a "$(pactl get-default-source)" -q ultra -r 150 -k h264 -o "$output_path" || notify-send -a "GPU Screen Recorder" -i "com.dec05eba.gpu_screen_recorder" --action=OK "Unable to start replay service."
IF YOU USE THE FLATPAK VERSION, replace gpu-screen-recorder(the beginning of the command) with flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder.
Then to save a replay, hook this script to a keybinding of your choice(I prefer Alt+F10). You can get to keybinds in System Settings>Shortcuts>Custom Shortcuts>Edit>New>Global Shortcut>Command/URL. Set the keybind in Trigger, then specify the script in the input area by clicking the folder icon and navigating to it.
#!/bin/sh -e
killall -SIGUSR1 gpu-screen-recorder
notify-send -t 10000 -a "GPU Screen Recorder" -i "com.dec05eba.gpu_screen_recorder" "Replay saved."
If the save replay script doesn't work, run chmod +x script_name on it, replacing "script_name" with the name of the script.