avcpp icon indicating copy to clipboard operation
avcpp copied to clipboard

Support for gpu-accelerated decoding?

Open morphogencc opened this issue 3 years ago • 5 comments

Does avcpp support gpu-accelerated decoding/encoding via nvenc?

morphogencc avatar Jan 06 '22 20:01 morphogencc

I've tested hardware decoding with h264_cuvid. It works. You need to create codec context using something like this:

av::VideoDecoderContext vdec(stream, av::findDecodingCodec("h264_cuvid"))

teodly avatar Mar 08 '22 12:03 teodly

It works with Nvidia GPU decoding, if you build ffmpeg with support for it. I have not tested with encoding, however. https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/ https://trac.ffmpeg.org/wiki/HWAccelIntro

tehkillerbee avatar Sep 21 '22 11:09 tehkillerbee

Hardware-accelerated encoding also works (tested with nvenc). You may need to set low-level libavcodec's fields: hw_device_ctx and hw_frames_ctx using av::VideoDecoderContext::raw() accessor.

Transcoding without raw frames leaving GPU's internal RAM (VRAM) is also possible if hw_frames_ctx->format is set to appropriate hardware "pixel format", e.g. AV_PIX_FMT_CUDA. It makes transcoding less PCIe-bandwidth-intensive. I can provide more details if anyone is interested in it.

teodly avatar Oct 31 '23 20:10 teodly

@teowoz , thanks for answer! I am so happy if you send a PR with minimal sample for nvenc usage. And will thinking about proper wrapping with high level code...

h4tr3d avatar Nov 01 '23 03:11 h4tr3d