Skip to content

Instantly share code, notes, and snippets.

@t-mart
Created October 14, 2018 01:49
Show Gist options
  • Save t-mart/e701d04104b5ba939d86c84fbe7c6795 to your computer and use it in GitHub Desktop.
Save t-mart/e701d04104b5ba939d86c84fbe7c6795 to your computer and use it in GitHub Desktop.
Creates a "boomerang" movie clip.
#!/usr/bin/env zsh
set -ex
INPUT_FILE_PATH=${INPUT:a}
INPUT_DIR=${INPUT:a:h}
INPUT_EXT=${INPUT:e}
REVERSE_FILE_PATH="${INPUT_DIR}/reverse.${INPUT_EXT}"
FORWARD_FILE_PATH="${INPUT_DIR}/forward.${INPUT_EXT}"
BOOMERANG_FILE_PATH="${INPUT_FILE_PATH:r}.boomerang.${INPUT_EXT}"
ffmpeg -ss ${FROM} -y -to ${TO} -i "${INPUT_FILE_PATH}" -filter:v "setpts=PTS-STARTPTS" -vf reverse -af areverse "${REVERSE_FILE_PATH}"
ffmpeg -ss ${FROM} -y -to ${TO} -i "${INPUT_FILE_PATH}" -filter:v "setpts=PTS-STARTPTS" "${FORWARD_FILE_PATH}"
ffmpeg -y -f concat -safe 0 -i =(print "file '${FORWARD_FILE_PATH}'"; print "file '${REVERSE_FILE_PATH}'") -c copy "${BOOMERANG_FILE_PATH}"
rm -v "${REVERSE_FILE_PATH}" "${FORWARD_FILE_PATH}"
set +ex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment