PyNvCodec.PyNvDecoder

class PyNvCodec.PyNvDecoder
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: PyNvCodec._PyNvCodec.PyNvDecoder, width: int, height: int, format: PyNvCodec._PyNvCodec.PixelFormat, codec: PyNvCodec._PyNvCodec.CudaVideoCodec, gpu_id: int) -> None

    Constructor method. Initialize HW decoding session with set of particular parameters such as video stream resolution, pixel format and video codec. Use this constructor alongside external demuxer.

    param width:

    video file width

    param height:

    video file height

    param format:

    pixel format used by codec

    param codec:

    video codec to use

    param gpu_id:

    what GPU to run decode on

  2. __init__(self: PyNvCodec._PyNvCodec.PyNvDecoder, input: str, gpu_id: int, opts: Dict[str, str]) -> None

    Constructor method. Initialize HW decoding section with path to input, GPU ID and dictionary of AVDictionary options that will be passed to built-in FFMpeg-based demuxer.

    param input:

    path to input file

    param gpu_id:

    what GPU to run decode on

    param opts:

    AVDictionary options that will be passed to AVFormat context.

  3. __init__(self: PyNvCodec._PyNvCodec.PyNvDecoder, input: str, gpu_id: int) -> None

    Constructor method. Initialize HW decoding section with path to input, and GPU ID. FFMpeg-based built-in demuxer will be used.

    param input:

    path to input file

    param gpu_id:

    what GPU to run decode on

  4. __init__(self: PyNvCodec._PyNvCodec.PyNvDecoder, width: int, height: int, format: PyNvCodec._PyNvCodec.PixelFormat, codec: PyNvCodec._PyNvCodec.CudaVideoCodec, context: int, stream: int) -> None

    Constructor method. Initialize HW decoding session with set of particular parameters such as video stream resolution, pixel format, video codec, CUDA context and stream Use this constructor alongside external demuxer.

    param width:

    video file width

    param height:

    video file height

    param format:

    pixel format used by codec

    param codec:

    video codec to use

    param context:

    CUDA context to use

    param stream:

    CUDA stream to use

  5. __init__(self: PyNvCodec._PyNvCodec.PyNvDecoder, input: str, context: int, stream: int, opts: Dict[str, str]) -> None

    Constructor method. Initialize HW decoding section with path to input, CUDA context and stream and dictionary of AVDictionary options that will be passed to built-in FFMpeg-based demuxer.

    param input:

    path to input file

    param context:

    CUDA context to use

    param stream:

    CUDA stream to use

    param opts:

    AVDictionary options that will be passed to AVFormat context.

  6. __init__(self: PyNvCodec._PyNvCodec.PyNvDecoder, input: str, context: int, stream: int) -> None

    Constructor method. Initialize HW decoding section with path to input, CUDA context and stream.

    param input:

    path to input file

    param context:

    CUDA context to use

    param stream:

    CUDA stream to use

Methods

AvgFramerate(self)

Return encoded video file average framerate.

Capabilities(self)

Return dictionary with Nvdec capabilities.

ColorRange(self)

Get color range information stored in video file.

ColorSpace(self)

Get color space information stored in video file.

DecodeFrameFromPacket(*args, **kwargs)

Overloaded function.

DecodeSingleFrame(*args, **kwargs)

Overloaded function.

DecodeSingleSurface(*args, **kwargs)

Overloaded function.

DecodeSurfaceFromPacket(*args, **kwargs)

Overloaded function.

FlushSingleFrame(*args, **kwargs)

Overloaded function.

FlushSingleSurface(*args, **kwargs)

Overloaded function.

Format(self)

Return encoded video file pixel format.

Framerate(self)

Return encoded video file framerate.

Framesize(self)

Return decoded video frame size in bytes.

Height(self)

Return encoded video file height in pixels.

IsVFR(self)

Tell if video file has variable frame rate.

LastPacketData(self, pkt_data)

Get last packet data.

Numframes(self)

Return number of video frames in encoded video file.

Timebase(self)

Return encoded video file time base.

Width(self)

Return encoded video file width in pixels.

__init__(*args, **kwargs)

Overloaded function.

AvgFramerate(self: PyNvCodec._PyNvCodec.PyNvDecoder) float

Return encoded video file average framerate.

Capabilities(self: PyNvCodec._PyNvCodec.PyNvDecoder) Dict[PyNvCodec._PyNvCodec.NV_DEC_CAPS, int]

Return dictionary with Nvdec capabilities.

