Skip to content

Instantly share code, notes, and snippets.

@lilithebowman
Last active May 14, 2018 17:36
Show Gist options
  • Save lilithebowman/a9f41134942c660532c1eedb069ce67d to your computer and use it in GitHub Desktop.
Save lilithebowman/a9f41134942c660532c1eedb069ce67d to your computer and use it in GitHub Desktop.
Stabilize footage to a high degree (8) and accuracy (9)
@ECHO OFF
REM You must download ffmpeg to use this batch file.
REM https://ffmpeg.zeranoe.com/builds/
REM
REM You can simply click and drag a video file onto this batch file and it should start processing in place
REM A command prompt will pop up and churn for a while depending on the size
For %%A in ("%1") do (
Set Folder=%%~dpA
Set Name=%%~nxA
)
rem Get start time:
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
ffmpeg -i %1 -vf vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=%Name%.trf -f null -
ffmpeg -i %1 -vf vidstabtransform=input=%Name%.trf:zoom=1:smoothing=30,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -preset slow -tune film -crf 18 -acodec copy %1_stable.mp4
rem Get end time:
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
rem Get elapsed time:
set /A elapsed=end-start
rem Show elapsed time:
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
if %mm% lss 10 set mm=0%mm%
if %ss% lss 10 set ss=0%ss%
if %cc% lss 10 set cc=0%cc%
echo Processing stabilization and outputting stabilized video took %hh%:%mm%:%ss%,%cc%
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment