Skip to content

Instantly share code, notes, and snippets.

@rileyjshaw
Last active May 6, 2018 17:13
Show Gist options
  • Save rileyjshaw/8f490a3a8599f778c4fd35197da679e4 to your computer and use it in GitHub Desktop.
Save rileyjshaw/8f490a3a8599f778c4fd35197da679e4 to your computer and use it in GitHub Desktop.
Split a longer video into 15 second clips (and rotate it, add audio) using FFmpeg for an Instagram story
# I'm sure there's a simple way to do this without intermediate files but :shrug:
# transpose=1 rotates 90 degrees.
# fade=in:120:60 adds a fade from 4s - 5s, since it's 30fps.
# the fade is placed there because later we crop the video and audio 4s: -ss 00:00:04. -shortest clips the output to the end of the video, not the whole song duration.
ffmpeg -i IMG_5965.mov -vf "transpose=1,fade=in:120:60" output_rotated.mov && ffmpeg -i output_rotated.mov -i ~/Downloads/soul_vibration.mp3 -ss 00:00:04 -shortest output_audio.mov && ffmpeg -i output_audio.mov -codec copy -shortest -c copy -map 0 -segment_time 00:00:10 -f segment -reset_timestamps 1 output%03d.mov && rm output_rotated.mov output_audio.mov
@rileyjshaw
Copy link
Author

There aren't always keyframes at exactly the right place for 15 second breaks, so I just split them into ~10 second chunks instead. Updating the gist now.

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