URI: 
       ffmpeg-effect: reuse code where appropriate - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit 131094fe55b30a847c07fd53502ed73b2d1ddb2d
   DIR parent add54ddd2d5bd41f9f35f56043dd561d6f8248f4
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Sat, 12 Jun 2021 20:17:10 +0200
       
       ffmpeg-effect: reuse code where appropriate
       
       Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
       
       Diffstat:
         M ffmpeg-effect                       |      34 +++++++++++++++++--------------
       
       1 file changed, 19 insertions(+), 15 deletions(-)
       ---
   DIR diff --git a/ffmpeg-effect b/ffmpeg-effect
       @@ -15,6 +15,22 @@ usage() {
                exit 1
        }
        
       +mix_audio() {
       +        $ffmpeg_common -i "$2" -i "$1" \
       +                -filter_complex "amerge=inputs=2" \
       +                "$3" </dev/null
       +}
       +
       +mix_audio_video() {
       +        $ffmpeg_common -i "$2" \
       +                -i "$1" \
       +                -filter_complex "
       +                        [0:v] scale=w=${4:-1920}:h=${5:-1080}, pad=w=${4:-1920}:h=${5:-1080} [video0];
       +                        [video0][1:v] blend=all_mode=average:shortest=1;
       +                        amix=inputs=2:duration=shortest:weights=3 2" \
       +                "$3" </dev/null
       +}
       +
        process_filter() {
                case "$1" in
                        wide|widen)
       @@ -52,23 +68,11 @@ process_filter() {
                                        -filter_complex "[0]reverse[r];[0][r]concat,loop=${repeats}:250,setpts=N/25/TB" -an \
                                        "$3" </dev/null;;
                        sexify)
       -                        $ffmpeg_common -i "$2" \
       -                                -i "${mediadir}/careless_whisper.mp3" \
       -                                -filter_complex "amerge=inputs=2" \
       -                                "$3" </dev/null;;
       +                        mix_audio "${mediadir}/careless_whisper.mp3" "$2" "$3";;
                        scrollify)
       -                        $ffmpeg_common -i "$2" \
       -                                -i "${mediadir}/elder_scrolls.mp3" \
       -                                -filter_complex "amerge=inputs=2" \
       -                                "$3" </dev/null;;
       +                        mix_audio "${mediadir}/elder_scrolls.mp3" "$2" "$3";;
                        sendtohell|amsterdamify)
       -                        $ffmpeg_common -i "$2" \
       -                                -i "${mediadir}/hell.mkv" \
       -                                -filter_complex "
       -                                        [0:v] scale=w=1920:h=1080, pad=w=1920:h=1080 [video0];
       -                                        [video0][1:v] blend=all_mode=average:shortest=1;
       -                                        amix=inputs=2:duration=shortest:weights=3 2" \
       -                                "$3" </dev/null;;
       +                        mix_audio_video "${mediadir}/hell.mkv" "$2" "$3" 1920 1080;;
                        *) usage;;
                esac
        }