Skip to main content

fpng for VapourSynth

This is a small plugin which allows fpng to be used with VapourSynth.

The motivation for this plugin was to dump frames of a VapourSynth script to PNGs faster than was possible with imwri.

Installation

The plugin is available on PyPI and can be installed with:

python -m pip install vsfpng

Usage

Python Helper

The raw plugin only writes frames when they are requested. This complicates the most common scenario where a user wants to dump all frames from a clip. To make dumping easier, a python helper is included and can be invoked from your script. See below example.

To get progress feedback, install rich.

def dump(
        clip: vs.VideoNode | tuple[vs.VideoNode, vs.VideoNode],
        output_directory: str | Path,
        filename_template: str = "frame_%d",
        first_num: int = 0,
        overwrite: bool = True,
        compression: Compression = Compression.SLOW,
    ) -> None:
    """
    Dump all frames of a clip to .png files.

    Args:
        clip: A single input clip if no transparency is needed. Otherwise
            a tuple of (clip, alpha) where alpha is a gray clip with the same
            dimensions.
        output_directory: Where to dump PNGs. Will attempt to create the
            directory if it doesn't already exist.
        filename_template: A printf style template for the filename. For
            example "frame_%d" or "%06d". Suffix will always be .png and does
            not need to be explicitly specified.
        first_num: The number to start counting from. Useful, for example, to
            preserve frame numbers from a source clip if the input clip has
            been trimmed.
        overwrite: If existing files should be overwritten. When set to False,
            existing files are left untouched, and no exception is raised.
        compression: The fpng compression level. The default is fine for most
            purposes, but can be set if other speed and size trade-offs are
            desired.
    """

Example

example.py
import vapoursynth as vs

clip = vs.core.bs.VideoSource("example.mkv")
# Set output so clip can be previewed or used with vspipe normally
clip.set_output()

# Only dump if the script is invoked directly
if __name__ == "__main__":
   from vsfpng import dump
   dump(clip, "./output")
output
$ vspipe example.py --info
Output Index: 0
Type: Video
Width: 1920
Height: 1080
Frames: 38072
FPS: 60/1 (60.000 fps)
Format Name: YUV420P8
Color Family: YUV
Alpha: No
Sample Type: Integer
Bits: 8
SubSampling W: 1
SubSampling H: 1

$ python example.py
Dumping... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:49

Plugin Documentation

Usage is similar to imwri.Write() with ImageMagick options replaced with fpng options.

.. function:: Write(clip clip, string filename[, int firstnum=0, int compression=1, bint overwrite=False, clip alpha])
   :module: fpng

   Write will write each frame to disk as it's requested. If a frame is never
   requested it's also never written to disk.

   Parameters:
      clip
         Input clip. Only RGB24 is supported.

      filename
         The filename string must have one or more frame number substitutions.
         The syntax is printf style. For example "image%06d.png" or
         "/images/%d.png" is common usage.

      firstnum
         The first image number in the sequence to write.

      compression
         Matches fpng flags which are:
         0 - fast compression
         1 - slow compression (smaller output file)
         2 - uncompressed

      overwrite
         Overwrite already existing files. This option also disables the
         requirement that output filenames contain a number.

      alpha
         A grayscale clip containing the alpha channel for the image to write.
         Apart from being grayscale, its properties must be identical to the
         main *clip*.

Vendored Dependencies

Some dependencies are directly copied into the src/ directory from their respective projects. It is the author's understanding that this usage is compatible with the applicable licenses.

From fpng fetched 2022-04-30

  • fpng.h
  • fpng.cpp

From libp2p fetched 2022-04-30

  • p2p.h
  • p2p_api.h
  • p2p_api.cpp
  • v210.cpp

From vs-imwri fetched 2022-04-30

  • vsutf16.h
  • Several methods within plugin.cpp also directly come from imwri.cpp

vapoursynth as a submodule for

  • VapourSynth4.h

Download files

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

Source Distribution

vsfpng-1.3.tar.gz (642.9 kB view details)

Uploaded Source

Built Distributions

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

vsfpng-1.3-py3-none-win_amd64.whl (219.2 kB view details)

