Vapoursynth ExBlend

From wiki.selur.net
Jump to navigation Jump to search

ExBlend repairs telecined film that was blend-deinterlaced to 30 fps: it finds the blended frame pairs of each cycle, recovers the original film frame from them and, by default, decimates back to the film rate.

Filtering → Vapoursynth → Frame → Deblend

ExBlend controls in Hybrid
ExBlend controls in Hybrid

What it does

When telecined film is deinterlaced by blending, each cycle contains good frames and a pair of blends of two film frames: GGGBB for 24p film (cycle 5), GGGGBB for 25p PAL (cycle 6). ExBlend locates the blend pairs, unblends them to get the missing film frame back, and with Decimate drops one frame per cycle. Before the first frame is delivered it scans the whole clip once and stores the measurements in a stats file.

Settings

Control Parameter Range / values Hybrid default Meaning
Pal pal film, PAL film Blend pattern: film (cycle 5) or PAL (cycle 6).
LockThresh lockthresh 0 – 100 1.0 Locks onto the blend sequence in near-static scenes; 0 switches locking off.
IThresh ithresh 0 – 100 3.0 Blend pairs with a merge difference above this are ignored (protects scene changes).
Decimate decimate on/off on Drop one frame per cycle (the second blend of each pair).
Disp disp 0 – keep blend, 1 – unblend, 2 – unblend, next frame for index 2 1 What replaces the blends. 2 needs Decimate off: choosing it switches Decimate off, switching Decimate on sets Disp back to 1.
Detection dclip none, vertical blur none Optional detection clip: a vertical 3-line blur of the luma, used only to find the blends.
CompUB compub 0 – 2 2 Only with a detection clip: 0 unblends from the source, 1 takes the blends from the detection clip and the neighbors from the source, 2 takes both from the detection clip.
Show show on/off off Mark recovered frames with a block in the top left corner (blue = blend index 1, red = index 2).
Compat compat on/off off Reproduce the original v1.04 exactly, including its defects; 8 bit only.
FullScan fullscan on/off on Check every frame for a blend pair; off skips frames already decided by a neighboring pair (v1.04 behaviour).

Example

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

# removing blends with ExBlend
clip = core.exblend.ExBlend(clip, statsfile="J:/tmp/exblend_mp4_d5388c6989b85ff899f0a531062413f6_853323747_clip.stats")

How Hybrid calls it

  • ExBlend works on 8–16-bit YUV and gray clips. It needs progressive input; interlaced material is deinterlaced first. With Compat the clip is converted to 8 bit, keeping the chroma subsampling.
  • The stats file lies in Hybrid's temporary folder and is reused as long as the clip stays the same; the first frame waits for the full scan.
  • Values are only written when they differ from the defaults; Show and Compat only when on. Thresholds are percentages and do not depend on the bit depth.
  • With Decimate on, the frame count and frame rate drop to 4/5 (film) or 5/6 (PAL): 29.97 fps → 23.976 fps, 30 fps → 25 fps. With Decimate off both stay the same.
  • In the side-by-side preview the unfiltered clip is rate-converted to stay in sync.
  • ExBlend also offers the common options (Gimmick only).

Background

Origin

ExBlend was written by StainlessS for AviSynth (v1.04); the plugin Hybrid uses is a port and rework for AviSynth+ and VapourSynth that fixes the original's defects unless Compat is on. On a clip without blends it logs that it found no clear film blend pattern. The plugin also has display modes 3 and 4, which Hybrid does not offer. It runs on the CPU.

For blended animation without a fixed pattern see Vapoursynth AnimDeblend; for blend-based frame-rate conversions (PAL ↔ NTSC) see Vapoursynth sRestore and Vapoursynth DeblendS.

Sources