bytedeco/javacv

h264_cuvid crashed when meets with dynamic resolution stream.

Open

#2384 aperta il 30 mar 2026

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)Java (1583 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (6985 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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.

Guida contributor