From ec550c42b0fd96d375c6036a18e16821ba11e2eb Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sat, 30 Nov 2024 23:23:50 +0100 Subject: [PATCH] Butcher script --- src/bin/butcher | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 src/bin/butcher diff --git a/src/bin/butcher b/src/bin/butcher new file mode 100755 index 0000000..3db56cf --- /dev/null +++ b/src/bin/butcher @@ -0,0 +1,31 @@ +#!/usr/bin/env nu + +def main [input: string, --resize(-r): string, --length(-l): string = "00:00:05"] { + let resize = if ($resize | is-empty ) { "" } else { $resize } + destroy (glitch $input $resize $length) +} + +def glitch [input: string, resize: string, length: string] { + let output = [ ($input | path parse | get stem ) "_glitch.mkv" ] | str join + let filter = if ($resize | is-not-empty) { + $"\'scale=($resize):-2,fps=60,frei0r=filter_name=glitch0r:filter_params=0.2|0.8|.04|1,rgbashift=rh=4:bh=-2,interlace=lowpass=complex\'" + } else { + "\'fps=60,frei0r=filter_name=glitch0r:filter_params=0.2|0.8|.04|1,rgbashift=rh=4:bh=-2,interlace=lowpass=complex\'" + } + #echo $"ffmpeg -loop 1 -i ($input) -filter_complex ($filter) -to ($length) ($output) -y" + ffmpeg -loop 1 -i $input -filter_complex $filter -to $length $output -y + echo $output +} + +def destroy [input: string] { + let output = ($input | path parse | get stem ) + let pngOutput = [ $output "_animated.png" ] | str join + let mp4Output = [ ($input | path parse | get stem ) "_animated.mp4" ] | str join + let mp4OutputFixed = [ ($mp4Output | path parse | get stem ) "_fixed.mp4" ] | str join + echo $"Creating destroyed png image at: ($pngOutput)" + magick -monitor $input $"APNG:($pngOutput)" + echo $"Creating video at: ($mp4Output)" + ffmpeg -i $pngOutput -vcodec libx265 -pix_fmt yuva420p $mp4Output -y + echo $"Fixing video at: ($mp4OutputFixed)" + ffmpeg -i $mp4Output $mp4OutputFixed -y +}