georgmartius / vid.stab

Video stabilization library
http://public.hronopik.de/vid.stab/
Other
838 stars 110 forks source link

Transforms information file naming limitations #87

Closed DavidAzofeifa closed 4 years ago

DavidAzofeifa commented 4 years ago

It is not possible to use a transforms information file (*.trf) that contains a comma (,) or semicolon (;) on its name. Maybe there are other forbidden characters too. This is a problem when using vidstab on a parameterized batch file that takes a video file name as input, which can indeed contain such characters.

georgmartius commented 4 years ago

I think this is a problem of ffmpeg's command line parsing. colons ':' are also not allows. I recommend create a new name for thee transform files or replace the forbidden characters in the batch script.

DavidAzofeifa commented 4 years ago

I solved it by replacing the commas and semicolons with underscores:

@echo off

if "%~1" == "" goto end

setlocal

set _filename=%~n1
set _extension=%~x1

set _cleanname=%_filename%
set _cleanname=%_cleanname:,=_%
set _cleanname=%_cleanname:;=_%

ffmpeg -y -i "%_filename%%_extension%" -vf vidstabdetect=shakiness=10:accuracy=15:stepsize=1:show=1:result="%_cleanname%.trf" -preset veryfast -c:v libx264 -crf 20 "%_cleanname%.detection.mp4"

ffmpeg -y -i "%_filename%%_extension%" -vf vidstabtransform=relative=1:smoothing=50:optzoom=2:zoomspeed=1:interpol=bicubic:input="%_cleanname%.trf" -movflags use_metadata_tags -map_metadata 0:g -preset veryfast -c:v libx264 -crf 20 "%_filename%.stabilized.mp4"

ffmpeg -y -i "%_filename%%_extension%" -i "%_filename%.stabilized.mp4" -filter_complex hstack -preset veryfast -c:v libx264 -crf 20 "%_filename%.comparison.mp4"

del /q /a /f "%_cleanname%.trf"

endlocal
echo=

:end