georgmartius / vid.stab

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

Rapid Shaking at End of Tripod Mode Stabilized Videos #27

Closed arch-salix closed 9 years ago

arch-salix commented 9 years ago

FFmpeg 2.6.2 / vid.stab 0.98b / libx264 144.20150223

Some tripod mode stabilized videos rapidly shake at the end of the video stream while others do not. Original videos are relatively still with minor roll/pitch/yaw which tripod mode should easily handle. While the stablized videos look great towards the beginning of the streams, the end results are unacceptable due to the instability at the end. I have run multiple passes with tripod=1 and tripod=[random referenced frame] in vidstabdetect but the instablity issues persist.

ffmpeg -i input -vf vidstabdetect=tripod=1:stepsize=4:mincontrast=0:result=input.trf" -f null -

ffmpeg -i input -vf vidstabtransform=tripod=1:interpol=bicubic:input=input.trf,unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -tune film -preset veryslow -crf 12 -x264opts no-fast-pskip -c:a copy input-stab.mkv

...or...

ffmpeg -i input -vf vidstabdetect=tripod=400:stepsize=4:mincontrast=0:result=input.trf" -f null -

ffmpeg -i input -vf vidstabtransform=tripod=1:interpol=bicubic:input=input.trf,unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -tune film -preset veryslow -crf 12 -x264opts no-fast-pskip -c:a copy input-stab.mkv

...or...

ffmpeg -i input -vf vidstabdetect=tripod=400:result=input.trf" -f null -

ffmpeg -i input -vf vidstabtransform=tripod=1:input=input.trf,unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -c:a copy input-stab.mkv

None of the above resolves the issue. Is this a known problem with tripod mode? Current (but not elegant) workaround is to perform standard stabilization. What to do?

georgmartius commented 9 years ago

thanks for reporting. The issue is not known. Can you provide a short sample.

arch-salix commented 9 years ago

Original File http://bit.ly/1L0cdeq [001.mkv]

ffmpeg -i 001.mkv -vf vidstabdetect=tripod=1:stepsize=4:mincontrast=0:result=001.mkv.trf -f null -

Transformations File http://bit.ly/1zWRTJA [001.mkv.trf]

ffmpeg -i 001.mkv -vf vidstabtransform=tripod=1:interpol=bicubic:input=001.mkv.trf,unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -tune film -preset veryslow -crf 18 -x264opts no-fast-pskip -c:a copy 001.mkv-stab.mkv

Tripod Stablized File http://bit.ly/1K4Dmzb [001.mkv-stab.mkv]

arch-salix commented 9 years ago

mlt 0.9.6 / FFmpeg 2.6.2 / vid.stab 0.98b

MLT XML File http://bit.ly/1Izlbzs [001.mkv.mlt]

MLT Transformations File http://bit.ly/1HfdlMN [vidstab.trf]

melt 001.mkv -filter vidstab accuracy=15 stepsize=4 mincontrast=0 tripod=1 -consumer xml:001.mkv.mlt all=1

melt 001.mkv.mlt -consumer avformat:001.mkv-stab-mlt.mkv vcodec=libx264 tune=film preset=veryslow crf=18 fast-pskip=0 acodec=pcm_s16le

MLT Tripod Stabilized File http://bit.ly/1FiEFtd [001.mkv-stab-mlt.mkv]

Same results when using mlt: Visible shake towards the end of the stream. The issue is not exclusive to this specific clip and affects many more clips that I have transcoded with some exhibiting extreme shaking...

georgmartius commented 9 years ago

It was not a bug but you specified: mincontrast=0 Why did you think this is advantages. In this setting all measurement fields for motion detection are used, also those that have no contrast. There the algorithm will get many many spurious motions that will add up. Just remove it and it should be fine.

ffmpeg -i input -vf vidstabdetect=tripod=1:stepsize=4:result=input.trf" -f null -

you can also check

It was not a bug but you specified: mincontrast=0 Why did you think this is advantages. In this setting all measurement fields for motion detection are used, also those that have no contrast. There the algorithm will get many many spurious motions that will add up. Just remove it and it should be fine.

ffmpeg -i input -vf vidstabdetect=tripod=1:stepsize=4:show=1:result=input.trf" input_show.avi

then you see the detection fields it is using on each frame.