From 283a938e4d315c819755167e9c454c225794d3e7 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 2 May 2020 15:08:37 +0200 Subject: [PATCH] Add options to modify the behaviour and buffer --- script.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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