Skip to content

Instantly share code, notes, and snippets.

@yuptogun
Last active February 9, 2022 05:25
Show Gist options
  • Save yuptogun/6c18325c2d22d7f1efab754ea61d898e to your computer and use it in GitHub Desktop.
Save yuptogun/6c18325c2d22d7f1efab754ea61d898e to your computer and use it in GitHub Desktop.
resize all media files in directory using linuxserver/ffmpeg
#!/bin/bash
# usage
# linuxserver-ffmpeg-resize.sh mkv 720
# linuxserver-ffmpeg-resize.sh avi 1080 480
if [ -z "$1" ]; then
echo "please provide extension! aborting."
exit
elif [ -z "$2" ]; then
echo "please provide original resolution! aborting."
exit
else
FROM="$2"
TO="360"
if [ ! -z "$3" ]; then
TO="$3"
echo "the files will be converted into ${TO}p!"
fi
for in in *${FROM}p*.$1; do
echo "encoding ${TO}p of $in ..."
OUT=$(echo "$in" | sed -e "s/${FROM}p/${TO}p/g")
docker run --rm -it \
-v "$(pwd):/config" \
linuxserver/ffmpeg \
-hide_banner -loglevel error -stats \
-i "/config/$in" \
-vf scale="-2:$TO" \
-y "/config/$OUT"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment