Skip to content

Instantly share code, notes, and snippets.

@hugohil
Created May 8, 2018 09:06
Show Gist options
  • Save hugohil/e6ecc8c776bec229e6e104d470cf7bec to your computer and use it in GitHub Desktop.
Save hugohil/e6ecc8c776bec229e6e104d470cf7bec to your computer and use it in GitHub Desktop.
media conversion scripts
#!/bin/sh
for i in medias/*.jpg;
do name=`echo $i | cut -d'.' -f1`;
# # this one looks for the previous pot
# p2w=$(convert "$i" -format "%[fx:2^(floor(log(w)/log(2)))]" info:)
# p2h=$(convert "$i" -format "%[fx:2^(floor(log(h)/log(2)))]" info:)
# # this one looks for the next pot
# p2w=$(convert "$i" -format "%[fx:2^(ceil(log(w)/log(2)))]" info:)
# p2h=$(convert "$i" -format "%[fx:2^(ceil(log(h)/log(2)))]" info:)
# # this does the actual conversion. I use 'jpeg' over 'jpg' to keep a backup.
# # Then I can also mv medias/*.jpeg to any folder I want without confusion.
# convert "$i" -background black -gravity center -extent ${p2w}x${p2h} -quality 100 "${name}.jpeg";
done
#!/bin/sh
for i in medias/*.gif;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" "${name}.mp4";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment