From 99264d9b5af156a699b98326e93fbc1a600d1171 Mon Sep 17 00:00:00 2001 From: Adrian Shum Date: Mon, 21 Jul 2025 21:15:30 +0800 Subject: [PATCH] fix(ffmpeg): use non-deprecated FFmpeg 7.1 side data API (#103) --- ffmpeg/ffmpeg.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ffmpeg/ffmpeg.c b/ffmpeg/ffmpeg.c index ea31d30..2225eef 100644 --- a/ffmpeg/ffmpeg.c +++ b/ffmpeg/ffmpeg.c @@ -70,10 +70,16 @@ int create_format_context(AVFormatContext *fmt_ctx, void* opaque, int flags) { } static int get_orientation(AVStream *video_stream) { - uint8_t *display_matrix = av_stream_get_side_data(video_stream, AV_PKT_DATA_DISPLAYMATRIX, NULL); + const AVPacketSideData *side_data = NULL; double theta = 0; - if (display_matrix) { - theta = -av_display_rotation_get((int32_t *) display_matrix); + + // Use the new API to get side data from codecpar + side_data = av_packet_side_data_get(video_stream->codecpar->coded_side_data, + video_stream->codecpar->nb_coded_side_data, + AV_PKT_DATA_DISPLAYMATRIX); + + if (side_data && side_data->size >= 9 * sizeof(int32_t)) { + theta = -av_display_rotation_get((int32_t *) side_data->data); } theta -= 360 * floor(theta / 360 + 0.9 / 360);