Commit 44252daaeb for ffmpeg

commit 44252daaeb4b638b807f914dda34bec63fbd24ef
Author: WindrunnerSky <>
Date:   Fri Oct 2 11:47:02 2026 +0000

    avcodec/hw_base_encode: guard timestamp fixup for empty input

    Draining an encoder before any frame has been submitted leaves pic_end NULL. Skip the timestamp fixup in that case; the receive path will then return EOF without producing a packet.

    The same guard was submitted earlier by Zach Denton:
    https://patchwork.ffmpeg.org/project/ffmpeg/patch/20260518230947.605278-1-z@chdenton.com/

    Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24248

    Assisted-by: Fairy

diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c
index 307e76ed79..5ba194fab5 100644
--- a/libavcodec/hw_base_encode.c
+++ b/libavcodec/hw_base_encode.c
@@ -508,7 +508,7 @@ static int hw_base_encode_send_frame(AVCodecContext *avctx, FFHWBaseEncodeContex

         // Fix timestamps if we hit end-of-stream before the initial decode
         // delay has elapsed.
-        if (ctx->input_order <= ctx->decode_delay)
+        if (ctx->input_order <= ctx->decode_delay && ctx->pic_end)
             ctx->dts_pts_diff = ctx->pic_end->pts - ctx->first_pts;
     }