Uploaded Python 3Windows x86-64

vsfpng-1.3-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (96.1 kB view details)

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

vsfpng-1.3-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (98.7 kB view details)

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

vsfpng-1.3-py3-none-macosx_15_0_x86_64.whl (74.9 kB view details)

Uploaded Python 3macOS 15.0+ x86-64

vsfpng-1.3-py3-none-macosx_15_0_arm64.whl (68.7 kB view details)

Uploaded Python 3macOS 15.0+ ARM64

File details

Details for the file vsfpng-1.3.tar.gz.

File metadata

  • Download URL: vsfpng-1.3.tar.gz
  • Upload date:
  • Size: 642.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vsfpng-1.3.tar.gz
Algorithm Hash digest
SHA256 97ca92ed95b50ec9c5f559a8d5a8eeb2121953320fc99f605d18d076c87cff44
MD5 bbd1d094ff516e03b45b001eb8486d74
BLAKE2b-256 c5c4b6ee1a9aed53fa2276609a3eab44c90df00691896d70463386394d248a61

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.3.tar.gz:

Publisher: build.yaml on Mikewando/vsfpng

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

File details

Details for the file vsfpng-1.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: vsfpng-1.3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 219.2 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vsfpng-1.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 74429b3a566add32cd0f585e2bf3e1d6d4baaf11158231659629d9b7bd27e456
MD5 81755ecfa617b735395bbc04665538fe
BLAKE2b-256 6ea7672e60904647fdfd4d3f3b859bd20e5bae23d00bfb8e55508a21cc669386

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.3-py3-none-win_amd64.whl:

Publisher: build.yaml on Mikewando/vsfpng

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

File details

Details for the file vsfpng-1.3-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vsfpng-1.3-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3bff45e63fc1e13bb787dc946408867610958d8fdaa5e30d29151440b0f4df81
MD5 22767f4e7791bb02506ae053db0577fb
BLAKE2b-256 10837e952b64155d6300b0713393f94f4672895412306721f50c8ead37abbf64

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.3-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yaml on Mikewando/vsfpng

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

File details

Details for the file vsfpng-1.3-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vsfpng-1.3-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3ea08f3a20f105ad7b31f41ff8392061e25437ead1ae9ba119838bab90920b62
MD5 766431f8c42d32ecfe9857e780de49fc
BLAKE2b-256 336a2cf91696f9e426db79010384c28f1c03efc3b346dc09e29a84cd9273b895

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.3-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build.yaml on Mikewando/vsfpng

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

File details

Details for the file vsfpng-1.3-py3-none-macosx_15_0_x86_64.whl.

File metadata

  • Download URL: vsfpng-1.3-py3-none-macosx_15_0_x86_64.whl
  • Upload date:
  • Size: 74.9 kB
  • Tags: Python 3, macOS 15.0+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vsfpng-1.3-py3-none-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 f581acf584de182fd114765caedfa9df7d51d854ea1ec8fef33c41298dafbd91
MD5 6b96c0bf2b301e823ca541dbc30046e1
BLAKE2b-256 712b261ea2c157ee6f942010137b9bc3909e9ef9101a7adad01bacd7fbe770fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.3-py3-none-macosx_15_0_x86_64.whl:

Publisher: build.yaml on Mikewando/vsfpng

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

File details

Details for the file vsfpng-1.3-py3-none-macosx_15_0_arm64.whl.

File metadata

  • Download URL: vsfpng-1.3-py3-none-macosx_15_0_arm64.whl
  • Upload date:
  • Size: 68.7 kB
  • Tags: Python 3, macOS 15.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vsfpng-1.3-py3-none-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 55a3a31c418a95343c0ebe859dd5d1c84874c23d0e206a23b05df30a90361228
MD5 94d63050246bcf7926142832a588cf9b
BLAKE2b-256 0ad5de92f9d83fb275a99d72bac57f308aca94065e071188b05a4999e7349f54

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.3-py3-none-macosx_15_0_arm64.whl:

Publisher: build.yaml on Mikewando/vsfpng

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

Release history Release notifications | RSS feed

This release

1.3 This release

6 files

1.2

6 files

1.1

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page