ColorRange(self: PyNvCodec._PyNvCodec.PyNvDecoder) PyNvCodec._PyNvCodec.ColorRange

Get color range information stored in video file. Please not that some video containers may not store this information.

Returns:

color range information

ColorSpace(self: PyNvCodec._PyNvCodec.PyNvDecoder) PyNvCodec._PyNvCodec.ColorSpace

Get color space information stored in video file. Please not that some video containers may not store this information.

Returns:

color space information

DecodeFrameFromPacket(*args, **kwargs)

Overloaded function.

  1. DecodeFrameFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], packet: numpy.ndarray[numpy.uint8]) -> bool

    Combination of DecodeSingleSurfaceFromPacket + DownloadSingleSurface

    param frame:

    decoded video frame

    param packet:

    encoded video packet

    return:

    True in case of success, False otherwise

  2. DecodeFrameFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], enc_packet_data: PyNvCodec._PyNvCodec.PacketData, packet: numpy.ndarray[numpy.uint8]) -> bool

    Combination of DecodeSingleSurfaceFromPacket + DownloadSingleSurface

    param frame:

    decoded video frame

    param enc_packet_data:

    PacketData structure of encoded video packet

    param packet:

    encoded video packet

    return:

    True in case of success, False otherwise

  3. DecodeFrameFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], enc_packet_data: PyNvCodec._PyNvCodec.PacketData, packet: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of DecodeSingleSurfaceFromPacket + DownloadSingleSurface

    param frame:

    decoded video frame

    param enc_packet_data:

    PacketData structure of encoded video packet

    param packet:

    encoded video packet

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

    return:

    True in case of success, False otherwise

  4. DecodeFrameFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], packet: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of DecodeSingleSurfaceFromPacket + DownloadSingleSurface

    param frame:

    decoded video frame

    param packet:

    encoded video packet

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

    return:

    True in case of success, False otherwise

DecodeSingleFrame(*args, **kwargs)

Overloaded function.

  1. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], sei: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param sei:

    decoded frame SEI data

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

    return:

    True in case of success, False otherwise

  2. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], sei: numpy.ndarray[numpy.uint8], seek_context: PyNvCodec._PyNvCodec.SeekContext) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param sei:

    decoded frame SEI data

    param seek_context:

    SeekContext structure with information about seek procedure

    return:

    True in case of success, False otherwise

  3. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], sei: numpy.ndarray[numpy.uint8], seek_context: PyNvCodec._PyNvCodec.SeekContext, pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param sei:

    decoded frame SEI data

    param seek_context:

    SeekContext structure with information about seek procedure

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

    return:

    True in case of success, False otherwise

  4. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8]) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    return:

    True in case of success, False otherwise

  5. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

    return:

    True in case of success, False otherwise

  6. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], seek_context: PyNvCodec._PyNvCodec.SeekContext) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param seek_context:

    SeekContext structure with information about seek procedure

    return:

    True in case of success, False otherwise

  7. DecodeSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], seek_context: PyNvCodec._PyNvCodec.SeekContext, pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of DecodeSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param seek_context:

    SeekContext structure with information about seek procedure

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

    return:

    True in case of success, False otherwise

DecodeSingleSurface(*args, **kwargs)

Overloaded function.

  1. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM.

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

  2. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, sei: numpy.ndarray[numpy.uint8]) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM.

    param sei:

    decoded frame SEI data

  3. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, sei: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM.

    param sei:

    decoded frame SEI data

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

  4. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, sei: numpy.ndarray[numpy.uint8], seek_context: PyNvCodec._PyNvCodec.SeekContext) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM. Use this function for seek + decode.

    param sei:

    decoded frame SEI data

    param seek_context:

    SeekContext structure with information about seek procedure

  5. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, sei: numpy.ndarray[numpy.uint8], seek_context: PyNvCodec._PyNvCodec.SeekContext, pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM. Use this function for seek + decode.

    param sei:

    decoded frame SEI data

    param seek_context:

    SeekContext structure with information about seek procedure

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

  6. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM.

  7. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, seek_context: PyNvCodec._PyNvCodec.SeekContext) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM. Use this function for seek + decode.

    param seek_context:

    SeekContext structure with information about seek procedure

  8. DecodeSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, seek_context: PyNvCodec._PyNvCodec.SeekContext, pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Decode single video frame from input stream. Video frame is returned as Surface stored in vRAM. Use this function for seek + decode.

    param seek_context:

    SeekContext structure with information about seek procedure

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

DecodeSurfaceFromPacket(*args, **kwargs)

