python_vali.PyNvEncoder¶
- class python_vali.PyNvEncoder¶
HW-accelerated video encoder which uses Nvenc.
- __init__(*args, **kwargs)¶
Overloaded function.
__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
__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
Return dictionary with Nvenc capabilities.
Return encoded video stream pixel format.
This function is used to get the current frame size based on pixel format.
Return encoded video stream height in pixels.
Return encoded video stream width in pixels.
- property Capabilities¶
Return dictionary with Nvenc capabilities.
- EncodeSingleSurface(*args, **kwargs)¶
Overloaded function.
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.
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.
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.
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.
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.