> Thanks! I read through the nvidia docs. It seems that I need to pass in the "hwaccel: cuvid" option in order to keep the raw frame in GPU memory. Do you have any idea how to do this in Libav (C)? I tried following this Stackoverflow post, <https://stackoverflow.com/questions/5985273/using-ffmpeg-hwaccel-from-c?fbclid=IwAR0bI8NuMoc29Kw_tCwGQVogXAsG4liAqYSw6hftOZ2n8H5jn-JIV6RVdko> but av_hwaccel_next() kept > returning NULL for a pixel format of AV_PIX_FMT_YUV420P and a codec of "h264_nvenc." I also see that av_hwaccel_next is deprecated. Do you have any suggestions?
You first need to create hardware device context, this example will get you started https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c . After this you need to create hardware frames context which you will use to pass frames inside of the GPU. For decoder get_hw_format should look something like this enum AVPixelFormat get_hw_format(AVCodecContext* ctx, const enum AVPixelFormat* pix_fmts) { const enum AVPixelFormat* p; for (p = pix_fmts; *p != -1; p++) { if (*p == this->hw_pix_fmt) break; } ctx->hw_frames_ctx = av_buffer_ref(this->hw_frames_ctx); //This is the important line if (!p) return AV_PIX_FMT_NONE; return *p; } While opening the encoder you simply reference the same hw_frames_ctx enc_ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ctx); And that should be it. -- Regards Strahinja Radman
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
