Last active
May 15, 2024 13:54
-
-
Save yadex205/4512716a15e17c76e0b58fd3e09a1f13 to your computer and use it in GitHub Desktop.
Make cross-faded seamless loop video from non-loop video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://stackoverflow.com/questions/60043174/cross-fade-video-to-itself-with-ffmpeg-for-seamless-looping | |
# and conversations with ChatGPT | |
duration=$(ffprobe -v error -show_entries format=duration -of noprint_wrappers=1:nokey=1 input.mp4) | |
duration=$(echo "$duration - 2" | bc) | |
ffmpeg -i input.mp4 -filter_complex "[0]trim=end=1,setpts=PTS-STARTPTS,fps=fps=30[begin];[0]trim=start=1,setpts=PTS-STARTPTS,fps=fps=30[end];[end][begin]xfade=fade:duration=1:offset=${duration}" output.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment