Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for gpu-accelerated decoding? #99

Open
morphogencc opened this issue Jan 6, 2022 · 4 comments
Open

Support for gpu-accelerated decoding? #99

morphogencc opened this issue Jan 6, 2022 · 4 comments

Comments

@morphogencc
Copy link

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

@teowoz
Copy link
Contributor

teowoz commented Mar 8, 2022

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"))

@tehkillerbee
Copy link

tehkillerbee commented Sep 21, 2022

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

@teowoz
Copy link
Contributor

teowoz commented Oct 31, 2023

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.

@h4tr3d
Copy link
Owner

h4tr3d commented Nov 1, 2023

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants