From 8f3369b037f76091062f1a09ab3549d4162863b3 Mon Sep 17 00:00:00 2001 From: Dominik 'Rathann' Mierzejewski Date: Fri, 19 Dec 2025 22:40:23 +0100 Subject: [PATCH] use modern FFmpeg API Fixes build with FFmpeg 8, where `FF_PROFILE_*` enums were replaced with `AV_PROFILE_*` and side_data API was replaced with codecpar. References: https://github.com/FFmpeg/FFmpeg/commit/8238bc0b5e3dba271217b1223a901b3f9713dc6e https://github.com/FFmpeg/FFmpeg/commit/5432d2aacad5fa7420fe2d9369ed061d521e92d6 Supersedes #1018 . Fixes #1028 . --- src/FFmpegReader.cpp | 5 +++++ src/FFmpegWriter.cpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 82c595f31..08307d281 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -567,8 +567,13 @@ void FFmpegReader::Open() { AVStream* st = pFormatCtx->streams[i]; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { // Only inspect the first video stream +#if (LIBAVFORMAT_VERSION_MAJOR < 62) for (int j = 0; j < st->nb_side_data; j++) { AVPacketSideData *sd = &st->side_data[j]; +#else + for (int j = 0; j < st->codecpar->nb_coded_side_data; j++) { + AVPacketSideData *sd = &st->codecpar->coded_side_data[j]; +#endif // Handle rotation metadata (unchanged) if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 26379041e..20a6b16bb 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -1501,7 +1501,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) { switch (video_codec_ctx->codec_id) { case AV_CODEC_ID_H264: video_codec_ctx->max_b_frames = 0; // At least this GPU doesn't support b-frames - video_codec_ctx->profile = FF_PROFILE_H264_BASELINE | FF_PROFILE_H264_CONSTRAINED; + video_codec_ctx->profile = AV_PROFILE_H264_BASELINE | AV_PROFILE_H264_CONSTRAINED; av_opt_set(video_codec_ctx->priv_data, "preset", "slow", 0); av_opt_set(video_codec_ctx->priv_data, "tune", "zerolatency", 0); av_opt_set(video_codec_ctx->priv_data, "vprofile", "baseline", AV_OPT_SEARCH_CHILDREN); @@ -2391,6 +2391,10 @@ void FFmpegWriter::AddSphericalMetadata(const std::string& projection, float yaw map->pitch = static_cast(pitch_deg * (1 << 16)); map->roll = static_cast(roll_deg * (1 << 16)); +#if (LIBAVFORMAT_VERSION_MAJOR < 62) av_stream_add_side_data(video_st, AV_PKT_DATA_SPHERICAL, reinterpret_cast(map), sd_size); +#else + av_packet_side_data_add(&video_st->codecpar->coded_side_data, &video_st->codecpar->nb_coded_side_data, AV_PKT_DATA_SPHERICAL, reinterpret_cast(map), sd_size, 0); +#endif #endif }