Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jordanbCS/cc4fecf81e5023430f945c1cc712d778 to your computer and use it in GitHub Desktop.
Save jordanbCS/cc4fecf81e5023430f945c1cc712d778 to your computer and use it in GitHub Desktop.
# Majority credit to the dozens of programmers talking through the problem on StackExchange and elsewhere
# Library vidstabdetect was a pain so I suggest a precompiled ffmpeg binary having it for your installation.
#1. build transform #2. apply transform #3. make side by side #4. extract audio from original then add it back in (side by side wouldn't know which audio to use)
ffmpeg_sd -i [Input]combined_segments.mp4 -vf vidstabdetect=stepsize=1:shakiness=7:accuracy=8:result=transforms.trf -f null -;ffmpeg -i [Input]combined_segments.mp4 -vf vidstabtransform=smoothing=9:input="transforms.trf" stabilized_[Input]combined_segments.mp4;ffmpeg -i [Input]combined_segments.mp4 -i stabilized_[Input]combined_segments.mp4 -filter_complex "[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]" -map [vid] -c:v libx264 -crf 23 -preset veryfast [output]stabilized_[Input]combined_segments.mp4;ffmpeg -i stabilized_[Input]combined_segments.mp4 audio_copy.wav;ffmpeg -i [output]stabilized_[Input]combined_segments.mp4 -i audio_copy.wav -shortest [output]stabilized_[Input]combined_segments_wAudio.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment