Introduction
Introduction Statistics Contact Development Disclaimer Help
add more video meme filters and split into separate script - annna - Annna the …
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 63e3baa4192174b82f3376aebd2a9b13c6949ac7
parent 8f1461a7105aabe20dfed0162b5f967fccc12a10
Author: Anders Damsgaard <[email protected]>
Date: Tue, 18 May 2021 21:52:21 +0200
add more video meme filters and split into separate script
Signed-off-by: Annna Robert-Houdin <[email protected]>
Diffstat:
M annna-message-common | 20 ++++++++++++--------
A ffmpeg-effect | 76 +++++++++++++++++++++++++++++…
2 files changed, 88 insertions(+), 8 deletions(-)
---
diff --git a/annna-message-common b/annna-message-common
@@ -652,16 +652,20 @@ case "${text}" in
"${botname}, bonjour !")
annna-say -c "${channel}" "${user}, bonjour !"
;;
-"${botname}, please widen #"*)
- hashtag="$(printf "%s\n" "${text}" | cut -c 22-)"
+"${botname}, please widen #"*|\
+"${botname}, please thin #"*|\
+"${botname}, please speedup #"*|\
+"${botname}, please slowdown #"*|\
+"${botname}, please reverse #"*|\
+"${botname}, please loop #"*|\
+"${botname}, please bounce #"*)
+ hashtag="$(printf "%s\n" "${text}" | sed 's/.*#//' )"
origext="$(grep -E "^#${hashtag} " "${hashtagfile}" | sed 's/.*\.//')"
- widefile="wide-${hashtag}.mkv"
{
- if ffmpeg -n -i "/br/gopher/memecache/${hashtag}.${origext}" \
- -vf "scale=iw*4:ih,crop=iw/4:ih:iw/4:ih,setsar=1" \
- "/br/gopher/memecache/wide/${widefile}"
- then
- annna-say -c "${channel}" "${user}, gopher://bitreich.…
+ filter="$(printf '%s\n' "${text}" | cut -d' ' -f3)"
+ if outfile="$(ffmpeg-effect "$filter" "/br/gopher/memecache/${…
+ mv "$outfile" "/br/gopher/memecache/filter/${outfile}"…
+ annna-say -c "${channel}" "${user}, gopher://b…
fi
} &
exit 0
diff --git a/ffmpeg-effect b/ffmpeg-effect
@@ -0,0 +1,76 @@
+#!/bin/sh
+# modify a video input file with an effect.
+# output is saved as "./filter-filename.mkv".
+# requirements: ffmpeg.
+
+ffmpeg_common="ffmpeg -n -loglevel error"
+
+repeats=5
+usage() {
+ printf 'usage: %s [-n REPEATS] FILTER file\n' "${0##*/}" 1>&2
+ printf 'where FILTER is one of: wide, thin, speedup, ' 1>&2
+ printf 'slowdown, reverse, loop, bounce.\n' 1>&2
+ printf 'For loop and bounce, option -n sets the number of repeats (def…
+ exit 1
+}
+
+process_filter() {
+ case "$1" in
+ wide|widen)
+ $ffmpeg_common -i "$2" \
+ -vf "scale=iw*4:ih,crop=iw/4:ih:iw/4:ih,setsar…
+ "$3" </dev/null;;
+ thin)
+ $ffmpeg_common -i "$2" \
+ -vf "scale=iw/4:ih,setsar=1" \
+ "$3" </dev/null;;
+ speedup)
+ $ffmpeg_common -i "$2" \
+ -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]a…
+ "$3" </dev/null;;
+ slowdown)
+ $ffmpeg_common -i "$2" \
+ -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]a…
+ "$3" </dev/null;;
+ reverse)
+ $ffmpeg_common -i "$2" \
+ -vf reverse -af areverse \
+ "$3" </dev/null;;
+ loop)
+ i=0
+ input=""
+ while test $i -lt $repeats; do
+ input="$input -i $2"
+ i=$((i + 1))
+ done
+ $ffmpeg_common $input \
+ -filter_complex "concat=n=${repeats}:v=1:a=1 […
+ "$3" </dev/null;;
+ bounce)
+ $ffmpeg_common -i "$2" \
+ -filter_complex "[0]reverse[r];[0][r]concat,lo…
+ "$3" </dev/null;;
+ *) usage;;
+ esac
+}
+
+while getopts 'hn:' opt; do
+ case $opt in
+ h) usage;;
+ n) n="$OPTARG";;
+ *) break;;
+ esac
+done
+shift $((OPTIND - 1))
+if test "$#" -lt 2 -o ! -r "$2"; then
+ usage
+fi
+
+n=$((n - 1))
+base="$(basename "$2")"
+out="${1}-${base%.*}.mkv"
+if process_filter "$1" "$2" "$out"; then
+ printf '%s\n' "$out"
+else
+ exit $?
+fi
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.