2

I need to encode a raw video stream captured from a camera to h264. I'm using an NVIDIA Pascal GPU under Windows 7 and am trying to use FFmpeg to control the h264_nvenc, rather than the NVIDIA SDK directly.

Using libavcodec, I've got a program that successfully encodes the input stream using avcodec_encode_video2(). This function takes the input image from a buffer in RAM and DMAs it to the GPU where it is encoded.

I now want to encode an image that is already on the GPU (in a CUDA buffer). Looking at the documentation and various examples for FFmpeg, I didn't find any pointers as to how to do this.

Does anybody know if this is possible, and if so how to do it?

talonmies
  • 70,661
  • 34
  • 192
  • 269
JPh
  • 536
  • 3
  • 20
  • Use the AVIOContext for that. – WLGfx Jan 19 '18 at 14:38
  • There are several examples from ffmpeg repo you can refer to, including `qsvdec.c`, `hw_decode.c` and `vaapi_encode.c`. Though these sources cannot give a direct solution, it is a good start to try encoding hardware buffer. `qsvdec` and `hw_decode` shows how to do the opposite: decoding from a hardware buffer, and I've successfully ported this to nvdec before. `vaapi_encode` is the only encoding example, maybe you could port it to nvenc. GL – halfelf Jan 20 '18 at 03:21
  • You might already did but I'll tell you anyway. Go and download nvidia NVENC SDK (Video_Codec_SDK_7.1.9 currently latest version - registration required and it's free). It has all the documents fro API and samples for encoding and decoding. Even one of sample app named "NvEncoderCudaInterop". Hope that helps. – the kamilz Jan 22 '18 at 07:45

0 Answers0