Skip to content

Instantly share code, notes, and snippets.

@tgreiser
Created December 10, 2022 01:37
Show Gist options
  • Save tgreiser/0110ba9a662a15f403d793f71d2ef0be to your computer and use it in GitHub Desktop.
Save tgreiser/0110ba9a662a15f403d793f71d2ef0be to your computer and use it in GitHub Desktop.
Make a seamless looping video from a normal video (colab)
# assume you have out.mp4 that is a normal video
!ffmpeg -y -r 30 -i out.mp4 -vf reverse reversed.mp4
!ffmpeg -y -i out.mp4 -i reversed.mp4 -filter_complex "concat=n=2:v=1:a=0" output.mp4
print('\nSeamless loop (original saved to out.mp4):')
show_video('output.mp4')
@tgreiser
Copy link
Author

If you want to flex and do everything one line:
!ffmpeg -y -r 30 -i 'out_%*.png' -lavfi "split[x][y];[y]reverse[z];[x][z]concat" -crf 15 -preset veryslow -pix_fmt yuv420p out.mp4

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