diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index e59bcfcc80e187c935a5e8e1d6226b07cef2341d..29a2f563e6c642b57c931b3e6f0a974a27d9382f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1601,8 +1601,10 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
         }
         if (descriptor->extradata) {
             st->codec->extradata = av_mallocz(descriptor->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
-            if (st->codec->extradata)
+            if (st->codec->extradata) {
                 memcpy(st->codec->extradata, descriptor->extradata, descriptor->extradata_size);
+                st->codec->extradata_size = descriptor->extradata_size;
+            }
         } else if(st->codec->codec_id == AV_CODEC_ID_H264) {
             ff_generate_avci_extradata(st);
         }