From d26a1da95b5d6f577eb79a9c88224000ed51ea37 Mon Sep 17 00:00:00 2001 From: bsflll Date: Tue, 5 May 2026 12:03:11 -0700 Subject: [PATCH] fix: support older ffmpeg (libavformat < 59) in cv-reader Add version check for LIBAVFORMAT_VERSION_MAJOR to handle the const AVCodec* change in av_find_best_stream() between ffmpeg 4.x and 5.x. Ubuntu 22.04 ships ffmpeg 4.4 (libavformat 58.x) which uses AVCodec**, while newer ffmpeg 5.0+ (libavformat 59+) uses const AVCodec**. --- .../Compressed_Video_Reader/src/cv_reader/h264_api.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/llava_next/Compressed_Video_Reader/src/cv_reader/h264_api.cpp b/llava_next/Compressed_Video_Reader/src/cv_reader/h264_api.cpp index 0f4682ae..b36c8eba 100644 --- a/llava_next/Compressed_Video_Reader/src/cv_reader/h264_api.cpp +++ b/llava_next/Compressed_Video_Reader/src/cv_reader/h264_api.cpp @@ -531,7 +531,11 @@ static PyObject *decode_h264(AVFormatContext *fmt_ctx, bool with_residual, int m int ret; AVStream *st; AVCodecContext *dec_ctx = nullptr; + #if LIBAVFORMAT_VERSION_MAJOR >= 59 const AVCodec *dec = nullptr; +#else + AVCodec *dec = nullptr; +#endif AVDictionary *opts = nullptr; AVPacket *pkt = nullptr; AVFrame *frame = nullptr; @@ -622,7 +626,11 @@ static PyObject *decode_h264_cb(AVFormatContext *fmt_ctx, int ret; AVStream *st; AVCodecContext *dec_ctx = nullptr; + #if LIBAVFORMAT_VERSION_MAJOR >= 59 const AVCodec *dec = nullptr; +#else + AVCodec *dec = nullptr; +#endif AVDictionary *opts = nullptr; AVPacket *pkt = nullptr; AVFrame *frame = nullptr;