python_vali.PyNvEncoder

class python_vali.PyNvEncoder

HW-accelerated video encoder which uses Nvenc.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: python_vali._python_vali.PyNvEncoder, settings: Dict[str, str], gpu_id: int, format: python_vali._python_vali.PixelFormat = <PixelFormat.NV12: 3>, verbose: bool = False) -> None

    Constructor method.

    param settings:

    Dictionary with nvenc settings

    param gpu_id:

    what GPU to run encode on

    param format:

    pixel format to use by codec

    param verbose:

    output verbose information to log

  2. __init__(self: python_vali._python_vali.PyNvEncoder, settings: Dict[str, str], stream: int, format: python_vali._python_vali.PixelFormat = <PixelFormat.NV12: 3>, verbose: bool = False) -> None

    Constructor method.

    param settings:

    Dictionary with nvenc settings

    param stream:

    CUDA stream to use

    param format:

    pixel format to use by codec

    param verbose:

    output verbose information to log

Methods

EncodeSingleSurface(*args, **kwargs)

Overloaded function.

Flush(self, packets)

Flush encoder.

FlushSinglePacket(self, packets)

Flush encoder.

Reconfigure(self, settings[, force_idr, ...])

DESC.

__init__(*args, **kwargs)

Overloaded function.

Attributes

Capabilities

Return dictionary with Nvenc capabilities.

Format

Return encoded video stream pixel format.

FrameSizeInBytes

This function is used to get the current frame size based on pixel format.

Height

Return encoded video stream height in pixels.

Width

Return encoded video stream width in pixels.

property Capabilities

Return dictionary with Nvenc capabilities.

EncodeSingleSurface(*args, **kwargs)

Overloaded function.

  1. EncodeSingleSurface(self: python_vali._python_vali.PyNvEncoder, surface: VPF::Surface, packet: numpy.ndarray[numpy.uint8], sei: numpy.ndarray[numpy.uint8], sync: bool, append: bool) -> bool

    Encode single Surface. Please not that this function may not return compressed video packet.

    param surface:

    raw input Surface

    param packet:

    output compressed packet

    param sei:

    unregistered user data SEI information to be attached to encoded bitstream

    param sync:

    run function in sync mode, will ensure encoded packet is returned when function returns

    param append:

    append encoded packet to input packet

    return:

    True in case of success, False otherwise.

  2. EncodeSingleSurface(self: python_vali._python_vali.PyNvEncoder, surface: VPF::Surface, packet: numpy.ndarray[numpy.uint8], sei: numpy.ndarray[numpy.uint8], sync: bool) -> bool

    Encode single Surface. Please not that this function may not return compressed video packet.

    param surface:

    raw input Surface

    param packet:

    output compressed packet

    param sei:

    unregistered user data SEI information to be attached to encoded bitstream

    param sync:

    run function in sync mode, will ensure encoded packet is returned when function returns

    return:

    True in case of success, False otherwise.

  3. EncodeSingleSurface(self: python_vali._python_vali.PyNvEncoder, surface: VPF::Surface, packet: numpy.ndarray[numpy.uint8], sync: bool) -> bool

    Encode single Surface. Please not that this function may not return compressed video packet.

    param surface:

    raw input Surface

    param packet:

    output compressed packet

    param sync:

    run function in sync mode, will ensure encoded packet is returned when function returns

    return:

    True in case of success, False otherwise.

  4. EncodeSingleSurface(self: python_vali._python_vali.PyNvEncoder, surface: VPF::Surface, packet: numpy.ndarray[numpy.uint8], sei: numpy.ndarray[numpy.uint8]) -> bool

    Encode single Surface. Please not that this function may not return compressed video packet.

    param surface:

    raw input Surface

    param packet:

    output compressed packet

    param sei:

    unregistered user data SEI information to be attached to encoded bitstream

    return:

    True in case of success, False otherwise.

  5. EncodeSingleSurface(self: python_vali._python_vali.PyNvEncoder, surface: VPF::Surface, packet: numpy.ndarray[numpy.uint8]) -> bool

    Encode single Surface. Please not that this function may not return compressed video packet.

    param surface:

    raw input Surface

    param packet:

    output compressed packet

    return:

    True in case of success, False otherwise.

Flush(self: python_vali._python_vali.PyNvEncoder, packets: numpy.ndarray[numpy.uint8]) bool

Flush encoder. Use this method in the end of encoding session to obtain all remaining compressed frames.

Parameters:

packets – one or multiple compressed packets squashed together.

Returns:

True in case of success, False otherwise.

FlushSinglePacket(self: python_vali._python_vali.PyNvEncoder, packets: numpy.ndarray[numpy.uint8]) bool

Flush encoder. Use this method in the end of encoding session to obtain single remaining compressed frame. TO flush encoder completely you need to call this method multiple times.

Parameters:

packets – single compressed packet.

Returns:

True in case of success, False otherwise.

property Format

Return encoded video stream pixel format.

property FrameSizeInBytes

This function is used to get the current frame size based on pixel format.

property Height

Return encoded video stream height in pixels.

Reconfigure(self: python_vali._python_vali.PyNvEncoder, settings: Dict[str, str], force_idr: bool = False, reset_encoder: bool = False, verbose: bool = False) bool

DESC.

Parameters:
  • settings – Dictionary with nvenc settings

  • force_idr – force next encoded frame to be IDR key frame

  • reset_encoder – force encoder reset

  • verbose – output verbose information to log

Returns:

property Width

Return encoded video stream width in pixels.