--- libavformat/matroskaenc.c.orig	2024-04-05 01:23:00.000000000 +0200
+++ libavformat/matroskaenc.c	2024-05-31 20:57:25.812315941 +0200
@@ -1003,6 +1003,8 @@
                               const AVCodecParameters *par,
                               const uint8_t *extradata, int extradata_size)
 {
+#if 0 // MEANX avidemux does thing differently
+
     const uint8_t *header_start[3];
     int header_len[3];
     int first_header_size;
@@ -1028,6 +1030,29 @@
         avio_write(pb, header_start[j], header_len[j]);
 
     return 0;
+#else
+   // Not endian safe....
+      uint32_t packetLen[3],*ptr=(uint32_t *)par->extradata;
+      uint8_t *data[3],i,j;
+      if( 3*4+ptr[0]+ptr[1]+ptr[2]!=par->extradata_size)
+      {
+        av_log(s, AV_LOG_ERROR, "Broken avidemux xiph header.\n");
+        return -1;
+      }
+      data[0]=par->extradata+3*4;
+      data[1]=data[0]+ptr[0];
+      data[2]=data[1]+ptr[1];
+      avio_w8(pb, 2);                    // number packets - 1
+      for (j = 0; j < 2; j++) 
+      {
+          put_xiph_size(pb, ptr[j]);
+      }
+      for (j = 0; j < 3; j++)
+        avio_write(pb, data[j], ptr[j]);
+      
+      return 0; // /MEANX
+#endif
+
 }
 
 #if CONFIG_MATROSKA_MUXER
