Skip to content

Conversation

@marktech0813
Copy link

What I changed
If you set a hardware pixel format (e.g., AV_PIX_FMT_CUDA) on the filter, FFmpegFrameFilter now uses NV12 for the buffersrc’s pix_fmt and logs a warning. This prevents avfilter_graph_config() from failing due to a missing hw_frames_ctx.
You can still override the buffersrc arguments entirely via setVideoFilterArgs() if you need a different software format.

How to use it now

  • Keep your GPU filter chain starting with hwupload_cuda (e.g., "hwupload_cuda,scale_cuda=...").
  • If you call filter.setPixelFormat(AV_PIX_FMT_CUDA), the filter will automatically configure buffersrc with NV12 and continue; no hw_frames_ctx error.
  • If your software input format isn’t NV12, set videoFilterArgs to the exact buffersrc args you need (it overrides the fallback), or set a software filter.setPixelFormat(...) like AV_PIX_FMT_YUV420P.

Status

  • I changed FFmpegFrameFilter only; no other files touched.
  • Prevents filter initialization failure when a hardware pix_fmt is set.
  • Adds a hardware-format check and auto-fallback to NV12 for buffersrc; users can still fully override via setVideoFilterArgs().

…avaCV GPU pipeline bytedeco#2365

I added safe handling in FFmpegFrameFilter to avoid setting a hardware pixel format on the buffer source (which requires hw_frames_ctx) by auto-falling back to a software format and logging a warning. I also added a small test to verify hwupload_cuda,scale_cuda works when the filter input pix_fmt is software.
@marktech0813
Copy link
Author

Please review this PR and merge it.
thanks.

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

Successfully merging this pull request may close these issues.

1 participant