Skip to content

Instantly share code, notes, and snippets.

@christiangenco
Created April 15, 2021 15:18
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 christiangenco/0da3486cccd330eaae3e8a2b9e672270 to your computer and use it in GitHub Desktop.
Save christiangenco/0da3486cccd330eaae3e8a2b9e672270 to your computer and use it in GitHub Desktop.
Crop a bunch of burst photos and stitch them together into a video
paths = Dir.glob("*.jpg")
`mkdir -p cropped`
paths.sort.each_with_index{|path, i|
cropped_path = "cropped/#{i.to_s.rjust(2, "0")}.jpg"
starting_width = 3834
starting_height = 5751
width = starting_width
height = starting_width
# x_offset = 0
# y_offset = (starting_height - height)/2
zoom = 1.8
width = width / zoom
height = height / zoom
x_offset = (starting_width - width) / 2
y_offset = (starting_height - height) / 2
cmd = %(convert #{path} -crop #{width.to_i}x#{height.to_i}+#{x_offset.to_i}+#{y_offset.to_i} #{cropped_path})
puts cmd
system(cmd)
# exit
}
# ffmpeg -y -r 15 -i cropped/%02d.jpg -vcodec libx264 -pix_fmt yuv420p out.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment