[Libav-user] Hardware transcoding with filter

Strahinja Radman dr.strashni at gmail.com
Fri Jan 10 22:02:44 EET 2020


Hello everyone,

I am having trouble initializing scale_cuda or scale_npp filter while using
CUDA hardware. I have created the decoder and encoder using the example
code from ffmpeg's github, hw_decode.c. This includes creating the hardware
context with av_hwdevice_ctx_create(), which is shared between decoder and
encoder, and presumably filter using the av_buffer_ref() call. After this,
following code is invoked to set hw_frames_ctx for decoder and encoder:

 codec_ctx->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx);

AVHWFramesContext* frames_ctx =
(AVHWFramesContext*)(ctx->hw_frames_ctx->data);
frames_ctx->format = AV_PIX_FMT_CUDA;
frames_ctx->sw_format = AV_PIX_FMT_NV12;
frames_ctx->width = ctx->width;
frames_ctx->height = ctx->height;
frames_ctx->initial_pool_size = 20;

err = av_hwframe_ctx_init(codec_ctx->hw_frames_ctx);

This code works fine, and everything seems to be set properly when I call
avcodec_open2() for encoder and decoder. Problem comes when I try to
initialize filter scale_cuda or scale_npp. scale_cuda simply gives
segmentation fault when invoking avfilter_graph_config(), and scale_npp
gives following message:

No hw context provided on input
Failed to configure output pad on Parsed_scale_npp_0

Currently I am not sure how to set hardware context on input filter, or
output filter or what exactly needs to be done to get this thing to work.
Any help is greatly appreciated!
-- 

Regards
Strahinja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200110/ffe3d910/attachment.html>


More information about the Libav-user mailing list