Skip to content

Instantly share code, notes, and snippets.

@peanutbutterandcrackers
Last active October 1, 2017 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peanutbutterandcrackers/b062ddcc7fb3802972b73025b531b493 to your computer and use it in GitHub Desktop.
Save peanutbutterandcrackers/b062ddcc7fb3802972b73025b531b493 to your computer and use it in GitHub Desktop.
Timelapse on Linux
ffmpeg -framerate 30 -pattern_type glob -i '*.JPG' -s hd1080 -c:v libx264 -crf 18 30fps_1080p_CRF18.mkv
# -framerate 30 -> 30fps; higher the frame rate ~ faster the action in timelapse
# -pattern_type glob -i '*.JPG' -> set the pattern type of the input file(s) to glob; single quotes in the file pattern
# so as to prevent the shell from expanding the glob pattern BEFORE ffmpeg ever gets it.
# Doing this: -i *.JPG will ruin the project. Doing this: -i '*.JPG' without pattern type set to glob will make ffmpeg
# complain about not finding the file.
# -s hd1080 -> 1080p video; other available ones: hd720, hd480
# -c:v libx264 -> use the libx264 library (developed by VideoLAN - the same group that developed VLC)
# -crf 18 -> set constant rate factor to 18. 0-51 is the possible range, 18-28 is the good range.
# 18 makes the video's bit rate same as the input
# 0 is lossless and 51 is the worst possible
# skipping the -crf part is also advisable
# For reverse timelapse:
cat $(ls -r *jpg) | ffmpeg -f image2pipe -framerate 30 -i - -s hd1080 -c:v libx264 -crf 18 30fps_1080p_CRF18_REVERSED.mkv
# -f image2pipe : tells ffmpeg about the type of input it is going to get, kinda'
# -i - : tells ffmpeg to get input from stdin
# Helpful Links:
# https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment