Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created January 11, 2023 23:21
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 gibatronic/f152319bdcfa71ec14b14c26a55f7801 to your computer and use it in GitHub Desktop.
Save gibatronic/f152319bdcfa71ec14b14c26a55f7801 to your computer and use it in GitHub Desktop.
Slide an image to the left using ffmpeg
#!/usr/bin/env bash
#
# Slide an image to the left using ffmpeg
#
# Usage:
# ./slide photo_input.jpg video_output.mp4
#
# See:
# https://ffmpeg.org/ffmpeg-filters.html#overlay-1
# https://easings.net/
#
main() {
local photo_input=$1
local video_output=$2
local duration='10' # in seconds
local fps='30'
local width='2160'
local height='3840'
ratio="t/${duration}"
easing="-(cos(PI*(${ratio}))-1)/2" # in-out-sine
overlay="(W-w)*(${easing}):(H-h)/2"
ffmpeg -f lavfi -i "\
color=black:r=${fps}:d=${duration}:s=${width}x${height}[background]; \
movie=${photo_input}[overlay]; \
[background][overlay]overlay='${overlay}' \
" -y "${video_output}"
}
main "$@"
@gibatronic
Copy link
Author

this one grew to be its own project: fotofx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment