diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 22f70ae87a582a7e09bc9dbbfb04af2f56ca25bd..56e3c9bf9bbece76f5d38c1d5aa20f5b58dfd073 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1621,9 +1621,9 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
 
                 pkt->pts = timecode;
                 pkt->pos = pos;
-                if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE)
+                if (st->codec->codec_id == CODEC_ID_TEXT)
                     pkt->convergence_duration = duration;
-                else
+                else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE)
                     pkt->duration = duration;
 
                 if (st->codec->codec_id == CODEC_ID_SSA)