Skip to main content

Scene change detection plugin for VapourSynth.

Project description

scenechange

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier PyPI - Version Tests Coverage Status

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Scene change detection plugin for VapourSynth.

The project builds two VapourSynth plugins:

  • scenechange (namespace scd) detects scene changes and attaches _SceneChangePrev and _SceneChangeNext frame properties (0 or 1) so downstream temporal filters can avoid bleeding across cuts.
  • temporalsoften2 (namespace focus2) is a temporal-averaging denoiser that honours those scene change properties.

The vapoursynth-scenechange Python package bundles both compiled plugins together with a small wrapper (scenechange.TemporalSoften) that stitches them into a single function call.

Building and installing

Requirements:

  • A C99 compiler (GCC, Clang, or MSVC).
  • CMake 3.28 or newer, and Ninja (or any other generator).
  • VapourSynth R55 or newer (API 4) development headers and vapoursynth.pc (vapoursynth-dev or your distribution's equivalent). The plugins use VapourSynth4.h and are not compatible with the legacy API 3.

Configure, build, and install:

cmake -S . -B build -G Ninja
cmake --build build
cmake --install build

By default the plugins install to the directory reported by pkg-config --variable=pluginsdir vapoursynth, falling back to ${CMAKE_INSTALL_FULL_LIBDIR}/vapoursynth when the pkg-config variable is unset. Override the location with -DVAPOURSYNTH_PLUGINS_DIR=/path/to/plugins at configure time.

Python package

Prebuilt wheels that bundle both plugins are published to PyPI, so most users do not need to build anything from source:

pip install vapoursynth-scenechange

The wheel installs the compiled plugins as package data (for example site-packages/scenechange/libscenechange.so) alongside the scenechange Python module, and declares vapoursynth as a dependency. Building the plugins from source with CMake (above) is only needed for development or for platforms without a published wheel. See Python wrapper for usage.

Usage

scd.Detect

clip = core.scd.Detect(clip, thresh, interval_h, interval_v, log)

Detect scene changes and attach _SceneChangePrev and _SceneChangeNext properties to the clip.

  • thresh: threshold for the average of luma differences between the previous and next frames. When the average exceeds this value the frame is judged a scene change. Range is 1 to 254 * 2 ^ (bitdepth - 8); the default (or any out-of-range value) is 15 * 2 ^ (bitdepth - 8).
  • interval_h: horizontal interval, in pixels, used when measuring differences. Range is 1 to the clip width; the default is auto-adjusted.
  • interval_v: vertical interval, in pixels, used when measuring differences. Range is 1 to the clip height; the default is auto-adjusted.
  • log: optional path of a log file. When set, the frame numbers identified as scene changes are written as text. An absolute path is recommended. Unset by default.

scd.ApplyLog

clip = core.scd.ApplyLog(clip, log)

Apply _SceneChangePrev and _SceneChangeNext properties to the clip from a log previously produced by scd.Detect.

Supported colour families are GRAY (8-bit and 16-bit) and YUV (8-bit, 9-bit, 10-bit, and 16-bit).

focus2.TemporalSoften2

clip = core.focus2.TemporalSoften2(clip, radius, luma_threshold, chroma_threshold,
                                   scenechange, mode)
  • radius: 1 to 7. Default is 4.
  • luma_threshold: 0 to 255. For RGB clips this value applies to all planes. Default is 4.
  • chroma_threshold: 0 to 255. Ignored for RGB and Gray clips. Default is 8.
  • scenechange: when 0 the _SceneChange* frame properties are ignored. Default is 1.
  • mode: 2.

YUV or Gray example:

import vapoursynth as vs

core = vs.Core()
core.std.LoadPlugin('/path/to/libscenechange.so')
core.std.LoadPlugin('/path/to/libtemporalsoften2.so')

clip = core.scd.Detect(clip, thresh=20)
clip = core.focus2.TemporalSoften2(clip)

RGB example (scene detection requires GRAY8, so the properties must be copied back):

def copy_sc(n, f):
    fout = f[0].copy()
    fout.props._SceneChange = f[1].props._SceneChange[0]
    return fout


tmp = core.resize.Point(clip, format=vs.GRAY8)
tmp = core.scd.Detect(tmp, thresh=20)
clip = core.std.ModifyFrame([clip, tmp], copy_sc)
clip = core.focus2.TemporalSoften2(clip)

Python wrapper

The TemporalSoften class in the scenechange package collapses the boilerplate above into a single call and handles the RGB property-copy step automatically. Its static load_plugins method loads the bundled plugins into the core, so no manual LoadPlugin paths are required:

import vapoursynth as vs
from scenechange import TemporalSoften

core = vs.core
TemporalSoften.load_plugins(core)
clip = TemporalSoften(core).soften(clip, luma_threshold=4)

Credits

Original plugins by Oka Motofumi (chikuzen.mo at gmail dot com).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vapoursynth_scenechange-0.4.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vapoursynth_scenechange-0.4.0-py3-none-win_arm64.whl (31.8 kB view details)

Uploaded Python 3Windows ARM64

vapoursynth_scenechange-0.4.0-py3-none-win_amd64.whl (34.8 kB view details)

Uploaded Python 3Windows x86-64

vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_x86_64.whl (29.9 kB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_aarch64.whl (29.6 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (29.9 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (30.2 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

vapoursynth_scenechange-0.4.0-py3-none-macosx_11_0_arm64.whl (28.3 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

vapoursynth_scenechange-0.4.0-py3-none-macosx_10_13_x86_64.whl (26.9 kB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file vapoursynth_scenechange-0.4.0.tar.gz.

File metadata

  • Download URL: vapoursynth_scenechange-0.4.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vapoursynth_scenechange-0.4.0.tar.gz
Algorithm Hash digest
SHA256 eaeac166d05d3d2742303e9b010d2971fd7a00d4d2e6d8195bbd92bd8a46f760
MD5 58dbe8cc27f67f203e8003231717f8b3
BLAKE2b-256 c850c8121fd94c86914466eb62baf1d2a1a451c7f3755d2fa9b742dad1652a6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0.tar.gz:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 dcd5faeec3642190f3092ae4920739e7c1e2e31bb52d1a64fc870ad0f8dba89e
MD5 4c11cb862c870452d3aeb85087db965b
BLAKE2b-256 679c54c8119c09840559c7bdbfc646df0ec66658bca93584a8a5b10405f455d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-win_arm64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6899e62127fde72aedd18bf70bfa2f1d9ab968b0cde3b4989f1316ba90f3a798
MD5 4fd4686f13b65fa91876ec8f3ec41ac9
BLAKE2b-256 8124afc2d20d6a548ff65050d1483e8ebe99726c7c0ac23d601e652948beed25

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-win_amd64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7396d330c5c215feed3c14bdfa761ab59b5ea4051d99b1c4a87153e9133740bc
MD5 6a276b127dd4f498357153198c6c5ea4
BLAKE2b-256 1b9fa4fcfdc805d7698d8a55b738fd01220edf17c6b0ff42390ac3a46fb8eba2

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4fd3b635ecfbb63372eb067144f2308616fcceb17fa55b91e3e906c4967da6d8
MD5 21f4294889f701ab8f8ac06028d176fa
BLAKE2b-256 96e6ca8fa1480343107b4e43d683c959c79fdea57159f5590a279f64de0c1cf6

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 99a1bd945b7815f1d8574d84dd9fb624888bdca4e14d75a050a7f5ec149e4bae
MD5 59966e4e3e74e3c477d9cadff1567dea
BLAKE2b-256 933fbe6f7790d96a51ca26e3f49264fa9652b64185added35891a0fe74be51be

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ae69d9016e3d79c5f06295086959e21a0de7d51d1b5b6cef340a0e21724c33d6
MD5 e8897694f311817116fb92ab0affc1d3
BLAKE2b-256 885c33bc07895a8094cc040dce9ec4c58504d9b7131f122defb544dfe4f17e74

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5a574cf0a8088c2e3a4cdf64b568e6cf896b254328094f3210faacaf58633b9
MD5 6fde9d6e7c409d38d1796767a59d8350
BLAKE2b-256 0062386b9e57646dbefb72784c42bb6c51793a390edbf5971b2a1f1885e31fd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_scenechange-0.4.0-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for vapoursynth_scenechange-0.4.0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4a4ae72aee08d31335dbdebe28b17215ea5f897b28894eacdfc8a9bd21ccb208
MD5 2012d4deda6eeb1d4c02efde2623c545
BLAKE2b-256 ef773f6d7bc8c3c2f5b13dbfb5c65b3dc09ac82d881c9696be8fce06423e83d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_scenechange-0.4.0-py3-none-macosx_10_13_x86_64.whl:

Publisher: publish.yml on Tatsh/scenechange

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page