# Inverse Telecine

Canonical URL: https://encode.wiki/tools/filtering/ivtc/
Content version: ca42e61ede0a24f789d7287a0001244ad22f4abf
Status: current
License: CC BY-SA 4.0
Checksum (SHA-256): 9c9c6615f8b14a8f38c60403b36cdeac32acf72794c9d416107cd9985cdb3bbd

Film is shot at 24 frames per second, but NTSC video runs at 29.97. Telecine bridges the gap with 3:2 pulldown, which spreads every four film frames (A, B, C, D) over five video frames by repeating fields: AA, BB, BC, CD, DD. Two of every five frames are a mix of two film frames and look combed. Inverse telecine (IVTC) reverses this: it matches fields back into the original progressive frames and then drops the repeated one, giving back 24000/1001 fps with no interpolation and no loss.

That is why IVTC is the right fix for telecined film and [deinterlacing](/tools/filtering/deinterlace/) is the wrong one. Deinterlacing would interpolate frames that never needed it and leave you at 29.97 fps with an uneven cadence.

## Is it telecined?

Run `idet` over a few thousand frames:

```sh
ffmpeg -t 60 -i input.mkv -vf idet -f null -
```

Telecine shows up as repeated fields: the "Repeated Fields" line reports Top or Bottom repeats in roughly two of every five frames. Stepping through frames in a previewer shows the same thing, three clean frames and two combed ones in a fixed rhythm. True interlaced video combs every moving frame instead.

There are two kinds of telecine:

- **Hard telecine** has the pulldown baked into the frames. Most NTSC TV recordings and many anime DVDs are like this. This is what IVTC is for.
- **Soft telecine** stores 24p video with flags that tell the player to repeat fields. NTSC film DVDs are often like this. There is nothing to undo; ignore the flags and you already have clean 24p. Plain `core.bs.VideoSource` ignores them (its `rff` option is off by default, and you may need to set the frame rate to 24000/1001 with `std.AssumeFPS`), but the vs-jetpack `BestSource` wrapper applies them by default (`rff=True`) and hands you hard-telecined 30i that needs the IVTC below.

## FFmpeg

`fieldmatch` pairs fields into frames, `yadif` deinterlaces the few frames that field matching couldn't repair, and `decimate` drops one frame in every five:

```sh
ffmpeg -i input.mkv -vf "fieldmatch,yadif=deint=interlaced,decimate" -c:v libx264 -crf 18 output.mkv
```

`deint=interlaced` makes `yadif` touch only the frames `fieldmatch` still marked as combed, so clean frames pass through untouched. Field order is taken from the stream; set `fieldmatch=order=tff` or `bff` if the stream is flagged wrong. `decimate` only works on constant-frame-rate input, so a source that mixes telecined and genuinely 24p sections needs `dejudder,fps=30000/1001,fieldmatch,decimate` instead (from the FFmpeg documentation); anything more tangled belongs in VapourSynth.

FFmpeg is fine for clean, constant-cadence sources. When the cadence changes partway, or you want to check what each frame did, use VapourSynth.

## VapourSynth

VIVTC's `VFM` (field matcher) and `VDecimate` do the same job with more control. `VFM` only accepts 8-bit input, so field-match before converting to a higher bit depth. `order` is mandatory: 1 for top field first, 0 for bottom field first.

```python
from vssource import BestSource

clip = BestSource.source("input.mkv", bits=None)
clip = core.vivtc.VFM(clip, order=1)
clip = core.vivtc.VDecimate(clip)
```

`VDecimate` removes one frame per cycle of five, whichever is the most nearly duplicate. vs-jetpack's `vsdeinterlace` wraps both and can deinterlace frames VFM could not match, much like the FFmpeg chain:

```python
from vsaa import NNEDI3
from vsdeinterlace import vfm, vdecimate

clip = vfm(clip, tff=True, postprocess=NNEDI3(double_rate=False).deinterlace)
clip = vdecimate(clip)
```

`VFM`'s `mode` trades safety against matching. `mode=0` is the safest and never creates duplicate-frame jerkiness, but outputs combed frames where a good match existed in damaged sections (bad edits, blended or orphaned fields); `mode=5` finds a match almost everywhere at the risk of jerky motion. The default is 1. `vsdeinterlace` also has `sivtc`, a minimal fixed-pattern IVTC for sources whose cadence never changes, and `jivtc` for the case where a normal IVTC leaves chroma blends on every fourth frame.

For difficult hard-telecined sources, especially anime with changing cadence, [Wobbly](https://github.com/Jaded-Encoding-Thaumaturgy/Wobbly) is an assistant for fixing field matching and decimation scene by scene by hand, on top of VFM and VDecimate's output.

## Check the result

You should get exactly four fifths of the original frame count, at 24000/1001 fps, with the same duration so audio stays in sync. Scrub through motion and look for duplicate frames or sudden jumps. Check the credits and any inserted video too: sections that were not film (credits, titles, commercials, 30i video) don't follow the pattern, and a fixed one-in-five decimation drops real motion from them. Those need separate handling; see [decombing](/tools/filtering/decombing/).

Don't use `-r 24` or `fps=24` as a shortcut. They drop frames on a schedule without matching fields, so you keep combed frames and lose clean ones.
