Skip to content

Instantly share code, notes, and snippets.

@drikusroor
Created January 28, 2026 13:19
Show Gist options
  • Select an option

  • Save drikusroor/80970258181c548249f2fd34c1b9d4b7 to your computer and use it in GitHub Desktop.

Select an option

Save drikusroor/80970258181c548249f2fd34c1b9d4b7 to your computer and use it in GitHub Desktop.
Create a bounce loop using ffmpeg
#!/usr/bin/env bash
ffmpeg -i input-video.mp4 -filter_complex "[0:0]split=2[v_fwd][v_to_rev];[v_to_rev]reverse[v_rev];[0:1]asplit=2[a_fwd][a_to_rev];[a_to_rev]areverse[a_rev];[v_fwd][a_fwd][v_rev][a_rev]concat=n=2:v=1:a=1[v_out][a_out]" -map "[v_out]" -map "[a_out]" -y output-video-with-bounce-loop.mp4
# A bounce loop is a versatile, bidirectional looping effect where media—such as a Live Photo, video, or audio sample—plays forward and then immediately plays in reverse, creating a continuous, seamless, back-and-forth motion. It is used in photography to make images "rock" or in DJing to create a temporary, reversing loop that resumes from the original track position when released.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment