diff --git a/script.sh b/script.sh index 19f2ea6..66824c8 100755 --- a/script.sh +++ b/script.sh @@ -1,2 +1,7 @@ -ffmpeg -hwaccel vdpau -video_size 1920x1080 -framerate 30 -f x11grab -i :0 -c:v libx264rgb -crf 0 -preset ultrafast -movflags +faststart -tune zerolatency -f segment -segment_time 4 -segment_wrap 6 -segment_list /tmp/list.m3u8 -segment_list_size 6 /tmp/seg\%d.ts -ffmpeg -y -i /tmp/list.m3u8 -c:v copy /tmp/snap.mp4 +# Usage: have this script run as a service or in the background and send a SIGTERM to ffmpeg to capture the past X seconds +# $1 is the duration of the buffer, defaulting at 25-30 seconds depending on the progress of the last written file +# $2 is the base path, defaulting at /tmp for performance reasons +# $3 is the framerate, defaulting at 30fps +# $4 is the resolution, defaulting at 1080p +ffmpeg -hwaccel vdpau -video_size ${4:-1920x1080} -framerate ${3:-30} -f x11grab -i :0 -c:v libx264rgb -crf 0 -preset ultrafast -movflags +faststart -tune zerolatency -f segment -segment_time $(( ${1:-30} / 5 )) -segment_wrap 6 -segment_list ${2:-/tmp}/list.m3u8 -segment_list_size 5 ${2:-/tmp}/seg\%d.ts +ffmpeg -y -i ${2:-/tmp}/list.m3u8 -c:v copy ${2:-/tmp}/snap.mp4