I'm trying to set up my Raspberry Pi to continuously record the last X minutes of audio until given the command to save it to a file. The only comparison I can make is an NVIDIA Shadowplay for audio. My goal with this is to have it constantly recording my band when practicing so if we play something that we like and want to keep I can save the last few minutes of audio.

I'm already able to record our multitrack audio interface via ffmpeg on the Pi, but right now the set up is repeating (every X minutes) the command to record X minutes of audio to a timestamp-named file. This isn't exactly what I'm looking for as I may end up splitting the "good" content across two files. If possible I'd also like to avoid writing to the disk until actually saving the audio, keeping the continuous recording as some sort of circular buffer in memory. I'm willing to write some C/Python/Bash if necessary!

  • 1
    This question is probably too broad for this site and also not specific to Raspberry Pi. It's not clear what you're asking either. You certainly cannot retroactively record something. You either record it when it happens or you don't. You could defer somehow the decision on whether to save what you recorded to some permanent storage, but that's a different question and probably relatively straightforward to do.
    – Brick
    Sep 3, 2018 at 15:09
  • I understand that I can't go back in time and get something that I wasn't recording - I'd like to be constantly recording (to e.g. /tmp/ or preferrably just to memory) a "buffer" of a few minutes of audio, discarding data that is older than that predefined few minutes or saving the buffer to an output file if the command is given.
    – Cowbell
    Sep 3, 2018 at 15:57
  • 1
    What's the problem with a recording split between two files? You can trivially merge them together with any audio editor. Alternatively, keep a single recording and cut the right part from it. Sep 25, 2018 at 12:59

1 Answer 1


Very interesting and nice to share this project. I believe what your looking for is called circular / ring buffer or maybe FIFO process. Very common in real data processing to “discard” the old data. I am just learning bash and I do not see why you couldn't do that in bash or in a script of your choice. Good luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.