Skip to content

Instantly share code, notes, and snippets.

@claygregory
Created July 8, 2017 01:33
Show Gist options
  • Save claygregory/07e9cab872e5086b420789981283f2b1 to your computer and use it in GitHub Desktop.
Save claygregory/07e9cab872e5086b420789981283f2b1 to your computer and use it in GitHub Desktop.
4K timelapse from photos using ffmpeg
#!/bin/bash
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: timelapse input/*.jpg output.mp4";
exit;
fi
mkdir "./working"
output="${!#}"
files_length=$(($#-1));
files=${@:1:$files_length}
for f in $files; do
base_f=`basename $f`;
f_noext="${base_f%.*}"
echo "Scaling $base_f";
convert "$f" -resize "3840x2160^" -gravity center -crop "3840x2160+0+0" "./working/$f_noext.jpg";
done
ffmpeg -framerate 24 -pattern_type glob -i './working/*.jpg' -c:v libx264 -pix_fmt yuv420p "$output"
rm -r "./working"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment