[FFmpeg-trac] #8234(avformat:new): mp4 file with id3v2 tag detected as mp4 but still fails decoding
FFmpeg
trac at avcodec.org
Wed Jan 4 18:33:16 EET 2023
#8234: mp4 file with id3v2 tag detected as mp4 but still fails decoding
-------------------------------------+-------------------------------------
Reporter: Mattias | Owner: (none)
Wadman |
Type: defect | Status: new
Priority: normal | Component: avformat
Version: git-master | Resolution:
Keywords: mov aac | Blocked By:
id3v2 |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by Mattias Wadman):
Problem seems to be that the mov demuxer does not correctly compensate for
tags when when calculating the sample offset. With this patch it works:
{{{
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 64fb7065d5..2c45e50ed0 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -326,6 +326,7 @@ typedef struct MOVContext {
int64_t extent_offset;
} *avif_info;
int avif_info_size;
+ int64_t header_offset;
} MOVContext;
int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 29bd3103e3..50a8e3308b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4140,7 +4140,7 @@ static void mov_build_index(MOVContext *mov,
AVStream *st)
for (i = 0; i < sc->chunk_count; i++) {
int64_t next_offset = i+1 < sc->chunk_count ?
sc->chunk_offsets[i+1] : INT64_MAX;
- current_offset = sc->chunk_offsets[i];
+ current_offset = mov->header_offset + sc->chunk_offsets[i];
while (mov_stsc_index_valid(stsc_index, sc->stsc_count) &&
i + 1 == sc->stsc_data[stsc_index + 1].first)
stsc_index++;
@@ -8416,6 +8416,7 @@ static int mov_read_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
+ mov->header_offset = avio_tell(pb);
mov->fc = s;
mov->trak_index = -1;
/* .mov and .mp4 aren't streamable anyway (only progressive download
if moov is before mdat) */
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8234#comment:4>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list