Last active
February 4, 2022 10:32
-
-
Save cathandnya/a8e40e4b7ce49539662c8b24f07895a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
FFMPEG="/usr/local/bin/ffmpeg" | |
WAIFU="/usr/local/bin/waifu2x" | |
INPUT=$1 | |
OUTPUT=$2 | |
ID=`/usr/bin/uuidgen` | |
WORKDIR="/tmp/$ID" | |
mkdir $WORKDIR | |
TMPDIR="$WORKDIR/waifu_tmp1" | |
TMPDIR2="$WORKDIR/waifu_tmp2" | |
mkdir $TMPDIR | |
mkdir $TMPDIR2 | |
# get fps | |
FPS=`$FFMPEG -i $INPUT 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p"` | |
echo "fps: $FPS" | |
# to images | |
$FFMPEG -r $FPS -i $INPUT -vcodec png "${TMPDIR}/%08d.png" < /dev/null | |
# upscale | |
for FILE in $TMPDIR/* | |
do | |
NAME=`basename $FILE` | |
echo "file: $FILE -> $NAME" | |
$WAIFU -i $FILE -o "$TMPDIR2/$NAME" -s 2 -t p -n 4 | |
done | |
rm -rf $TMPDIR | |
# make movie | |
$FFMPEG -y -r $FPS -i "$TMPDIR2/%08d.png" -vcodec libx264 -pix_fmt yuv420p $OUTPUT < /dev/null | |
rm -rf $WORKDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment