commit 5094f89de1cae3b757c544b8d8f93ad0a91304e6 parent 654efacdd90da0e256bb6205ac511ce15ff4f6bd Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Sat, 6 Feb 2021 10:08:29 +0100 add ffmpeg-bounce to loop a video back and forth n times Diffstat:
A | .local/bin/ffmpeg-bounce | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 40 insertions(+), 0 deletions(-)
diff --git a/.local/bin/ffmpeg-bounce b/.local/bin/ffmpeg-bounce @@ -0,0 +1,40 @@ +#!/bin/sh + +die() { + printf '%s: error: %s\n' "${0%%*/}" "$1" >&2 + exit 1 +} + +usage() { + printf '%s [-h] [-n repeats] file\n' "${0%%*/}" +} + +n=5 +while :; do + case "$1" in + -h) + usage + exit 0;; + -n) + n="$2" + shift;; + -*) + usage + exit 1;; + *) + break;; + esac + shift +done + +if test $# -lt 1 -o "$n" -lt 1; then + usage + exit 1 +fi + +n=$(( n - 1 )) +for f in "$@"; do + ext="${f##*.}" + out="${f%.*}-bounce.${ext}" + ffmpeg -i "$f" -filter_complex "[0]reverse[r];[0][r]concat,loop=${n}:250,setpts=N/25/TB" "$out" +done