vid.stab icon indicating copy to clipboard operation
vid.stab copied to clipboard

Something in this video segment causes jerking motion

Open Pixelsplasher opened this issue 7 months ago • 4 comments

This 12-second segment was extracted from raw footage. The 12-second segment before it worked fine with vid.stab so there must be something in the video encoding causing the jerky output. Stabilizing the whole source footage will result in jerky motion from start to end but extracting the first 12 seconds only and stabilizing that results in good stabilization. Extracting the second 12 seconds of raw footage (posted here as the source file) and stabilizing that results in jerky motion.

image Extracted segment highlighted in the timeline with blue line.

Source: https://drive.google.com/file/d/1XwShRO9p6F_fy8SUxQVbl34HS11okG30/view?usp=sharing

Output: https://drive.google.com/file/d/16OMpXoJKKiJj2PcH2B26974VtoHFt32z/view?usp=sharing

Options: vidstabdetect=shakiness=5:accuracy=15 vidstabtransform=interpol=no

Issue persists with

default interpol on smoothing at 5,10,15 and 30. framerate set to 24 (source is 30) fps unsharp filter on (unsharp=5:5:0.8:3:3:0.4)

Pixelsplasher avatar Dec 28 '23 04:12 Pixelsplasher

Hi, When I tested your video with interpolation= bilinear, stabilized result seems alright. I think configuration of relative, or tripod might generate shaky effect, too.

Here is all configurations value when I tested.

 # vidstabdetect
    "shakiness": 5,
    "accuracy": 15,
    "stepsize": 6,          
    "mincontrast": 0.25, 
    "show": 0,
    "tripod": 0,

# vidstabtransform
    "smoothing":15,
    "optzoom":2,
    "zoomspeed": 0.25,
    "optalgo": "gauss",
    "crop": "keep",
    "invert": 0,
    "relative": 1,
    "zoom": 0,
    "interpol": "bilinear"

Output with interpol= no https://drive.google.com/file/d/1QE8u_Gl9PXz1e7RlNPG4ebVjTGHiusrw/view?usp=sharing

Ouput with interpol = bilinear https://drive.google.com/file/d/1E1S-zouYrCTb51rKwvxf-EnxezfX27A7/view?usp=sharing

Ssong24 avatar Jan 10 '24 06:01 Ssong24

Thank you for trying it out for me, @Ssong24 . I have already tried interpolation off and on with same result.

I think this could be my

system: unsupported gpu output format: h.265

Pixelsplasher avatar Jan 11 '24 09:01 Pixelsplasher

Interpolation is not causing this. GPU is also not used, unfortunately. What is the exact cmd line you are using? You might want to run the motiondetection in debug mode and look at the output video.

georgmartius avatar Jan 11 '24 12:01 georgmartius

Here are the exact cmd lines I used, @georgmartius.

First pass "D:\cmd\ffmpeg\bin\ffmpeg.exe" -i "..\20160110-133454 Pomelo Climb Up (vid.stab jerky src).MP4" -vf vidstabdetect=shakiness=8:accuracy=15:result="20160110-133454 Pomelo Climb Up (vid.stab jerky src)-s8.trf" -f null -

Second pass D:\cmd\ffmpeg\bin\ffmpeg.exe" -i "..\20160110-133454 Pomelo Climb Up (vid.stab jerky src).MP4" -c:v libx265 -filter:v "scale='min(1280,iw)':-1,minterpolate=mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=48,fps=48,vidstabtransform=optzoom=2:crop=black:relative=1:input=20160110-133454 Pomelo Climb Up (vid.stab jerky src)-s8.trf,unsharp=5:5:0.8:3:3:0.4" -fps_mode passthrough -crf 36 -preset fast "20160110-133454 Pomelo Climb Up (vid.stab jerky src).720p.48fps.crf36.mp4

Solution: use ffmpeg interpolation

On second pass I set the frame rate from 30 fps, the source frame rate, to 48 fps in order to have more frames for interpolation by ffmpeg video filter instead of vid.stab interpolation.

Problem: vid.stab does not support custom frame rates

On second pass, unaware of the new frame rate, vid.stab has used the video stabilization analysis of the source video in its original frame rate and ran out of transformation data. A warning error was shown at the end of second pass encoding:

[vidstabtransform @ 000000b9b3dff448] not enough transforms found, use last transformation!251x

The jerking motion was gone but stabilization data was out of sync with the output video and introduced more shakes than the original.

Pixelsplasher avatar Jan 12 '24 03:01 Pixelsplasher