Skip to main content

fpng for VapourSynth

Project description

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

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

vsfpng-1.2.tar.gz (642.5 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.2-py3-none-win_amd64.whl (218.4 kB view details)

Uploaded Python 3Windows x86-64

vsfpng-1.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (95.9 kB view details)

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

vsfpng-1.2-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (98.6 kB view details)

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

vsfpng-1.2-py3-none-macosx_15_0_x86_64.whl (74.8 kB view details)

Uploaded Python 3macOS 15.0+ x86-64

vsfpng-1.2-py3-none-macosx_15_0_arm64.whl (68.6 kB view details)

Uploaded Python 3macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for vsfpng-1.2.tar.gz
Algorithm Hash digest
SHA256 a695395956342b8dec18136a21e49281bd555aba17142d4b7ea60a3427175ce2
MD5 c6a7afd348291ac1c55fecc4576da0db
BLAKE2b-256 a5a5e2b2f55a1ce6ed78dd69085f34d2e57a5948abd262cd2849e5ebc357f51a

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.2.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.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: vsfpng-1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 218.4 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.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d65d81a90a17070311b57a9a44043258b3536a4a36289989de3f47c7ac6bd6ed
MD5 344e21efdf0247fb0039356cd2494c4b
BLAKE2b-256 976c537f159cfe382264d6c70c335c11d87b843e5b237e7db448d20930c994b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.2-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.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vsfpng-1.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 16b238f0a9fbc1b5587dad4b18c635b87cffda14c8b83fc2b59fa453da56d693
MD5 05ac4245476c24db962c9b55cda7705d
BLAKE2b-256 6b596219b6c9dec31f264b667db333bfc6ff69884bc55b3e56bb64dcdcde8792

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.2-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.2-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vsfpng-1.2-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fe0237a3df0cdcb9a79e8a2588a2ec31e3ee71700f8c313133c7c5acde7930ae
MD5 1cac3f0ac1b64409964cc5617d9c4074
BLAKE2b-256 2e800f7843382ceaa07d588455747ad64227b2f401063fa5dae0d043de810a16

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.2-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.2-py3-none-macosx_15_0_x86_64.whl.

File metadata

  • Download URL: vsfpng-1.2-py3-none-macosx_15_0_x86_64.whl
  • Upload date:
  • Size: 74.8 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.2-py3-none-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 a91fc5c1eafb8ee29ceac0a8d3d672e2007f5d3ee940dedc6a3cd0f379b1d916
MD5 3d7bab4cb908c796d8934eb1c5e03172
BLAKE2b-256 bbe30870f59068439b3d09b90375d9de912291b0a8a0eebd637171a8b5457b54

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.2-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.2-py3-none-macosx_15_0_arm64.whl.

File metadata

  • Download URL: vsfpng-1.2-py3-none-macosx_15_0_arm64.whl
  • Upload date:
  • Size: 68.6 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.2-py3-none-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 109e3ee5fced3b1eaadd54264b8359d9ba89b84ac0b6217040eea712d0cefedb
MD5 8d77606b1d13dc9d7a22001e888f5a43
BLAKE2b-256 637e5b322ef78b2a89dcd23f0c1da54be7c36edd3799e5351cdd8d63a1f6daa7

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsfpng-1.2-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.

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