V-Nova VC-6 codec Python bindings.
Project description
V-Nova VC-6 codec python module
Usage
Main codec functionality is inside the codec module that can be imported as follow:
from vnova.vc6_opencl import codec as vc6codec
or if you have installed the CUDA codec:
from vnova.vc6_cuda import codec as vc6codec
Then you can create codecs and start transcoding. For complete examples see provided sample codes
# setup encoder and decoder instances
encoder = vc6codec.EncoderSync(
1920, 1080, vc6codec.CodecBackendType.CPU, vc6codec.PictureFormat.RGB_8, vc6codec.ImageMemoryType.CPU)
encoder.set_generic_preset(vc6codec.EncoderGenericPreset.LOSSLESS)
# Using double resolution to demonstrate reconfiguration later
decoder = vc6codec.DecoderSync(1920, 1080, vc6codec.CodecBackendType.CPU, vc6codec.PictureFormat.RGB_8, vc6codec.ImageMemoryType.CPU)
# encode file to memory
encoded_image = encoder.read("example_1920x1080_rgb8.rgb")
# decode memory to memory
decoder.write(encoded_image.memoryview, "reconstruction_example_1920x1080_rgb8.rgb")
encoded_image.release()
GPU memory output
In case of cuda package (vc6_cuda), decoder output can be a device memory. To enable this feature create the decoder with specifying GPU_DEVICE as the output memory type. With that, the output images will have __cuda_array_interface__ and can be used with other libraries like cupy, pytorch and nvimagecodec.
import cupy
# setup GPU decoder instances with CUDA device output
decoder = vc6codec.DecoderSync(1920, 1080, vc6codec.CodecBackendType.GPU, vc6codec.PictureFormat.RGB_8, vc6codec.ImageMemoryType.CUDA_DEVICE)
# decode from file
decoded_image = decoder.read("example_1920x1080_rgb8.vc6")
# Make a cupy array from decoded image, download to cpu and write to file
cuarray = cupy.asarray(decoded_image)
with open("reconstruction_example_1920x1080_rgb8.rgb", "wb") as decoded_file:
decoded_file.write(cuarray.get())
Both for sync and async decoders, accessing __cuda_array_interface__ is blocking and implicitly waits on the result to be ready in the image.
The __cuda_array_interface__ always contains a one-dimension data of unsigned-8bit type like the CPU version. Adjusting dimensions (or the type in case of 10-bit formats) is up to the user.
Environment variables
Variables OCL_BIN_LOC and OCL_DEVICE can be set to be used as gpu binary cache location and hint to selecting target GPU respectively. For more details refer to VC6-SDK documentation.
export OCL_BIN_LOC=./tmp/clbin
export OCL_DEVICE=nvidia
Variable CUDA_BIN_LOC serves the same purpose for CUDA version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vc6-7.34.0-py3-none-any.whl.
File metadata
- Download URL: vc6-7.34.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f52276045b2726682fd0a6e40b95fb5b4060a5c8d1a6c2c9243e1ae641657c3
|
|
| MD5 |
ac674a10c0b40a6098a5c9ced52360dd
|
|
| BLAKE2b-256 |
7b06dee490c9bd20dc6b184b43396b6fc6c41f41a46adf909b8f8731546ab346
|