FFmpeg: Record the screen but only remember the last 5 minutes?
ffmpeg, pyffmpeg, screen-capture, video-capture, video-streaming
Solution
I agree that I would love to see this feature in ffmpeg.
As a work around solution, I created a script to record the screen into pictures and continuously delete older pictures. Unfortunately it doesn't save audio. Here is the script.
#!/bin/bash
set -e -u
mkdir "$HOME/history" || true
rm "$HOME"/history/img*.png || true
# Get screen resolution.
RES="$(xwininfo -root | grep -Po 'geometry[^+]*' | sed 's/^\S* //')"
# Record the screen into images into /home/username/history/ one per second.
avconv -s "$RES" -f x11grab -i :0.0 -r 1 -f image2 "$HOME/history/img%06d.png" &
AVCONV_PID=$!
trap "kill $AVCONV_PID" INT TERM EXIT
while true; do
# Delete screen images older than 5 minutes.
find "$HOME/history" -name "img*.png" -mmin +5 -exec rm {} +
sleep 10
done
If you want 5 pictures per second, change the part `-r 1` to `-r 5`. See this link how to assemble the images into a video (avi, mpeg) file.
PS. You could also use ffmpeg instead of avconv.
Problem
I am using Ffmpeg to continuously record the video the screen on my PC. However, I only ever need the last 5 minutes of the video. Yes, I could edit the video afterwards. But these recording sessions could go on for several hours and take up A LOT of hard disk space. Is there a way to only remember the last 5 minutes of a video capture and forget everything previous before the file is saved? (Kind of like a TiVO would do) I've found ``` -fs limit_size ``` and ``` -timelimit duration ``` ..but these seem to stop once the limit has been reached. Maybe there is an inversed switch? Like to only keep the last 1000000 bytes or something.