-
Notifications
You must be signed in to change notification settings - Fork 428
Open
Description
In the current implementation, the following error occurs during the process of initializing the codec context to encode a frame in GPU memory using nvenc with pix_fmt=“cuda”.
cc = av.CodecContext.create("h264_nvenc", "w")
cc.width = 864
cc.height = 1904
cc.time_base = fractions.Fraction(1, 24)
cc.framerate = fractions.Fraction(24, 1)
cc.pix_fmt = "cuda"
cc.bit_rate = 6 * 1024 * 1024
y = torch.zeros((1904, 864), dtype=torch.uint8, device="cuda")
uv = torch.zeros((952, 432, 2), dtype=torch.uint8, device="cuda")
frame = av.VideoFrame.from_dlpack((y, uv))
cc.encode(frame)hw_frames_ctx must be set when using GPU frames as input
Invalid argument: 'avcodec_open2("h264_nvenc", {})' returned 22
When pix_fmt=“nv12” is applied, it is presumed that the encoder copies the data to the CPU and then back to the GPU. To prevent this, I would like to modify the code so that when pix_fmt=“cuda”, it executes via the correct path.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels