Skip to content

Instantly share code, notes, and snippets.

@lilithebowman
Last active August 20, 2020 00:19
Show Gist options
  • Save lilithebowman/092dc3dbdd3b3f6f2f2ae2265ca007a8 to your computer and use it in GitHub Desktop.
Save lilithebowman/092dc3dbdd3b3f6f2f2ae2265ca007a8 to your computer and use it in GitHub Desktop.
echo "You must download ffmpeg to use this shell script.
https://www.johnvansickle.com/ffmpeg/
Only this version will work because the default packages do not contain vidstab.
A terminal will pop up and churn for a while depending on the size
Add the list of files to concatenate to mylist.txt with "file " in front of the name. One per line.
Example:
file GOPR2307.MP4
file GP012307.MP4
file GP022307.MP4
This batch file will automatically concatenate, speed up the video 4x, and run extensive stabilization on the video.
"
start=`date +%s`
echo "Start timestamp $start"
mkdir /tmp/vid
echo "##### RUN CONCATENATION #####"
ffmpeg -f concat -safe 0 -i mylist.txt -c copy /tmp/vid/concatenated.mp4
echo "##### RUN STABILIZE - CALCULATE TRV #####"
ffmpeg -f mp4 -i /tmp/vid/concatenated.mp4 -strict -2 -vf vidstabdetect=stepsize=32:shakiness=10:accuracy=10:result=concatenated.trf -f null -
echo "##### RUN STABILIZE - STABILIZE VIDEO #####"
ffmpeg -i /tmp/vid/concatenated.mp4 -strict -2 -vf vidstabtransform=input=concatenated.trf:zoom=1:smoothing=10,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -preset slow -tune film -crf 18 -acodec copy stabilized_1x_speed_output.mp4
end=`date +%s`
echo "End timestamp $end"
runtime=$((end-start))
hms=$(date -u -d @${runtime} +"%T")
echo "Time to concatenate, speed up 4x, and smooth video: ($hms)"
echo "\n\n"
read -n 1 -s -r -p "Press any key to DELETE ALL TEMPORARY VIDEOS in /tmp/vid"
rm -rf /tmp/vid
@lilithebowman
Copy link
Author

Updated to be less aggressive since the old settings took FOREVER to process

Settings from here: https://www.imakewebsites.ca/posts/2018/02/17/stabilizing-gopro-video-with-ffmpeg-and-vid.stab/

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