bytedeco/javacv

h264_cuvid crashed when meets with dynamic resolution stream.

Open

#2.384 aberto em 30 de mar. de 2026

Ver no GitHub
 (4 comments) (0 reactions) (0 assignees)Java (1.583 forks)batch import
enhancementhelp wanted

Métricas do repositório

Stars
 (6.985 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Recently, while using JavaCV to ingest a video stream, I encountered a crash when the connected live stream's resolution dynamically increased. Interestingly, the stream remains stable if the resolution decreases.

The error message is: [h264_cuvid @ ...] AVHWFramesContext is already initialized with incompatible parameters

After inspecting the source code, I found the following check

    if (hwframe_ctx->pool && (
            hwframe_ctx->width < avctx->width ||
            hwframe_ctx->height < avctx->height ||
            hwframe_ctx->format != AV_PIX_FMT_CUDA ||
            hwframe_ctx->sw_format != avctx->sw_pix_fmt)) {
        av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized with incompatible parameters\n");
        // ... debug logs ...
        ctx->internal_error = AVERROR(EINVAL);
        return 0;

It appears this is related to the hardware context initialization.

My Question: Is it possible to manually preset a hardware context (AVHWFramesContext) with a sufficiently large resolution (e.g., a maximum expected size) to accommodate dynamic resolution upscaling without triggering this incompatibility error?

Any advice or workarounds would be greatly appreciated.

Guia do colaborador