0

I do like how OBS studio "replay buffer" feature works (recording of last X seconds continuously).

But it seems like over-sophisticated heavy application to be used for this only purpose.

As I understood, it uses ffmpeg for recording. And ffmpeg seem to support scripting (or configuring, I'm not sure which term fits better here).

So I tried to find some instructions on how to make it with ffmpeg scripting only (without OBS studio), but hadn't found clear and straightforward one yet.

So how to make ffmpeg to do this:

  1. begin video recording which will be finished only after some particular action (e.g. hotkey is pushed)
  2. each second delete part of recording which is older than 10 seconds.

1 Answer 1

1

You can split the recording to segments and use a playlist file to combine them later. See https://unix.stackexchange.com/a/373148

Step 1:

ffmpeg -i input force_key_frames expr:gte(t,n_forced*4) -c:v libx264 -c:a aac -f segment -segment_time 4 -segment_wrap 6 -segment_list list.m3u8 -segment_list_size 6 seg%d.ts

This will save the recording in segments of 4 seconds. Once 6 segments have been written, the next segment will overwrite the first file. The playlist is updated accordingly.

Step 2:

ffmpeg -i list.m3u8 -c copy video.mp4

or

ffplay list.m3u8

The duration of the preserved footage is 20 < duration < 24.

If you want a complete solution that does this for you I have made a script for it https://github.com/MAPReiff/ShadowRePlay-Linux

1
  • Always quote the most relevant part of an important link in case the target site is unreachable or goes permanently offline.
    – somebadhat
    Commented May 8, 2020 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .