PR #25608 opened by thardin
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25608
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25608.patch

The issue is fundamentally that MXF is actually AAF by another name. The reason 
why we can't really handle situations like this is the same as why we can't 
handle higher operational patterns or sequences with more than one 
StructuralComponent in them. We can handle MXF when it behaves like a "normal" 
VfW-esque container.

In the future we might want to expose metadata like this. For now I think it's 
better if we complain loudly until we get samples. Then we can decide more 
firmly


>From 6af4a44d7bd03408abc1e2dbfd2846f38b562edb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <[email protected]>
Date: Sun, 18 Oct 2026 15:57:32 +0200
Subject: [PATCH] avformat/mxfdec: Bail out instead of silently overriding SP
 EditRate with MP EditRate

An example would be a file containing 50 Hz material played back at 25 Hz or 
vice versa, both of which are wrong.
Interlacing makes the situation even worse.
---
 libavformat/mxfdec.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 280a20aad33..51dd9000a3a 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2852,9 +2852,18 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
         }
         avpriv_set_pts_info(st, 64, material_track->edit_rate.den, 
material_track->edit_rate.num);
 
-        /* ensure SourceTrack EditRate == MaterialTrack EditRate since only
-         * the former is accessible via st->priv_data */
-        source_track->edit_rate = material_track->edit_rate;
+        // Files with different SP and MP EditRates are not something we can 
easily support
+        // Such files are better handled using NLE tools like kdenlive
+        // MXF has its basis in AAF after all
+        if (source_track->edit_rate.num != material_track->edit_rate.num ||
+            source_track->edit_rate.den != material_track->edit_rate.den) {
+            // We need samples before we can make a proper decision about this
+            av_log(mxf->fc, AV_LOG_ERROR, "EditRate mismatch: %i/%i vs 
%i/%i\n",
+                    source_track->edit_rate.num,   source_track->edit_rate.den,
+                    material_track->edit_rate.num, 
material_track->edit_rate.den);
+            avpriv_request_sample(mxf->fc, "Mismatched SourcePackage and 
MaterialPackage EditRate");
+            return AVERROR_PATCHWELCOME;
+        }
 
         PRINT_KEY(mxf->fc, "data definition   ul", 
source_track->sequence->data_definition_ul);
         codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, 
&source_track->sequence->data_definition_ul);
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to