[Libav-user] Hardware transcoding with filter

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Libav-user] Hardware transcoding with filter

Strahinja Radman
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!


Libav-user mailing list
[hidden email]

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".