diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 9a2463808e491cfa4ec1f262f57b4c55d65e175e..43775ce3c26cfa36b60769185726422e394d8226 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -155,7 +155,10 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
     while (len >= taghdrlen) {
         if (isv34) {
             tag  = get_be32(s->pb);
+            if(version==3){
             tlen = get_be32(s->pb);
+            }else
+                tlen = get_size(s->pb, 4);
             get_be16(s->pb); /* flags */
         } else {
             tag  = get_be24(s->pb);