Today I learned of a Windows-only product today called the Overwolf Replay HUD, which lets the user press a key to replay the last 20 seconds of happenings on their screen. It's meant for people playing or spectating fast-paced videogames who want to quickly review a hectic moment.
I'm trying to duplicate that behaviour on Linux. So far, I figure I could easily start ffmpeg
(with -f x11grab
) capture to a file in /tmp
(which is memory-mapped), then use sxhkd
to bind a keyboard shortcut to launch mpv
to play the last 20 seconds of that file.
However, the rest of the recording would still be stored, and I'd eventually run out of RAM. How could I go about keeping only the last 20 seconds?
-segment
& co. can split a stream into separate files of specified length, which could just be pruned periodically to save space, but this may require rejoining files before playing them.