Overloaded function.

  1. DecodeSurfaceFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, enc_packet_data: PyNvCodec._PyNvCodec.PacketData, packet: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData, bool_nvcv_check: bool) -> object

    Decode single video frame from input stream. Video frame is returned as NVCVImage.

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

  2. DecodeSurfaceFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, packet: numpy.ndarray[numpy.uint8]) -> VPF::Surface

    Decode single video frame from compressed video packet. Please note that function may not return decoded Surface. Use this to decode compressed packets obtained from external demuxer.

    Video frame is returned as Surface stored in vRAM.

    param packet:

    encoded video packet

  3. DecodeSurfaceFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, enc_packet_data: PyNvCodec._PyNvCodec.PacketData, packet: numpy.ndarray[numpy.uint8]) -> VPF::Surface

    Decode single video frame from compressed video packet. Please note that function may not return decoded Surface. Use this to decode compressed packets obtained from external demuxer.

    Video frame is returned as Surface stored in vRAM.

    param enc_packet_data:

    PacketData structure of encoded video packet

    param packet:

    encoded video packet

  4. DecodeSurfaceFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, packet: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Decode single video frame from compressed video packet. Please note that function may not return decoded Surface. Use this to decode compressed packets obtained from external demuxer.

    Video frame is returned as Surface stored in vRAM.

    param packet:

    encoded video packet

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

  5. DecodeSurfaceFromPacket(self: PyNvCodec._PyNvCodec.PyNvDecoder, enc_packet_data: PyNvCodec._PyNvCodec.PacketData, packet: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Decode single video frame from compressed video packet. Please note that function may not return decoded Surface. Use this to decode compressed packets obtained from external demuxer.

    Video frame is returned as Surface stored in vRAM.

    param enc_packet_data:

    PacketData structure of encoded video packet

    param packet:

    encoded video packet

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

FlushSingleFrame(*args, **kwargs)

Overloaded function.

  1. FlushSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8]) -> bool

    Combination of FlushSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

  2. FlushSingleFrame(self: PyNvCodec._PyNvCodec.PyNvDecoder, frame: numpy.ndarray[numpy.uint8], pkt_data: PyNvCodec._PyNvCodec.PacketData) -> bool

    Combination of FlushSingleSurface + DownloadSingleSurface

    param frame:

    decoded video frame

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

FlushSingleSurface(*args, **kwargs)

Overloaded function.

  1. FlushSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder) -> VPF::Surface

    Send null input to decoder. Use this function in the end of decoding session to flush decoder and obtain those video frames which were not returned yet.

    If this method returns empty Surface it means there are no decoded frames left.

    Video frame is returned as Surface stored in vRAM.

  2. FlushSingleSurface(self: PyNvCodec._PyNvCodec.PyNvDecoder, pkt_data: PyNvCodec._PyNvCodec.PacketData) -> VPF::Surface

    Send null input to decoder. Use this function in the end of decoding session to flush decoder and obtain those video frames which were not returned yet.

    If this method returns empty Surface it means there are no decoded frames left.

    Video frame is returned as Surface stored in vRAM.

    param pkt_data:

    PacketData structure of decoded frame with PTS, DTS etc.

Format(self: PyNvCodec._PyNvCodec.PyNvDecoder) PyNvCodec._PyNvCodec.PixelFormat

Return encoded video file pixel format.

Framerate(self: PyNvCodec._PyNvCodec.PyNvDecoder) float

Return encoded video file framerate.

Framesize(self: PyNvCodec._PyNvCodec.PyNvDecoder) int

Return decoded video frame size in bytes.

Height(self: PyNvCodec._PyNvCodec.PyNvDecoder) int

Return encoded video file height in pixels.

IsVFR(self: PyNvCodec._PyNvCodec.PyNvDecoder) bool

Tell if video file has variable frame rate.

Returns:

True in case video file has variable frame rate, False otherwise

LastPacketData(self: PyNvCodec._PyNvCodec.PyNvDecoder, pkt_data: PyNvCodec._PyNvCodec.PacketData) None

Get last packet data.

Parameters:

pkt_data – PacketData structure.

Numframes(self: PyNvCodec._PyNvCodec.PyNvDecoder) int

Return number of video frames in encoded video file. Please note that some video containers doesn’t store this infomation.

Timebase(self: PyNvCodec._PyNvCodec.PyNvDecoder) float

Return encoded video file time base.

Width(self: PyNvCodec._PyNvCodec.PyNvDecoder) int

Return encoded video file width in pixels.