Skip to content

Instantly share code, notes, and snippets.

@arnaudrenaud
Last active April 24, 2024 14:23
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 arnaudrenaud/aa38439eafb84aabdc8e29c4ea4a5919 to your computer and use it in GitHub Desktop.
Save arnaudrenaud/aa38439eafb84aabdc8e29c4ea4a5919 to your computer and use it in GitHub Desktop.
Make video from random clips of desert images

Used to make https://vimeo.com/610805063

Original images: https://unsplash.com/s/photos/ground%2Bsoil?orientation=landscape

Get all image files

const allImageUrls = new Set()

// run this after each time you scroll
[...document.querySelectorAll('img._2UpQX')].map(img => img.currentSrc).forEach(imgUrl => allImageUrls.add(imgUrl))

copy([...allImageUrls])
mkdir -p images
wget -i 2050-image-urls -P images
for file in images/*; do  mv -- "$file" "$file.jpg"; done

Create clips from images

mkdir -p clips-rtl clips-ltr clips-ttb clips-btt
for i in select-images/*.jpg; do ffmpeg -y -i "$i" -filter_complex "zoompan=z=7:x='(1-on/(24*0.5))*(iw-zoom)':y='(ih/2)-(ih/zoom/2)':d=24*0.5:s=1280x720" -pix_fmt yuv420p -r 24 -c:v libx264 "clips-rtl/${i##*/}.mp4"; done
for i in select-images/*.jpg; do ffmpeg -y -i "$i" -filter_complex "zoompan=z=7:x='iw-(1-on/(24*0.5))*(iw-zoom)':y='(ih/2)-(ih/zoom/2)':d=24*0.5:s=1280x720" -pix_fmt yuv420p -r 24 -c:v libx264 "clips-ltr/${i##*/}.mp4"; done
for i in select-images/*.jpg; do ffmpeg -y -i "$i" -filter_complex "zoompan=z=7:x='(iw/2)-(iw/zoom/2)':y='ih-(1-on/(24*0.5))*(ih-zoom)':d=24*0.5:s=1280x720" -pix_fmt yuv420p -r 24 -c:v libx264 "clips-ttb/${i##*/}.mp4"; done
for i in select-images/*.jpg; do ffmpeg -y -i "$i" -filter_complex "zoompan=z=7:x='(iw/2)-(iw/zoom/2)':y='(1-on/(24*0.5))*(ih-zoom)':d=24*0.5:s=1280x720" -pix_fmt yuv420p -r 24 -c:v libx264 "clips-btt/${i##*/}.mp4"; done

Concatenate clips

sed -e "s/\(.*\)/file '\1'/" <( find ./clips-* -name '*.mp4' | sort -R ) > random-ordered-clips.txt
ffmpeg -f concat -safe 0 -i random-ordered-clips.txt -c copy concatenated-clips.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment