New to vide encode decoding. Using PyNvVideoCodec for decoding. Looking for ways to convert the decode frame to RGB UINT8 image.
nv_dmx = nvc.CreateDemuxer(filename="codylexi.mp4")
nv_dec = nvc.CreateDecoder(gpuid=0,
codec=nv_dmx.GetNvCodecId(),
cudacontext=0,
cudastream=0,
usedevicememory=True)
decoded_frame_size = 0
raw_frame = None
height = nv_dmx.Height()
width = nv_dmx.Width()
y_size = width * height
uv_size = width * height // 2
seq_triggered = False
# printing out FPS and pixel format of the stream for convenience
print("FPS = ", nv_dmx.FrameRate())
for packet in nv_dmx:
# Decode returns a list of packets, range of this list is from [0, size of (decode picture buffer)]
# size of (decode picture buffer) depends on GPU, fur Turing series its 8
for decoded_frame in nv_dec.Decode(packet):
# 'decoded_frame' contains list of views implementing cuda array interface
# for nv12, it would contain 2 views for each plane and two planes would be contiguous
if not seq_triggered:
print(decoded_frame.format)
decoded_frame_size = nv_dec.GetFrameSize()
raw_frame = np.ndarray(shape=decoded_frame_size, dtype=np.uint8)
seq_triggered = True
decoded_frame = decoded_frame.nvcv_image()