shotcut icon indicating copy to clipboard operation
shotcut copied to clipboard

Stabilization filter causes stuttering on VFR (or converted VFR to CFR) videos

Open Timocop opened this issue 5 months ago • 5 comments

OS and Version (please complete the following information):

  • Operating System: Windows 10 (22H2 19045.5487)
  • Shotcut Version: 25.05.11

Describe the bug Whenever duplicated frames are present such as from VFR or converted VFR into CFR videos, the stabilization filter also "stabilizes" the duplicated frames and smoothes them. Causing weird stuttering and jitter in the output.

Steps To Reproduce

  1. Start Shotcut
  2. Add a video with duplicated frames (VFR video for best results).
  3. Apply stabilization filter
  4. See stuttering on any filter settings.

Expected behavior Stabilization should exclude the analysis and smoothing of duplicated frames that have not been changed since previous frame.

Screenshots

https://github.com/user-attachments/assets/2adb7611-abf1-4a2e-883f-068410a7ae2d

Timocop avatar Jun 28 '25 13:06 Timocop

Usually the problem you describe occurs when the data becomes out of sync with the clip. Shotcut detects some of those conditions and clears the link to the data, but I suspect there are places where it does not. The stabilization algorithm can handle no motion fine, but it cannot simply skip over the repeated frames. So, your expectation is wrong. Rather, it needs to repeat the same transform as the frame it is repeating.

If you re-run the analysis does the problem go away? I doubt I have a clip with which I can reproduce this.

ddennedy avatar Jun 28 '25 16:06 ddennedy

If you re-run the analysis does the problem go away

No, its consistent with every VFR recording i do. My camera outputs MJPG 1080p@30hz (shotcut does not detect it as VFR via metadata) but does have a average fps of 19-21 frames seen in the Classic Media Player statistic.

Demo video of the smoothing problem

(🔴 D means duplicated frame)

https://github.com/user-attachments/assets/b0b354be-a41d-4442-953d-6ba1460b3408

Source video to reproduce

https://github.com/user-attachments/assets/f8523d83-30f0-4359-99d2-de43fc72b43b

Timocop avatar Jun 28 '25 17:06 Timocop

As a test, you could try to convert the clip and use the "Motion Compensation" frame rate conversion mode. Maybe that would avoid duplicated frames.

Image

https://forum.shotcut.org/t/convert-to-edit-friendly-dialog/47720

bmatherly avatar Jun 28 '25 21:06 bmatherly

Interpolation does not work since shotcut detects the input video as CFR, even if, interpolation is terribly slow and causes bad artifacts.

Currently my only workaround is to run ffmpeg manually with mpdecimate to remove all duplicated frames from the video and create a proper VFR video or use the original VFR video that my camera creates and then run vidstabdetect and vidstabtransform to stabilize the VRF video.

https://github.com/user-attachments/assets/9ef1fc85-c1a5-45cb-8a23-699305160b0a

Timocop avatar Jun 29 '25 01:06 Timocop

I reproduced it with the video you shared, thank you. It seems to be a problem in vid.stab that Shotcut uses, but it is no longer maintained outside of mostly minor pull requests.

ddennedy avatar Jun 29 '25 16:06 ddennedy