Vapoursynth sRestore

From wiki.selur.net
Revision as of 09:54, 16 November 2026 by Selur (talk | contribs) (Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

sRestore (by MOmonster) undoes blend-based frame-rate conversions: it detects blended frames and either decimates back to the original rate, e.g. 50 → 23.976 fps for PAL-to-NTSC blends, or keeps the rate and replaces or rebuilds the blends.

Filtering → Vapoursynth → Frame → Deblend

sRestore controls in Hybrid
sRestore controls in Hybrid

What it does

sRestore measures for every frame how likely it is a blend of its neighbors. Output mode 6 picks the clear frames and decimates to the target rate; modes 1–5 keep the rate and replace each blend with a clean neighbor; pp0–pp3 remove double blends and rebuild frames with increasing post-processing. sRestore works strictly frame by frame in order: when seeking in the preview, the shown frames can be wrong; an encode is correct.

Settings

Control Parameter Range / values Hybrid default Meaning
Omode omode 1 – 6, pp0 – pp3 6 1–5: deblend without rate change (1 previous, 2 next, 3 smaller difference, 4 smaller blend probability, 5 best of four); 6: blend decimation; pp0–pp3: double-blend removal with increasing post-processing. Choosing 6 ticks Frate, any other mode unticks it.
Frate frate 0.0001 – 1000 on, 23.976 Target rate. With Omode 6 it is passed to sRestore; with other modes the clip is converted to this rate afterwards by dropping/repeating frames.
Speed speed −25 – 25 9 Speed versus detail of the detection (25 = one of 25 pixels is used); negative values for HD or high quality.
Mode mode −4, −3, −1, 1, 2, 3, 4 2 Use of chroma and handling of duplicates and merges in the detection.
Thresh thresh 1 – 44 16 Weight of the detection.
bob before – on/off off Bob the clip before sRestore when the input is not progressive.
decimate after – on/off off Remove 1 of every 5 frames after sRestore (only for non-progressive sources).
Tools: Expr – akarin, cranexpr, std – Expression plugin.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356, 25 fps):

# adjusting frame count and rate with sRestore
clip = srestore.sRestoreMUVs(clip, speed=9, frate=23.9760, tools={'expr': 'akarin'})

How Hybrid calls it

  • sRestore works on YUV clips of any bit depth; other formats are converted first. Interlaced input is allowed. The script scales its values for the bit depth itself.
  • Omode, Thresh and Mode are written when they differ from the defaults; Speed is always written, so the shown value is what runs. Frate is written with Omode 6 and Frate ticked.
  • Frame rate with Omode 6 and Frate: the Frate value. A target above the input rate or below a fifth of it means no decimation; the clip then keeps the source rate.
  • Frame rate with Omode 6 without Frate: sRestore picks the standard conversion itself (50 → 23.976 fps, 25 → 11.988 fps, 59.94 → 25 fps, 29.97 → 12.5 fps), and Hybrid follows it.
  • Other Omodes keep rate and frame count; with Frate ticked the clip is then converted to the Frate value.
  • "bob before" doubles the frame rate before sRestore; "decimate after" removes 1 of every 5 frames afterwards (frame rate and frame count −20 %).
  • sRestore also offers the common options (Gimmick only).

Background

The script

sRestore started as an AviSynth script; the VapourSynth version (srestore 2.7e) comes from havsfunc and is adapted so the frames are processed strictly in order. The detection itself runs on an 8-bit 4:2:0 copy of the clip. Frate is only needed for unusual conversions such as 29.97 → 23.976 or 50 → 25; with a frame-rate ratio above 5 or below 1 the output keeps the input rate, which can be used for the duplicate handling alone.

Vapoursynth DeblendS is a faster reimplementation with the same detection. For blend-deinterlaced telecine with a fixed pattern see Vapoursynth ExBlend.

Sources