Skip to content

Instantly share code, notes, and snippets.

@kenske
Created October 12, 2017 22:39
Show Gist options
  • Save kenske/df605961738d016f240003b64481aa06 to your computer and use it in GitHub Desktop.
Save kenske/df605961738d016f240003b64481aa06 to your computer and use it in GitHub Desktop.
Create timelapse
#!/bin/bash
# Create 1080p and 4k timelapse
# Requires imagemagick, mencoder and parallel
# Resizes and crops images and creates video
if [[ "$#" == 0 ]]; then
echo "Usage: $0 <sourcedir>"
exit 1
fi
echo "Creating output directories..."
rm -Rf resized/1080
rm -Rf resized/4k
mkdir -p resized/1080
mkdir -p resized/4k
mkdir video
echo "Resizing images to 1920x1080..."
find $1 -iname "*.JPG" | parallel -j+0 --bar convert {} -gravity center -resize 1920x -crop "1920x1080+0+0" +repage resized/1080/{/.}.jpg
echo "Resizing images to 3840x2160..."
find $1 -iname "*.JPG" | parallel -j+0 --bar convert {} -gravity center -resize 3840x -crop "3840x2160+0+0" +repage resized/4k/{/.}.jpg
cd resized/1080
echo "Creating 1080 video..."
mencoder "mf://*.jpg" -mf fps=24 -o ../../video/timelapse24-1080.avi -ovc x264
mencoder "mf://*.jpg" -mf fps=30 -o ../../video/timelapse30-1080.avi -ovc x264
cd ../4k
echo "Creating 4k video..."
mencoder "mf://*.jpg" -mf fps=24 -o ../../video/timelapse24-4k.avi -ovc x264
mencoder "mf://*.jpg" -mf fps=30 -o ../../video/timelapse30-4k.avi -ovc x264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment