pixtreme-transport-nvenc
pixtreme-transport-nvenc provides a shared library with a C ABI for H.264,
H.265 (HEVC) and AV1 encoding with NVIDIA NVENC. C and C++ output modules link
the encoder, write each frame into an encoder-owned CUDA region lent as a
pixtreme PixelBuffer, and receive
encoded access units with their original presentation timestamps and decoding
timestamps (DTS). The Python module
pixtreme.transport.nvenc offers the same operations to Python code.
One wheel includes the shared library, public C header and header-only C++ wrapper, CMake package configuration, the Python module, and license notices. It depends on the pixtreme wheel.
Install
pip install pixtreme-transport-nvenc
For a uv project:
uv add pixtreme-transport-nvenc
The package depends on pixtreme>=2.25.3, whose wheel supplies the
PixelBuffer type and its shared library (libpixtreme.so.2 on Linux,
pixtreme-2.dll on Windows). The encoder finds that library in the same
environment. At runtime, the encoder loads libcuda.so.1 and
libnvidia-encode.so.1 on Linux, or nvcuda.dll and nvEncodeAPI64.dll from
Windows System32. Neither driver library
nor the CUDA runtime is bundled in the wheel.
Supported environments
PyPI wheels support Linux x86_64 with glibc 2.28 or later
(manylinux_2_28_x86_64), including WSL2, and native Windows x86_64
(win_amd64), with CPython 3.12 or later. Each platform has a
cp312-abi3 wheel whose Python module uses CPython's stable ABI and serves
every supported Python version. PyPI releases contain
wheels only; no source distribution is uploaded. Installation on another
operating system or CPU architecture fails with no matching distribution.
Encoding requires an NVIDIA GPU with NVENC support for the selected codec and
configuration. The driver must support CUDA 13 and NVENC API 13.0 (driver
branch 580 or later). Driver API compatibility is checked before creating a
CUDA context or NVENC session. The encoder calls NVIDIA driver APIs directly;
the shared library contains host C++ code and no embedded CUDA kernels.
Supported configurations depend on runtime queries for the codec, profile, input format, output precision and chroma format, dimensions, B frames and lookahead. Representative verified capabilities include:
| GPU | Compute capability | Examples of verified support |
|---|---|---|
| RTX A6000 (Ampere) | 8.6 (sm 86) | H.264 8-bit; HEVC 8-bit and 10-bit |
| RTX 6000 Ada Generation | 8.9 (sm 89) | H.264 and HEVC; AV1 Main 4:2:0 at 8 or 10 bits |
| GeForce RTX 5090 (Blackwell) | 12.0 (sm 120) | H.264 10-bit; H.264 and HEVC 4:2:2 with NV16/P210; AV1 Main 4:2:0 at 8 or 10 bits |
The GPU model alone does not decide whether a requested combination is valid.
Unsupported GPU configurations are rejected before a session is created, with
an unsupported error reason identifying the codec and setting. Invalid
arguments and conflicting settings use invalid_configuration. Unsupported
configurations are also distinguished from driver-query, initialization and
resource-allocation failures.
Use from Python
pixtreme.transport.nvenc is a thin nanobind module over the C ABI and its
C++ wrapper described below. It offers the same operations, with Python
conventions: classes, functions and attributes keep the C++ names, enumeration
members are the C++ names in upper case (Codec.HEVC for Codec::hevc), and
timeouts are nonnegative seconds rather than milliseconds.
import pixtreme.transport.nvenc as nvenc
from pixtreme.io import to_pixel_buffer
session = nvenc.Session(nvenc.Settings(
codec=nvenc.Codec.HEVC, input_format=nvenc.InputFormat.NV12,
width=1920, height=1080, profile=nvenc.Profile.MAIN,
rate_control=nvenc.RateControl.CBR, bitrate=10_000_000,
frame_rate=nvenc.FrameRate(30000, 1001), gop_length=60, idr_period=60,
input_slots=4, access_unit_queue_limit=4))
buffer = session.acquire_input() # a pixtreme.PixelBuffer, or None when every region is in use
to_pixel_buffer(frame, out=buffer) # frame: a pixtreme Frame on the session's device
while not session.encode(buffer, timestamp):
... # the access unit queue is full: take access units, then submit again
del buffer
result = session.take(0.1)
if result.status is nvenc.TakeStatus.ACCESS_UNIT:
unit = result.access_unit # unit.bitstream is bytes; unit.timestamp is the input's timestamp
session.flush()
while (result := session.take(1.0)).status is not nvenc.TakeStatus.END:
...
session.close(5.0)
acquire_input() lends an encoder-owned region as a pixtreme.PixelBuffer.
pixtreme.io.to_pixel_buffer records its write in pixtreme's use records; record
other writes with buffer.storage.record_stream(stream). encode() accepts only
such a region and the caller's integer timestamp; it does not accept a pixtreme
Frame. Release the region by dropping the last reference to it. take(timeout)
returns a TakeResult whose status is ACCESS_UNIT, NOT_READY or, after
flush(), END; its access_unit holds the bitstream as bytes, the
timestamp (PTS), signed dts, is_idr, display_order and picture_type. close(timeout)
returns False while it cannot confirm that NVENC no longer reads input.
effective_settings() returns the accepted settings and low-latency switches.
Operations that wait for the GPU, NVENC or output release the GIL, and one
Session can be used from several Python threads. A failed operation raises
EncoderError, a RuntimeError whose reason (ErrorReason) and
classification (ErrorClassification) are those of the C error. Arguments of
the wrong type raise TypeError, and negative or NaN timeouts raise
ValueError. ABI_VERSION is the ABI version of the header the module was
built with; importing the module fails with ImportError when the loaded
encoder library reports a different runtime_abi_version(). The package
includes py.typed and a stub generated from the module for type checkers.
Use from C and C++
Native C and C++ applications obtain the prebuilt SDK from the public
Release through Conan, independently of the Python wheel. The recipes live
in the private sync-dev-org/conan-recipes repository. Authenticate gh
with an account that can read that repository, and follow its
download instructions
to obtain and verify a shared Release archive containing both pixtreme
and pixtreme-transport-nvenc. The download uses a temporary Conan
source_credentials.json with the host's gh token; remove it immediately
after downloading and keep the token out of commands and logs. Check the
archive's SHA256 against the shared Release before extracting it.
Set recipes to the extracted archive's recipes/ directory, and choose
an encoder version present in that archive. For the current SDK dependency,
export pixtreme 2.25.3 into the same fresh Conan home:
version=X.Y.Z
recipes=/absolute/path/to/verified-shared-release/recipes
export CONAN_HOME="$(mktemp -d)"
conan export "$recipes/pixtreme" --version 2.25.3
conan export "$recipes/pixtreme-transport-nvenc" --version "$version"
conan profile detect
The compiled application needs no Python environment. A consumer's
conanfile.py declares:
from conan import ConanFile
class OutputModule(ConanFile):
settings = "os", "arch", "compiler", "build_type"
requires = "pixtreme-transport-nvenc/[>=X.Y.Z]"
default_options = {"pixtreme-transport-nvenc/*:shared": True}
generators = "CMakeDeps", "CMakeToolchain"
Replace X.Y.Z with the required minimum. Run conan install /path/to/consumer --no-remote --build=missing -of /path/to/consumer/build --lockfile-out /path/to/consumer/conan.lock, then configure CMake
with -DCMAKE_TOOLCHAIN_FILE=/path/to/consumer/build/conan_toolchain.cmake
and -DCMAKE_BUILD_TYPE=Release. The recipe verifies the SDK's URL and SHA256,
requires the build SDK's pixtreme version or newer with shared=True, and
packages the prebuilt files without compiling encoder or pixtreme sources.
The same shared recipe supports from_source=True to build the matching
private source tag when the caller has source access; its default is
from_source=False. Keep the generated lock to record recipe revisions.
The CMake example below works with these Conan packages. For execution from
separate package prefixes, put both Conan library directories in the
application's runtime search path. A deployed application can instead arrange
the two SDKs in one prefix and retain their relative library layout. Before
using the encoder, compare its runtime ABI with the header as described below.
The package provides <pixtreme/nvenc/c/encoder.h> for C and
<pixtreme/nvenc/encoder.hpp> for C++17. The C++ wrapper is header-only;
only C functions cross the shared-library boundary. Both headers include
pixtreme's <pixtreme/pixel_buffer.h> and require neither CUDA headers nor
core headers. The package configuration finds pixtreme through Conan or beside
the encoder in a Python environment. For wheel consumers, locate the installed CMake
prefix using the Python interpreter from the environment containing the wheel:
nvenc_prefix="$(python -c 'import sysconfig; print(sysconfig.get_path("platlib") + "/pixtreme/transport/nvenc")')"
cmake -S /path/to/consumer -B /path/to/consumer/build \
-DCMAKE_PREFIX_PATH="$nvenc_prefix"
cmake --build /path/to/consumer/build
Use .venv/bin/python in place of python when the wheel is installed in a uv
virtual environment that has not been activated. The consumer's
CMakeLists.txt discovers the package and links its imported target:
cmake_minimum_required(VERSION 3.28)
project(output_module LANGUAGES CXX)
find_package(pixtreme_transport_nvenc CONFIG REQUIRED)
add_executable(output_module main.cpp)
target_link_libraries(output_module PRIVATE pixtreme::transport_nvenc)
The target supplies the public include directories, the pixtreme target,
C++17 requirement and shared library. On Windows, the SDK contains
bin/pixtreme_nvenc-6.dll and lib/pixtreme_nvenc.lib; link through
pixtreme::transport_nvenc. Use a compatible MSVC toolchain with the dynamic
C runtime (/MD). The application must make the encoder's bin/ and
pixtreme's core/bin/ available to its DLL loader, for example by deploying
the DLLs beside its executable or registering their directories with
AddDllDirectory. Load one encoder DLL and one pixtreme DLL in each process.
Python packages register their own DLL directories before importing native
modules; applications using the SDK need no Python environment or nvcc.
On Linux, CMake gives the build executable a
runtime search path to the encoder and pixtreme. An installed consumer must
retain an appropriate INSTALL_RPATH. For a shared library installed at
pixtreme/transport/output/liboutput.so, use paths relative to that library:
target_link_libraries(output PRIVATE pixtreme::transport_nvenc)
set_target_properties(output PROPERTIES INSTALL_RPATH "$ORIGIN/../nvenc;$ORIGIN/../../core/lib")
install(TARGETS output LIBRARY DESTINATION pixtreme/transport/output)
Keep the encoder in its own wheel. If the consumer wheel uses auditwheel repair, exclude libpixtreme_nvenc.so, libpixtreme.so.2 and the NVIDIA
driver libraries from copying. Relative $ORIGIN paths allow the Python environment to move without
breaking library loading.
Release tags use vX.Y.Z. CMake uses the numeric release segment of the wheel
version. Package versions and the runtime ABI version advance independently.
An optional version in find_package sets a minimum version. Before any other
encoder operation, compare pixtreme::transport::nvenc::runtime_abi_version()
with the public header's pixtreme::transport::nvenc::abi_version and stop if
they differ. The current ABI version is 6. CMake package discovery does not
perform this runtime check. C++ classes, exceptions and automatic resource
management stay in the consumer's header-only wrapper, so consumers can use a
different compiler and standard library from the encoder.
Static embedding from source
The wheel and prebuilt SDK distribute only the shared encoder library. To
embed the encoder, use the Conan recipe with both from_source=True and
shared=False; source access is required. The recipe rejects shared=False
with the prebuilt SDK (from_source=False). Both forms expose the same C
operations and public headers through pixtreme::transport_nvenc.
After preparing the checkout's Conan dependencies as described in Development, the underlying CMake build is:
python3 cpp/conan/prepare.py --offline --output build/cpp
. ./build/cpp/conanbuild.sh
cd cpp
cmake --preset conan-release -DBUILD_SHARED_LIBS=OFF
cmake --build --preset conan-release -j8
cmake --install ../build/cpp --prefix "$PWD/../build/static-prefix"
cd ..
The static archive contains only encoder objects. pixtreme remains a link
dependency, and the installed target supplies PIXTREME_TRANSPORT_NVENC_STATIC
to select undecorated C declarations. The shared build remains the default;
Python builds explicitly select it. Static archives are built from source
for embedding and are not published in wheels or SDK archives. Re-link an
embedding artifact when updating its encoder; the shared library's ABI
compatibility promise applies to callers linked to that shared library.
C API
For a C consumer of the shared encoder, set project(output_module LANGUAGES C)
in the CMake example. A C consumer of the static encoder enables
LANGUAGES C CXX so CMake can link the encoder's C++ implementation.
Include <pixtreme/nvenc/c/encoder.h>. Before any other operation,
compare pixtreme_transport_nvenc_runtime_abi_version() with
PIXTREME_TRANSPORT_NVENC_ABI_VERSION and stop if they differ.
C types and functions use the pixtreme_transport_nvenc_ prefix. Start each
record with struct_size = sizeof(record), the record size defined by the
caller's header rather than the capacity of a larger allocation. A settings
record requires every field this header defines; fields that a later header
appends use defaults when absent. Outputs write only complete members that fit
the caller's capacity. Accepted settings and low-latency switches are returned
in two independent records, so each record can grow without moving fields in
the other record. The header documents the field rules, including unknown
extensions and partial fields.
Use pixtreme_transport_nvenc_settings_default to create complete settings without
accessing a GPU, and pixtreme_transport_nvenc_settings_apply_options to apply
name/string-value pairs atomically. C++ and Python expose default_settings
and apply_options. See Encoder settings for defaults, names
and value spellings.
Colour options such as primaries set their value and presence together;
unspecified removes the value. Colour presence flags are not named options.
For an absent chroma location, pass chroma_top and chroma_bottom together.
Create a session with pixtreme_transport_nvenc_session_create. Its remaining
operations are session_acquire_input, session_encode, session_reconfigure, session_flush,
session_close, session_take, session_codec_configuration and session_effective_settings, with the same
prefix. Input regions are pixtreme_pixel_buffer_t handles, and wait durations
use nonnegative int64_t milliseconds. The functions return an int32_t
status and optionally an owned error handle; read its reason, classification
and message, then release it with pixtreme_transport_nvenc_error_release. No
exception escapes a C function. An exhausted input pool, a full access-unit
queue, pending output and an unconfirmed close return success with a separate
result indicating that state.
A newly returned session or error owns one reference. Use the matching
retain/release functions for copies and final release. Releasing a session's
last reference starts closing it without waiting. session_acquire_input
returns an owning PixelBuffer, which the caller releases with pixtreme's
pixtreme_pixel_buffer_release or pixtreme_pixel_buffer_destroy. The C++
wrapper performs this reference management automatically.
For output, pass a writable host buffer and its capacity to session_take,
along with pointers for size, a sized
pixtreme_transport_nvenc_access_unit_metadata record and the take status.
The record supplies timestamp, is_idr, display_order, picture_type and
signed dts. The appended dts field is written only when the caller's sized
record includes the complete field; older records keep their existing layout.
A capacity of zero with a null buffer is a normal size query.
PIXTREME_TRANSPORT_NVENC_BUFFER_TOO_SMALL succeeds without changing the
buffer or consuming the AU, and reports a required size greater than the
supplied capacity. Allocate at least that size and retry. Another consumer can
take the queried AU in between, so each retry checks the current front and can
require more capacity. Share one waiting deadline across retries.
PIXTREME_TRANSPORT_NVENC_ACCESS_UNIT writes exactly the actual size and
consumes the AU once. The caller owns those bytes, which stay valid after the
session is released. No access-unit handle needs to be retained or released.
Session API
All public types are in pixtreme::transport::nvenc. Construct a Session
with Settings specifying codec, dimensions, input_format, profile,
rate control, frame rate, GOP length, idr_period, input_slots and CUDA
device. Select Codec::h264, Codec::hevc or Codec::av1 through the same
API. The positive rational frame_rate is used for rate control; DTS uses
input timestamps rather than the frame rate. The encoder does not check input
intervals. idr_period sets the IDR period
for H.264/HEVC and the key-frame period for AV1.
Profile::main selects the chosen codec's Main profile. HEVC also provides
Profile::main10 and Profile::frext. H.264 provides Profile::baseline,
Profile::high, Profile::high10, Profile::high422, Profile::high444,
Profile::stereo, Profile::progressive_high and Profile::constrained_high.
Profile::autoselect selects the runtime-listed automatic profile. Each
selection must agree with the codec, precision and chroma format.
Set input_bit_depth, output_bit_depth and chroma_format to select the
requested input/output precision and output sampling. Zero precision fields
and ChromaFormat::unspecified use the input format's defaults. The input
precision must match the selected format, and runtime support determines the
permitted output combinations.
Choose RateControl::cbr with a target bitrate, RateControl::vbr with
average bitrate and max_bitrate, or RateControl::constqp with
qp.intra, qp.inter_p and qp.inter_b. Lossless encoding requires
lossless=true, CONSTQP and zero for all three QPs, and is available only
where the codec and GPU support it. B frames are controlled by b_frames;
lookahead is controlled by enable_lookahead and lookahead_depth.
max_reference_frames selects the DPB size. num_ref_l0 and num_ref_l1
select forward and backward reference counts independently (0–7 for H.264 and
H.265; AV1 permits 0–4 forward and 0–3 backward). A count above one requires
the codec's multiple-reference capability. vbv_buffer_size and
vbv_initial_delay specify the VBV buffer size and initial delay in bits.
Directly constructed C++ and Python Settings leave all five fields at zero,
preserving the NVENC preset/driver defaults. The default_settings operation
sets the VBV buffer size to twice the rounded average bitrate, in bits, and
leaves the initial delay at zero. DPB size and reference counts remain zero.
Nonzero values are passed without rounding. The C settings record, C++
Settings and Python Settings use the same field names.
effective_settings().accepted retains the request, while the five fields
on EffectiveSettings report the values passed to NVENC, including preset
defaults. AV1 reference counts are SDK hints and may differ from the output.
input_slots selects the fixed number of input regions. At least 1+B
regions are required without lookahead and 1+B+L with lookahead, where
B=b_frames and L=lookahead_depth. A smaller count is an
invalid_configuration error during session creation. For example, two B
frames and lookahead depth four require at least seven regions. When every
region is in use, acquire_input() returns without waiting and reports that
none is available. While access_unit_queue_limit (at least one) access units
wait for take(), encode() returns false without consuming its input.
Inputs that NVENC is still reading add their access units after encode()
accepted them, so up to access_unit_queue_limit + input_slots - 1 access
units can wait.
Input formats
The API covers the SDK 13.0 formats that a pixtreme PixelFormat describes,
subject to codec and GPU support. Each lent PixelBuffer has the corresponding
pixtreme format.
InputFormat value |
pixtreme PixelFormat |
Input precision and layout | Planes |
|---|---|---|---|
InputFormat::nv12 |
nv12 |
8-bit 4:2:0, Y then interleaved UV | 2 |
InputFormat::p010 |
p010 |
10-bit 4:2:0, Y then interleaved UV | 2 |
InputFormat::yv12 |
yv12 |
8-bit 4:2:0, Y then V then U | 3 |
InputFormat::iyuv |
yuv420p |
8-bit 4:2:0, Y then U then V | 3 |
InputFormat::yuv444 |
yuv444p |
8-bit 4:4:4, Y then U then V | 3 |
InputFormat::yuv444_10bit |
yuv444p10msb |
10-bit 4:4:4, Y then U then V | 3 |
InputFormat::nv16 |
nv16 |
8-bit 4:2:2, Y then interleaved UV | 2 |
InputFormat::p210 |
p210 |
10-bit 4:2:2, Y then interleaved UV | 2 |
InputFormat::argb |
bgra |
8-bit packed RGB, B8G8R8A8 bytes | 1 |
InputFormat::abgr |
rgba |
8-bit packed RGB, R8G8B8A8 bytes | 1 |
InputFormat::argb10 |
x2rgb10 |
10-bit packed RGB, little-endian 32-bit word with B in bits 0–9, G in 10–19 and R in 20–29 | 1 |
InputFormat::abgr10 |
x2bgr10 |
10-bit packed RGB, little-endian 32-bit word with R in bits 0–9, G in 10–19 and B in 20–29 | 1 |
InputFormat::ayuv |
vuya |
8-bit packed V8U8Y8A8 bytes | 1 |
The packed formats (the four RGB formats and AYUV) accept any output chroma
format that the codec and GPU support; ChromaFormat::unspecified selects
4:2:0. NVENC converts RGB input to YUV internally. pixtreme's RGB formats hold
full-range RGB without a YCbCr matrix. For x2rgb10 and x2bgr10, pixtreme
ignores bits 30–31 when reading and writes 3 to them. The bitstream's colour
signalling comes from the session settings, not from the input format.
With RGB input, a session accepts the matrix codes 1, 4, 5, 6, 7, 8 and 9 at
either range, the unspecified code 2, or no matrix. abgr and abgr10 input
does not accept code 8 (YCgCo): NVENC's YCgCo conversion swaps R and B of that
byte order, so the Co samples have the opposite sign. NVENC converts the
accepted matrices and ranges as written. For codes 0, 11, 12, 13, 14, 16 and
17, NVENC uses BT.601 instead of the conversion written in the signalling, and
for code 10 it uses BT.2020 non-constant luminance. Code 15 has not been
verified with RGB input. Session creation therefore rejects all of these codes
with RGB input as unsupported; YUV input accepts them. These results come
from the development RTX A6000 (sm 86) with H.264 8-bit and HEVC 8- and 10-bit
output at 4:2:0 and 4:4:4. AV1, 4:2:2 output and H.264 10-bit output with RGB
input, other GPU generations, and the conversion of sessions with the
unspecified matrix 2 or without a matrix have not been verified on hardware.
Input and output
Call acquire_input() to obtain a free input region as a
pixtreme::pixel_buffer. It wraps encoder-owned CUDA memory in the session's
format, dimensions and NVENC plane layout, with unknown colour declarations.
Write the frame into it, for example with pixtreme's to_pixel_buffer, and
record the write in pixtreme's use records (pixtreme's conversions record their
writes; record other work with pixtreme_ndarray_record_stream). Then pass the
PixelBuffer and a std::uint64_t timestamp to encode(). NVENC waits on the
GPU for the recorded uses, so the caller needs no host synchronization. The
encoder uses the selected device's primary CUDA context, and the caller must
write on that device.
encode() submits work without waiting for encoding to finish and accepts
only a region lent by the same session that has not been encoded. The encoder
holds its own reference until NVENC has read the input. A region becomes free
again once every reference is released and the work on the final release
stream completes; taking its access unit is not required. Release a region that
was never encoded with the stream of its last use. Releasing a region does not
wait for its release stream, including the last region that the caller still
holds after the session has been released. An encoder thread that does not keep
the CPU busy then frees the memory after the stream's work completes; if the
encoder cannot create that thread, the releasing call itself waits for the
stream, also without keeping the CPU busy. If the process ends before that work
completes, the encoder leaves the memory unfreed. Call
take(std::chrono::milliseconds) to receive an access unit, a not-ready result,
or the end of the stream after flushing. The wrapper prepares its vector before
consuming an AU. If allocation fails, a later take() can retry the same queued
output.
Every submitted picture yields one access unit, including when identical
pixels are submitted again. Access units are returned in coding order, which
can differ from display order with B frames. Each unit retains the caller's
timestamp unchanged, including duplicate timestamps. display_order
identifies the input picture in display order, and picture_type identifies
the codec's picture category. is_idr identifies H.264/HEVC IDR pictures and
AV1 key pictures.
dts is a signed 64-bit decoding timestamp in the same unit as timestamp
(PTS); the caller owns that unit and supplies it to the muxer. For H.264/H.265
with B frames, coding-order AU i > 0 receives the timestamp of input i - 1
in display order, and the first AU receives the first input timestamp minus
one. With no B frames, and for every AV1 temporal unit, DTS equals PTS.
Lookahead does not change this calculation. An independent-stream
reconfiguration restarts the calculation for the next input while pending
old access units keep their DTS. Timestamps may continue or restart at zero
for the new stream. Input timestamps must be less than 2^63; larger values
raise a recoverable INVALID_CONFIGURATION error before NVENC receives the
picture. The encoder accepts duplicate or decreasing input timestamps and
does not require DTS to increase for those inputs.
For H.264/HEVC, an AU contains one coded picture and its associated NAL units.
For AV1 without scalability, it is a temporal unit containing one shown
picture and the preceding no-show frame OBUs needed for that display, in
coding order. The display may use show_existing_frame to show a previously
coded reference. Its metadata and timestamp identify the shown input picture.
With B frames and lookahead disabled, an input's AU is returned after encoding
without waiting for a later input. Enabling either feature allows output to
be delayed. effective_settings() exposes the accepted settings, including
the colour request, and the low-latency switches.
flush() ends input without waiting for the remaining access units. Continue
calling take() to drain them. close(timeout) stops input and waits up to
the timeout until NVENC no longer reads any accepted input and the internal
collector has exited; it returns false while that is unconfirmed and can be
called again. Outstanding outputs remain available through take() after
close. A region the caller still holds keeps its memory until its final
release. A cleanup failure throws a fatal EncoderError distinct from the
original output error. Other operation failures also use EncoderError, which
exposes their reason and recoverable or fatal classification.
Codec configuration and in-band parameter sets
Session::codec_configuration() returns caller-owned bytes in C++;
Session.codec_configuration() returns Python bytes. Call it before the first
input to obtain H.264 SPS/PPS or H.265 VPS/SPS/PPS as Annex B, or an AV1
sequence-header OBU. Each call reflects the last successful session creation or
reconfiguration and leaves queued access units and their order unchanged.
The returned bytes remain valid after the session closes.
The C operation is
pixtreme_transport_nvenc_session_codec_configuration(session, buffer, capacity, size, error).
Pass a null buffer and zero capacity to query the required size. If the returned
size exceeds capacity, the operation succeeds without copying any bytes. Retry
with enough caller-owned host memory; otherwise exactly the returned size is
copied. Calls after flush or close return an invalid-state error.
Settings::repeat_parameter_sets and Python's Settings.repeat_parameter_sets
default to true / True. Set them to false for a container that stores codec
configuration separately: IDR/key-frame access units then carry no parameter
sets. The C field is a uint32_t containing 0 or 1; an older sized settings
record that omits this field retains the repeating default. This field requires
session recreation to change.
Change settings during a session
Session::reconfigure(settings, start_new_stream) and Python's
Session.reconfigure(settings, start_new_stream) take the complete Settings,
just like session creation. The C operation is
pixtreme_transport_nvenc_session_reconfigure(session, settings, start_new_stream, error);
its stream flag is a uint32_t containing 0 or 1.
For example, Python can reuse a session for independent clips by changing its current settings before submitting the next clip:
settings = session.effective_settings().accepted
settings.bitrate = 2_000_000
session.reconfigure(settings, start_new_stream=True)
# Take every access unit of the previous clip, then submit the next clip.
The same change in C++ is:
auto settings = session.effective_settings().accepted;
settings.bitrate = 2'000'000;
session.reconfigure(settings, true);
With start_new_stream=true, pending pictures become available through take()
without another input. The next input becomes an IDR with parameter sets, has
no reference to the previous stream, and starts with reset rate control. The
bitstream beginning at that IDR can be decoded independently. When
repeat_parameter_sets is false, combine the new codec configuration with that
IDR stream for independent decoding. The operation
maps this single flag to NVENC's forceIDR=1 and resetEncoder=1.
With start_new_stream=false, changes affect pictures encoded after the
operation, including accepted pictures still waiting for encoding. Access units
already copied to the caller stay valid. Both modes preserve accepted pictures,
queued output, coding order and the timestamps attached to each input.
| Setting | Change during a session |
|---|---|
| Rate control mode, CBR/VBR bitrate, VBR maximum, CONSTQP I/P/B QPs | Allowed |
| VBV buffer size and initial delay | Allowed; initial delay is used when rate control resets |
Forward reference count (num_ref_l0) |
Requires start_new_stream=true |
Backward reference count (num_ref_l1) |
H.264 requires start_new_stream=true; H.265 permits either mode |
| IDR period | H.264 permits either direction; H.265 permits increases only |
| Every other setting | Requires recreating the session |
Settings that require recreation include codec, profile, dimensions, input
format, precision, chroma, frame rate, GOP length, B frames, lookahead, DPB size,
lossless tuning, colour, device, input regions, queue capacity and
repeat_parameter_sets. The operation
rejects these changes before calling NVENC, with INVALID_CONFIGURATION and
RECOVERABLE, naming the field and the required action. Reconfiguration after
flush() or close() returns INVALID_STATE and RECOVERABLE. A failed NVENC
reconfiguration is fatal because its previous state cannot be confirmed.
effective_settings() returns one complete snapshot of the last successful
configuration, including when another thread changes settings. A change rejected
before NVENC leaves that snapshot unchanged. flush() still ends session input;
call reconfigure() before flushing when the session will continue.
Colour signalling
Settings::colour takes H.273 codes through ColourSignalling: primaries,
transfer, matrix and full_range (0 for limited range, 1 for full range).
Each value is specified or left absent on its own; absent codes are written as
2 (unspecified) and an absent range as 0. H.264 and HEVC use the SPS VUI: any
specified value sets video_signal_type_present_flag=1 with video_format=5
(unspecified), and any specified code sets colour_description_present_flag=1.
With all four absent, H.264/HEVC set video_signal_type_present_flag=0. AV1
uses the sequence header's color_config, which always carries a range; it
sets color_description_present_flag=0 when all three codes are absent or 2.
chroma_location supplies top and bottom field H.273 types through
ChromaLocation. It is valid only for 4:2:0 output; without it, H.264/HEVC set
chroma_loc_info_present_flag=0. H.264/HEVC accept types 0–5; progressive
content should normally use the same type for both fields. AV1 requires equal
types that map to its single chroma_sample_position: type 0 maps to position
1 and type 2 maps to position 2. Reserved codes, out-of-range values and colour
requests that the selected codec and chroma format cannot express are rejected
as invalid_configuration before session creation. For example, AV1 infers
full range for BT.709 primaries with the sRGB transfer and the identity matrix,
so that combination requires full_range 1. H.264 and HEVC allow the matrix
codes 0 (identity), 16 (YCgCo-Re) and 17 (YCgCo-Ro) only for 4:4:4 output, so
4:2:0 and 4:2:2 requests with those codes are rejected.
effective_settings().accepted.colour returns the colour request. The encoder
does not read colour back from its output; inspect the bitstream to check the
written values.
Measured throughput
In 60-second HEVC measurements on an RTX A6000 under WSL2 (driver 616.92, CUDA 13.2.86, Release build), both NV12/Main and P010/Main10 were measured at 1920x1080 at 30000/1001 fps, 3840x2160 at 30000/1001 fps, and 1920x1080 at 60000/1001 fps. Each configuration used four input regions, no B frames or lookahead, CBR at 10 Mbps for 1080p or 35 Mbps for 2160p. GOP and IDR periods were 60 frames at 30000/1001 fps and 120 frames at 60000/1001 fps. Inputs were tested both as fast as possible and at the specified frame rate. All submitted inputs produced an AU. Submitting as fast as possible, every configuration encoded at least 220 fps at 1920x1080 and at least 149 fps at 3840x2160. At the specified frame rate, the paced runs skipped no inputs, except the 1920x1080 NV12/Main run at 60000/1001 fps, which skipped one of 3,597 scheduled inputs because no input region or access unit queue space was free at its scheduled time. The measured GPU was reserved for encoding and the benchmark was pinned to two logical CPUs; work on a separate GPU ran concurrently on other CPUs. These measurements cover the encoder with a CUDA test-picture producer, excluding the core conversion and output module.
Distribution
Versioned wheels are published on PyPI and in the public
GitHub Releases.
SDK-enabled releases also contain
pixtreme_transport_nvenc-X.Y.Z-sdk-manylinux_2_28_x86_64.tar.gz and
pixtreme_transport_nvenc-X.Y.Z-sdk-win_amd64.tar.gz.
One SHA256SUMS records both wheels and both SDK archives. Recipes are distributed
by sync-dev-org/conan-recipes, separately from the encoder Release. The SDK
retains the wheel's encoder library, public headers,
CMake package and license notices, and excludes Python and pixtreme libraries.
License
The package uses the MIT License. The wheel's *.dist-info/licenses/ directory
contains the project license, the MIT notice for NVIDIA's NVENC
header, and the notices of the components compiled into the Python module:
nanobind (BSD-3-Clause) and its robin_map (MIT). The wheel's license expression
is MIT AND BSD-3-Clause.
Metadata
Release files for pixtreme-transport-nvenc 0.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pixtreme_transport_nvenc-0.14.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details for pixtreme_transport_nvenc-0.14.0-cp312-abi3-win_amd64.whl |
| pixtreme_transport_nvenc-0.14.0-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details for pixtreme_transport_nvenc-0.14.0-cp312-abi3-manylinux_2_28_x86_64.whl |
Total release size: 454.7 kB
Release files / pixtreme_transport_nvenc-0.14.0-cp312-abi3-win_amd64.whl
| Download URL | pixtreme_transport_nvenc-0.14.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 219.4 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e66746449fabc26b88750458050b38ffd023270275f42036bf26ff7eb972dee6
|
|
BLAKE2b-256 checksum How to use checksums |
8f53c2c09bf8d6255e38172675255f9dedf5a600dde0dbff0303d4b5b1d9c158
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / pixtreme_transport_nvenc-0.14.0-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | pixtreme_transport_nvenc-0.14.0-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 235.3 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
facf290eeeddde90d2a87730f35224581ef7ae8f7290d84deb61afe3587a292a
|
|
BLAKE2b-256 checksum How to use checksums |
d26c2714ecd86d16ab09694c10547cad8b242c56fa7d19470ac8c64d20d18fbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for pixtreme-transport-nvenc 0.14.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.