Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created January 11, 2023 23:21
Show Gist options
  • Save gibatronic/f152319bdcfa71ec14b14c26a55f7801 to your computer and use it in GitHub Desktop.
Save gibatronic/f152319bdcfa71ec14b14c26a55f7801 to your computer and use it in GitHub Desktop.

Revisions

  1. gibatronic created this gist Jan 11, 2023.
    33 changes: 33 additions & 0 deletions slide.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/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 "$@"