This repository has been archived on 2020-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
ffsnap/script.sh

8 lines
760 B
Bash
Executable File

# 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