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.
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 parametersAfter inspecting the source code, I found the following check
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.