Skip to content

Commit 8f3369b

Browse files
committed
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: FFmpeg/FFmpeg@8238bc0 FFmpeg/FFmpeg@5432d2a Supersedes OpenShot#1018 . Fixes OpenShot#1028 .
1 parent 47b3081 commit 8f3369b

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/FFmpegReader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,13 @@ void FFmpegReader::Open() {
567567
AVStream* st = pFormatCtx->streams[i];
568568
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
569569
// Only inspect the first video stream
570+
#if (LIBAVFORMAT_VERSION_MAJOR < 62)
570571
for (int j = 0; j < st->nb_side_data; j++) {
571572
AVPacketSideData *sd = &st->side_data[j];
573+
#else
574+
for (int j = 0; j < st->codecpar->nb_coded_side_data; j++) {
575+
AVPacketSideData *sd = &st->codecpar->coded_side_data[j];
576+
#endif
572577

573578
// Handle rotation metadata (unchanged)
574579
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX &&

src/FFmpegWriter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
15011501
switch (video_codec_ctx->codec_id) {
15021502
case AV_CODEC_ID_H264:
15031503
video_codec_ctx->max_b_frames = 0; // At least this GPU doesn't support b-frames
1504-
video_codec_ctx->profile = FF_PROFILE_H264_BASELINE | FF_PROFILE_H264_CONSTRAINED;
1504+
video_codec_ctx->profile = AV_PROFILE_H264_BASELINE | AV_PROFILE_H264_CONSTRAINED;
15051505
av_opt_set(video_codec_ctx->priv_data, "preset", "slow", 0);
15061506
av_opt_set(video_codec_ctx->priv_data, "tune", "zerolatency", 0);
15071507
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
23912391
map->pitch = static_cast<int32_t>(pitch_deg * (1 << 16));
23922392
map->roll = static_cast<int32_t>(roll_deg * (1 << 16));
23932393

2394+
#if (LIBAVFORMAT_VERSION_MAJOR < 62)
23942395
av_stream_add_side_data(video_st, AV_PKT_DATA_SPHERICAL, reinterpret_cast<uint8_t*>(map), sd_size);
2396+
#else
2397+
av_packet_side_data_add(&video_st->codecpar->coded_side_data, &video_st->codecpar->nb_coded_side_data, AV_PKT_DATA_SPHERICAL, reinterpret_cast<uint8_t *>(map), sd_size, 0);
2398+
#endif
23952399
#endif
23962400
}

0 commit comments

Comments
 (0)