diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 7cbae47e42..e813ef86cf 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -264,8 +264,12 @@ typedef struct MatroskaMuxContext {
 /** 4 * (1-byte EBML ID, 1-byte EBML size, 8-byte uint max) */
 #define MAX_CUETRACKPOS_SIZE 40
 
-/** 2 + 1 Simpletag header, 2 + 1 + 8 Name "DURATION", 23B for TagString */
-#define DURATION_SIMPLETAG_SIZE (2 + 1 + (2 + 1 + 8) + 23)
+/** DURATION_STRING_LENGTH must be <= 112 or the containing
+ * simpletag will need more than one byte for its length field. */
+#define DURATION_STRING_LENGTH 19
+
+/** 2 + 1 Simpletag header, 2 + 1 + 8 Name "DURATION", rest for TagString */
+#define DURATION_SIMPLETAG_SIZE (2 + 1 + (2 + 1 + 8) + (2 + 1 + DURATION_STRING_LENGTH))
 
 /** Seek preroll value for opus */
 #define OPUS_SEEK_PREROLL 80000000
@@ -3239,7 +3243,7 @@ after_cues:
 
             if (track->duration_offset > 0) {
                 double duration_sec = track->duration * av_q2d(st->time_base);
-                char duration_string[20] = "";
+                char duration_string[DURATION_STRING_LENGTH + 1] = "";
                 ebml_master simpletag;
 
                 av_log(s, AV_LOG_DEBUG, "stream %d end duration = %" PRIu64 "\n", i,
@@ -3250,11 +3254,12 @@ after_cues:
                                               2 + 1 + 8 + 23);
                 put_ebml_string(tags_bc, MATROSKA_ID_TAGNAME, "DURATION");
 
-                snprintf(duration_string, 20, "%02d:%02d:%012.9f",
+                snprintf(duration_string, sizeof(duration_string), "%02d:%02d:%012.9f",
                          (int) duration_sec / 3600, ((int) duration_sec / 60) % 60,
                          fmod(duration_sec, 60));
 
-                put_ebml_binary(tags_bc, MATROSKA_ID_TAGSTRING, duration_string, 20);
+                put_ebml_binary(tags_bc, MATROSKA_ID_TAGSTRING,
+                                duration_string, DURATION_STRING_LENGTH);
                 end_ebml_master(tags_bc, simpletag);
             }
         }
diff --git a/tests/ref/fate/aac-autobsf-adtstoasc b/tests/ref/fate/aac-autobsf-adtstoasc
index 76125083b6..616f875ab3 100644
--- a/tests/ref/fate/aac-autobsf-adtstoasc
+++ b/tests/ref/fate/aac-autobsf-adtstoasc
@@ -1,5 +1,5 @@
-3d4465a7ea2cfba31af737e288c892fe *tests/data/fate/aac-autobsf-adtstoasc.matroska
-6646 tests/data/fate/aac-autobsf-adtstoasc.matroska
+b8594ae7884fcad4acfc5b997d012857 *tests/data/fate/aac-autobsf-adtstoasc.matroska
+6645 tests/data/fate/aac-autobsf-adtstoasc.matroska
 #extradata 0:        2, 0x0030001c
 #tb 0: 1/1000
 #media_type 0: audio
diff --git a/tests/ref/fate/matroska-alac-remux b/tests/ref/fate/matroska-alac-remux
index 3eb3cdcb37..70fb11a14f 100644
--- a/tests/ref/fate/matroska-alac-remux
+++ b/tests/ref/fate/matroska-alac-remux
@@ -1,5 +1,5 @@
-c683b17ab66c9f0fba57da7af86740c9 *tests/data/fate/matroska-alac-remux.matroska
-1293810 tests/data/fate/matroska-alac-remux.matroska
+71f41fb8d2fe30281c254c378921bf2a *tests/data/fate/matroska-alac-remux.matroska
+1293809 tests/data/fate/matroska-alac-remux.matroska
 #extradata 0:       36, 0x562b05d8
 #tb 0: 1/1000
 #media_type 0: audio
diff --git a/tests/ref/fate/matroska-avoid-negative-ts b/tests/ref/fate/matroska-avoid-negative-ts
index f52f3dec72..05821cbf09 100644
--- a/tests/ref/fate/matroska-avoid-negative-ts
+++ b/tests/ref/fate/matroska-avoid-negative-ts
@@ -1,5 +1,5 @@
-69461a333cae20646d4e514b7b510bef *tests/data/fate/matroska-avoid-negative-ts.matroska
-973074 tests/data/fate/matroska-avoid-negative-ts.matroska
+dede1d72a28c7eb0a849acf230b08247 *tests/data/fate/matroska-avoid-negative-ts.matroska
+973072 tests/data/fate/matroska-avoid-negative-ts.matroska
 #extradata 0:       22, 0x2885037c
 #tb 0: 1/1000
 #media_type 0: video
diff --git a/tests/ref/fate/matroska-dovi-write-config7 b/tests/ref/fate/matroska-dovi-write-config7
index ef4c87d885..aaeeb34751 100644
--- a/tests/ref/fate/matroska-dovi-write-config7
+++ b/tests/ref/fate/matroska-dovi-write-config7
@@ -1,5 +1,5 @@
-82581e39700ff479516c33402e8b1d5d *tests/data/fate/matroska-dovi-write-config7.matroska
-72702 tests/data/fate/matroska-dovi-write-config7.matroska
+7adef53df9e14358e0b99f8a829e2d97 *tests/data/fate/matroska-dovi-write-config7.matroska
+72700 tests/data/fate/matroska-dovi-write-config7.matroska
 #extradata 0:      116, 0x2b8d1669
 #extradata 1:      116, 0x2b8d1669
 #tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-dovi-write-config8 b/tests/ref/fate/matroska-dovi-write-config8
index de90101a55..55fe191047 100644
--- a/tests/ref/fate/matroska-dovi-write-config8
+++ b/tests/ref/fate/matroska-dovi-write-config8
@@ -1,5 +1,5 @@
-56eea905c35996a729371372dd3113f9 *tests/data/fate/matroska-dovi-write-config8.matroska
-3600609 tests/data/fate/matroska-dovi-write-config8.matroska
+0730145aa317d800cb4bde0e3a38bb8d *tests/data/fate/matroska-dovi-write-config8.matroska
+3600607 tests/data/fate/matroska-dovi-write-config8.matroska
 #extradata 0:      551, 0xa18acf66
 #extradata 1:        2, 0x00340022
 #tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-dvbsub-remux b/tests/ref/fate/matroska-dvbsub-remux
index 03341d9668..f55b9642c4 100644
--- a/tests/ref/fate/matroska-dvbsub-remux
+++ b/tests/ref/fate/matroska-dvbsub-remux
@@ -1,5 +1,5 @@
-5d1591e9abd7e1373d43bc776572aaf7 *tests/data/fate/matroska-dvbsub-remux.matroska
-39018 tests/data/fate/matroska-dvbsub-remux.matroska
+d6385d4623cd59061c13e26b004eaa8e *tests/data/fate/matroska-dvbsub-remux.matroska
+39016 tests/data/fate/matroska-dvbsub-remux.matroska
 #extradata 0:        5, 0x00bb0064
 #extradata 1:        5, 0x00bb0064
 #tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-encoding-delay b/tests/ref/fate/matroska-encoding-delay
index 3059c32e03..d2ff2d07be 100644
--- a/tests/ref/fate/matroska-encoding-delay
+++ b/tests/ref/fate/matroska-encoding-delay
@@ -1,5 +1,5 @@
-c51ac49b96b213e6646196fc81f8eb84 *tests/data/fate/matroska-encoding-delay.matroska
-961240 tests/data/fate/matroska-encoding-delay.matroska
+156c5c615bee0c55e76275df8d84e505 *tests/data/fate/matroska-encoding-delay.matroska
+961238 tests/data/fate/matroska-encoding-delay.matroska
 #extradata 0:       22, 0x32ea0490
 #tb 0: 1/1000
 #media_type 0: video
@@ -32,7 +32,7 @@ dts_time=-0.010000
 duration=24
 duration_time=0.024000
 size=1152
-pos=1257
+pos=1255
 flags=K__
 [/PACKET]
 [PACKET]
@@ -45,7 +45,7 @@ dts_time=0.000000
 duration=40
 duration_time=0.040000
 size=237628
-pos=2417
+pos=2415
 flags=K__
 [/PACKET]
 [PACKET]
@@ -58,7 +58,7 @@ dts_time=0.014000
 duration=24
 duration_time=0.024000
 size=1152
-pos=240052
+pos=240050
 flags=K__
 [/PACKET]
 [PACKET]
@@ -71,7 +71,7 @@ dts_time=0.038000
 duration=24
 duration_time=0.024000
 size=1152
-pos=241227
+pos=241225
 flags=K__
 [/PACKET]
 [PACKET]
@@ -84,7 +84,7 @@ dts_time=0.040000
 duration=40
 duration_time=0.040000
 size=238066
-pos=242387
+pos=242385
 flags=K__
 [/PACKET]
 [STREAM]
diff --git a/tests/ref/fate/matroska-flac-extradata-update b/tests/ref/fate/matroska-flac-extradata-update
index d6713aaafa..a4f8bf2dac 100644
--- a/tests/ref/fate/matroska-flac-extradata-update
+++ b/tests/ref/fate/matroska-flac-extradata-update
@@ -1,5 +1,5 @@
-fdbfdc51b519fd5e8f425aca1e7b8704 *tests/data/fate/matroska-flac-extradata-update.matroska
-1807 tests/data/fate/matroska-flac-extradata-update.matroska
+f0b0a6a8a0fc975aef9048023faf7c92 *tests/data/fate/matroska-flac-extradata-update.matroska
+1804 tests/data/fate/matroska-flac-extradata-update.matroska
 #extradata 0:       34, 0x93650c81
 #extradata 1:       34, 0x93650c81
 #extradata 2:       34, 0x93650c81
diff --git a/tests/ref/fate/matroska-h264-remux b/tests/ref/fate/matroska-h264-remux
index aefd6f65ef..2c727f03cd 100644
--- a/tests/ref/fate/matroska-h264-remux
+++ b/tests/ref/fate/matroska-h264-remux
@@ -1,5 +1,5 @@
-bc0ce442f20d1d62663b40391a3be812 *tests/data/fate/matroska-h264-remux.matroska
-2036071 tests/data/fate/matroska-h264-remux.matroska
+f6b943ed3ff05087d0ef58fbaf7abcb0 *tests/data/fate/matroska-h264-remux.matroska
+2036067 tests/data/fate/matroska-h264-remux.matroska
 #tb 0: 1/25
 #media_type 0: video
 #codec_id 0: rawvideo
diff --git a/tests/ref/fate/matroska-hdr10-plus-remux b/tests/ref/fate/matroska-hdr10-plus-remux
index bb0580db33..923fd2a7ab 100644
--- a/tests/ref/fate/matroska-hdr10-plus-remux
+++ b/tests/ref/fate/matroska-hdr10-plus-remux
@@ -1,5 +1,5 @@
-0f941512f69b1cc0ac27f3375e56a0cc *tests/data/fate/matroska-hdr10-plus-remux.matroska
-13892 tests/data/fate/matroska-hdr10-plus-remux.matroska
+299d8f8b5174f9a8747304056d742501 *tests/data/fate/matroska-hdr10-plus-remux.matroska
+13891 tests/data/fate/matroska-hdr10-plus-remux.matroska
 #tb 0: 1/1000
 #media_type 0: video
 #codec_id 0: vp9
@@ -16,7 +16,7 @@ dts_time=0.000000
 duration=40
 duration_time=0.040000
 size=13350
-pos=436
+pos=435
 flags=K__
 [SIDE_DATA]
 side_data_type=HDR10+ Dynamic Metadata (SMPTE 2094-40)
diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata
index ad36f01e61..3726469213 100644
--- a/tests/ref/fate/matroska-mastering-display-metadata
+++ b/tests/ref/fate/matroska-mastering-display-metadata
@@ -1,5 +1,5 @@
-b3204c8fa6a78037243cc4948a2775ee *tests/data/fate/matroska-mastering-display-metadata.matroska
-1669593 tests/data/fate/matroska-mastering-display-metadata.matroska
+9d0fb8123a2e90e85153428a91d1ee9d *tests/data/fate/matroska-mastering-display-metadata.matroska
+1669589 tests/data/fate/matroska-mastering-display-metadata.matroska
 #extradata 0:        4, 0x040901a3
 #extradata 3:      200, 0x506463a8
 #tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-move-cues-to-front b/tests/ref/fate/matroska-move-cues-to-front
index 79ccc2fd93..1deacaa370 100644
--- a/tests/ref/fate/matroska-move-cues-to-front
+++ b/tests/ref/fate/matroska-move-cues-to-front
@@ -1,5 +1,5 @@
-74a5ed3f0b14112322c8bf3e94d6e98b *tests/data/fate/matroska-move-cues-to-front.matroska
-23210297 tests/data/fate/matroska-move-cues-to-front.matroska
+4ca0bdb5636523c3e43b9dbf692ae21c *tests/data/fate/matroska-move-cues-to-front.matroska
+23210293 tests/data/fate/matroska-move-cues-to-front.matroska
 #tb 0: 1/1000
 #media_type 0: audio
 #codec_id 0: pcm_s24be
diff --git a/tests/ref/fate/matroska-mpegts-remux b/tests/ref/fate/matroska-mpegts-remux
index af41b57af1..c6b7d324b0 100644
--- a/tests/ref/fate/matroska-mpegts-remux
+++ b/tests/ref/fate/matroska-mpegts-remux
@@ -1,5 +1,5 @@
-ca1b91e49b6e238b641007c186d8f424 *tests/data/fate/matroska-mpegts-remux.matroska
-6502 tests/data/fate/matroska-mpegts-remux.matroska
+52e030428110a8c1b74c03c7ad31a6ca *tests/data/fate/matroska-mpegts-remux.matroska
+6500 tests/data/fate/matroska-mpegts-remux.matroska
 #tb 0: 1/1000
 #media_type 0: audio
 #codec_id 0: ac3
diff --git a/tests/ref/fate/matroska-ms-mode b/tests/ref/fate/matroska-ms-mode
index 7ce0f1e4ff..5c91209910 100644
--- a/tests/ref/fate/matroska-ms-mode
+++ b/tests/ref/fate/matroska-ms-mode
@@ -1,5 +1,5 @@
-703d268b966d5dfabe5e22c2de69dc66 *tests/data/fate/matroska-ms-mode.matroska
-413105 tests/data/fate/matroska-ms-mode.matroska
+a2897e3951b0054d0fa31fe51860444f *tests/data/fate/matroska-ms-mode.matroska
+413103 tests/data/fate/matroska-ms-mode.matroska
 #extradata 0:       40, 0x54290c93
 #extradata 1:      114, 0xb6c80771
 #tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux
index cd3eade361..bf6613e257 100644
--- a/tests/ref/fate/matroska-ogg-opus-remux
+++ b/tests/ref/fate/matroska-ogg-opus-remux
@@ -1,5 +1,5 @@
-b602a1a4aaa4fbca4b8aaf39b66d7235 *tests/data/fate/matroska-ogg-opus-remux.matroska
-10204 tests/data/fate/matroska-ogg-opus-remux.matroska
+87d0185c5b780dd9509aafd957236bdd *tests/data/fate/matroska-ogg-opus-remux.matroska
+10203 tests/data/fate/matroska-ogg-opus-remux.matroska
 #extradata 0:       19, 0x399c0471
 #tb 0: 1/1000
 #media_type 0: audio
@@ -57,7 +57,7 @@ dts_time=-0.007000
 duration=20
 duration_time=0.020000
 size=402
-pos=544
+pos=543
 flags=K__
 [/PACKET]
 [PACKET]
@@ -70,7 +70,7 @@ dts_time=0.013000
 duration=20
 duration_time=0.020000
 size=216
-pos=953
+pos=952
 flags=K__
 [/PACKET]
 [PACKET]
@@ -83,7 +83,7 @@ dts_time=0.033000
 duration=20
 duration_time=0.020000
 size=215
-pos=1176
+pos=1175
 flags=K__
 [/PACKET]
 [STREAM]
diff --git a/tests/ref/fate/matroska-opus-remux b/tests/ref/fate/matroska-opus-remux
index 975510e167..9f2526dc57 100644
--- a/tests/ref/fate/matroska-opus-remux
+++ b/tests/ref/fate/matroska-opus-remux
@@ -1,5 +1,5 @@
-fe0258eb0d4b525203ea240c87a154d3 *tests/data/fate/matroska-opus-remux.matroska
-9359 tests/data/fate/matroska-opus-remux.matroska
+b9881205f8945fefc16a6f23474071a6 *tests/data/fate/matroska-opus-remux.matroska
+9358 tests/data/fate/matroska-opus-remux.matroska
 #extradata 0:       19, 0x3a04048f
 #tb 0: 1/1000
 #media_type 0: audio
@@ -68,7 +68,7 @@ dts_time=-0.007000
 duration=20
 duration_time=0.020000
 size=320
-pos=500
+pos=499
 flags=K__
 [/PACKET]
 [PACKET]
@@ -81,7 +81,7 @@ dts_time=0.014000
 duration=20
 duration_time=0.020000
 size=159
-pos=827
+pos=826
 flags=K__
 [/PACKET]
 [PACKET]
@@ -94,7 +94,7 @@ dts_time=0.034000
 duration=20
 duration_time=0.020000
 size=148
-pos=993
+pos=992
 flags=K__
 [/PACKET]
 [STREAM]
diff --git a/tests/ref/fate/matroska-pgs-remux b/tests/ref/fate/matroska-pgs-remux
index a086111495..318cc65ec3 100644
--- a/tests/ref/fate/matroska-pgs-remux
+++ b/tests/ref/fate/matroska-pgs-remux
@@ -1,5 +1,5 @@
-d39daa393d66ae0b0c153be045897585 *tests/data/fate/matroska-pgs-remux.matroska
-49748 tests/data/fate/matroska-pgs-remux.matroska
+b03d39ae755cb07fde023f6e9e6186ce *tests/data/fate/matroska-pgs-remux.matroska
+49747 tests/data/fate/matroska-pgs-remux.matroska
 #tb 0: 1/1000
 #media_type 0: subtitle
 #codec_id 0: hdmv_pgs_subtitle
diff --git a/tests/ref/fate/matroska-pgs-remux-durations b/tests/ref/fate/matroska-pgs-remux-durations
index 37494cd98f..4a07f5edf2 100644
--- a/tests/ref/fate/matroska-pgs-remux-durations
+++ b/tests/ref/fate/matroska-pgs-remux-durations
@@ -1,5 +1,5 @@
-27af80eecea4f15f415f22841bc699d5 *tests/data/fate/matroska-pgs-remux-durations.matroska
-49760 tests/data/fate/matroska-pgs-remux-durations.matroska
+1d8fedf8f90f755f9dd6914489ee8ab2 *tests/data/fate/matroska-pgs-remux-durations.matroska
+49759 tests/data/fate/matroska-pgs-remux-durations.matroska
 #tb 0: 1/1000
 #media_type 0: subtitle
 #codec_id 0: hdmv_pgs_subtitle
diff --git a/tests/ref/fate/matroska-qt-mode b/tests/ref/fate/matroska-qt-mode
index 62a2d82f16..90bbd52bde 100644
--- a/tests/ref/fate/matroska-qt-mode
+++ b/tests/ref/fate/matroska-qt-mode
@@ -1,5 +1,5 @@
-f2eac23e9f7f3a7dac9e2d94885ff4f1 *tests/data/fate/matroska-qt-mode.matroska
-1884243 tests/data/fate/matroska-qt-mode.matroska
+bab6f4122a60a0d4e192fb93c17a5464 *tests/data/fate/matroska-qt-mode.matroska
+1884240 tests/data/fate/matroska-qt-mode.matroska
 #extradata 0:       90, 0x817d0185
 #tb 0: 1/1000
 #media_type 0: video
diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux
index 0940e3ea86..e9904b2c92 100644
--- a/tests/ref/fate/matroska-spherical-mono-remux
+++ b/tests/ref/fate/matroska-spherical-mono-remux
@@ -1,5 +1,5 @@
-281555d95fca08f3ba103eefa1c22b54 *tests/data/fate/matroska-spherical-mono-remux.matroska
-161584 tests/data/fate/matroska-spherical-mono-remux.matroska
+fddfea5f05a7a9a0d187df9a72900055 *tests/data/fate/matroska-spherical-mono-remux.matroska
+161582 tests/data/fate/matroska-spherical-mono-remux.matroska
 #extradata 0:       43, 0x2b0e0d7b
 #extradata 1:       43, 0x2b0e0d7b
 #tb 0: 1/1000
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux
index 86024b3477..eba3ffb77a 100644
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ b/tests/ref/fate/matroska-vp8-alpha-remux
@@ -1,5 +1,5 @@
-635702724143e90d2a3ec457f65676cf *tests/data/fate/matroska-vp8-alpha-remux.matroska
-235026 tests/data/fate/matroska-vp8-alpha-remux.matroska
+129f76bb3cee967ebd067efa30c4e4f7 *tests/data/fate/matroska-vp8-alpha-remux.matroska
+235025 tests/data/fate/matroska-vp8-alpha-remux.matroska
 #tb 0: 1/1000
 #media_type 0: video
 #codec_id 0: vp8
diff --git a/tests/ref/fate/matroska-zero-length-block b/tests/ref/fate/matroska-zero-length-block
index 3987cc14c4..2affd97067 100644
--- a/tests/ref/fate/matroska-zero-length-block
+++ b/tests/ref/fate/matroska-zero-length-block
@@ -1,5 +1,5 @@
-f577fad2fff41d6e055f605281582b8d *tests/data/fate/matroska-zero-length-block.matroska
-634 tests/data/fate/matroska-zero-length-block.matroska
+451a43f61da7baee559005881d94203e *tests/data/fate/matroska-zero-length-block.matroska
+633 tests/data/fate/matroska-zero-length-block.matroska
 #tb 0: 1/1000
 #media_type 0: subtitle
 #codec_id 0: subrip
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index 484198aaa4..99234f1052 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@
-4801308890e7a9db51fc13b05f817165 *tests/data/fate/rgb24-mkv.matroska
-58226 tests/data/fate/rgb24-mkv.matroska
+e181dc84058c3584598333dabd110123 *tests/data/fate/rgb24-mkv.matroska
+58225 tests/data/fate/rgb24-mkv.matroska
 #tb 0: 1/10
 #media_type 0: video
 #codec_id 0: rawvideo
diff --git a/tests/ref/fate/shortest-sub b/tests/ref/fate/shortest-sub
index 49e13d65d7..9caee587ce 100644
--- a/tests/ref/fate/shortest-sub
+++ b/tests/ref/fate/shortest-sub
@@ -1,5 +1,5 @@
-2b6e72494d74aaf07380bfe3d50b62d5 *tests/data/fate/shortest-sub.matroska
-139251 tests/data/fate/shortest-sub.matroska
+73d142a80965f9e0884a5863abde0dab *tests/data/fate/shortest-sub.matroska
+139249 tests/data/fate/shortest-sub.matroska
 #extradata 1:      167, 0xf7272d5f
 #tb 0: 1/1000
 #media_type 0: video
diff --git a/tests/ref/fate/webm-av1-extradata-update b/tests/ref/fate/webm-av1-extradata-update
index 68bbb9ad89..3a84511bae 100644
--- a/tests/ref/fate/webm-av1-extradata-update
+++ b/tests/ref/fate/webm-av1-extradata-update
@@ -1,5 +1,5 @@
-fbf3091fdf05b2856c578e7c948d68c3 *tests/data/fate/webm-av1-extradata-update.webm
-23048 tests/data/fate/webm-av1-extradata-update.webm
+dc7593b977b092e522018de7e0d12681 *tests/data/fate/webm-av1-extradata-update.webm
+23047 tests/data/fate/webm-av1-extradata-update.webm
 #extradata 0:       35, 0x527207cd
 #tb 0: 1/1000
 #media_type 0: video
diff --git a/tests/ref/fate/webm-dash-chapters b/tests/ref/fate/webm-dash-chapters
index 9444824c4c..f32e83852f 100644
--- a/tests/ref/fate/webm-dash-chapters
+++ b/tests/ref/fate/webm-dash-chapters
@@ -1,5 +1,5 @@
-aa3ca15fae0239d6bf67fa0658a8bc3b *tests/data/fate/webm-dash-chapters.webm
-111150 tests/data/fate/webm-dash-chapters.webm
+e2d3d812e6d9cf05a36eaefe02801a99 *tests/data/fate/webm-dash-chapters.webm
+111149 tests/data/fate/webm-dash-chapters.webm
 #extradata 0:     3469, 0xc6769ddc
 #tb 0: 1/1000
 #media_type 0: audio
diff --git a/tests/ref/fate/webm-hdr10-plus-remux b/tests/ref/fate/webm-hdr10-plus-remux
index d8dbb93598..04ab55e56f 100644
--- a/tests/ref/fate/webm-hdr10-plus-remux
+++ b/tests/ref/fate/webm-hdr10-plus-remux
@@ -1,5 +1,5 @@
-30923c8d916f5719f62727f24957974f *tests/data/fate/webm-hdr10-plus-remux.webm
-13843 tests/data/fate/webm-hdr10-plus-remux.webm
+7c5ae91189589c07f92aa97cb9b3d9e1 *tests/data/fate/webm-hdr10-plus-remux.webm
+13842 tests/data/fate/webm-hdr10-plus-remux.webm
 #tb 0: 1/1000
 #media_type 0: video
 #codec_id 0: vp9
@@ -16,7 +16,7 @@ dts_time=0.000000
 duration=40
 duration_time=0.040000
 size=13350
-pos=393
+pos=392
 flags=K__
 [SIDE_DATA]
 side_data_type=HDR10+ Dynamic Metadata (SMPTE 2094-40)
diff --git a/tests/ref/fate/webm-webvtt-remux b/tests/ref/fate/webm-webvtt-remux
index 88def03dbe..b247eec894 100644
--- a/tests/ref/fate/webm-webvtt-remux
+++ b/tests/ref/fate/webm-webvtt-remux
@@ -1,5 +1,5 @@
-0b43695bf27bbe48ea44e969d8908e1f *tests/data/fate/webm-webvtt-remux.webm
-6528 tests/data/fate/webm-webvtt-remux.webm
+c372c76c062d368f1d17373c19f83579 *tests/data/fate/webm-webvtt-remux.webm
+6524 tests/data/fate/webm-webvtt-remux.webm
 #tb 0: 1/1000
 #media_type 0: subtitle
 #codec_id 0: webvtt
diff --git a/tests/ref/lavf-fate/av1.mkv b/tests/ref/lavf-fate/av1.mkv
index 685fd70811..84924fe05c 100644
--- a/tests/ref/lavf-fate/av1.mkv
+++ b/tests/ref/lavf-fate/av1.mkv
@@ -1,3 +1,3 @@
-279268e8d6ffcc2299e725a756bbb1a0 *tests/data/lavf-fate/lavf.av1.mkv
-55657 tests/data/lavf-fate/lavf.av1.mkv
+ba198efa114b4db3c9f772728f84978b *tests/data/lavf-fate/lavf.av1.mkv
+55656 tests/data/lavf-fate/lavf.av1.mkv
 tests/data/lavf-fate/lavf.av1.mkv CRC=0x7c27cc15
diff --git a/tests/ref/lavf/mka b/tests/ref/lavf/mka
index 93a0b8f71a..135fade76c 100644
--- a/tests/ref/lavf/mka
+++ b/tests/ref/lavf/mka
@@ -1,3 +1,3 @@
-77db16a9fe1c42a230c85124bfb40cad *tests/data/lavf/lavf.mka
-43573 tests/data/lavf/lavf.mka
+4fede420f36a21bbb3ae4e5d6a884267 *tests/data/lavf/lavf.mka
+43572 tests/data/lavf/lavf.mka
 tests/data/lavf/lavf.mka CRC=0x3a1da17e
diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv
index 8ddc9cf57f..1b25aea6aa 100644
--- a/tests/ref/lavf/mkv
+++ b/tests/ref/lavf/mkv
@@ -1,3 +1,3 @@
-05889ab61cc6144018c80e50c781fe44 *tests/data/lavf/lavf.mkv
-320428 tests/data/lavf/lavf.mkv
+d5f719b715ad5eb6860c85f0d8202b8e *tests/data/lavf/lavf.mkv
+320426 tests/data/lavf/lavf.mkv
 tests/data/lavf/lavf.mkv CRC=0xec6c3c68
diff --git a/tests/ref/lavf/mkv_attachment b/tests/ref/lavf/mkv_attachment
index 6a08a580d2..3a599c6ed5 100644
--- a/tests/ref/lavf/mkv_attachment
+++ b/tests/ref/lavf/mkv_attachment
@@ -1,3 +1,3 @@
-901b4ba820fe1d6c627ce2a4b31b65af *tests/data/lavf/lavf.mkv_attachment
-472578 tests/data/lavf/lavf.mkv_attachment
+7681b6ece94f20684838bcbba2458c58 *tests/data/lavf/lavf.mkv_attachment
+472576 tests/data/lavf/lavf.mkv_attachment
 tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68
diff --git a/tests/ref/seek/lavf-mkv b/tests/ref/seek/lavf-mkv
index 6abdbd6ee7..78c2b13b46 100644
--- a/tests/ref/seek/lavf-mkv
+++ b/tests/ref/seek/lavf-mkv
@@ -1,48 +1,48 @@
-ret: 0         st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos:    676 size:   208
+ret: 0         st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos:    674 size:   208
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292308 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
 ret: 0         st: 0 flags:0  ts: 0.788000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292308 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
 ret: 0         st: 0 flags:1  ts:-0.317000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
 ret:-1         st: 1 flags:0  ts: 2.577000
 ret: 0         st: 1 flags:1  ts: 1.471000
-ret: 0         st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320149 size:   209
+ret: 0         st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320147 size:   209
 ret: 0         st:-1 flags:0  ts: 0.365002
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146860 size: 27925
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146858 size: 27925
 ret: 0         st:-1 flags:1  ts:-0.740831
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
 ret:-1         st: 0 flags:0  ts: 2.153000
 ret: 0         st: 0 flags:1  ts: 1.048000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292308 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
 ret: 0         st: 1 flags:0  ts:-0.058000
-ret: 0         st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos:    676 size:   208
+ret: 0         st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos:    674 size:   208
 ret: 0         st: 1 flags:1  ts: 2.836000
-ret: 0         st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320149 size:   209
+ret: 0         st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320147 size:   209
 ret:-1         st:-1 flags:0  ts: 1.730004
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146860 size: 27925
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146858 size: 27925
 ret: 0         st: 0 flags:0  ts:-0.482000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
 ret: 0         st: 0 flags:1  ts: 2.413000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292308 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
 ret:-1         st: 1 flags:0  ts: 1.307000
 ret: 0         st: 1 flags:1  ts: 0.201000
-ret: 0         st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos:    676 size:   208
+ret: 0         st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos:    674 size:   208
 ret: 0         st:-1 flags:0  ts:-0.904994
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
 ret: 0         st:-1 flags:1  ts: 1.989173
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292308 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
 ret: 0         st: 0 flags:0  ts: 0.883000
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292308 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
 ret: 0         st: 0 flags:1  ts:-0.222000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
 ret:-1         st: 1 flags:0  ts: 2.672000
 ret: 0         st: 1 flags:1  ts: 1.566000
-ret: 0         st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320149 size:   209
+ret: 0         st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320147 size:   209
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146860 size: 27925
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146858 size: 27925
 ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    892 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    890 size: 27837
