[FFmpeg-devel] [PATCH] lavf/movdec: flag chapter streams as such, even when not reading them
Rodger Combs
rodger.combs at gmail.com
Tue Sep 26 05:01:28 EEST 2017
This allows the use of the `ignore_chapters` option to avoid performing
extra seeks at startup without producing "subtitle" chapter streams.
---
libavformat/mov.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2519707345..5b40408d62 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5780,6 +5780,7 @@ static void mov_read_chapters(AVFormatContext *s)
int64_t cur_pos;
int i, j;
int chapter_track;
+ int read_contents = (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mov->ignore_chapters;
for (j = 0; j < mov->nb_chapter_tracks; j++) {
chapter_track = mov->chapter_tracks[j];
@@ -5799,7 +5800,7 @@ static void mov_read_chapters(AVFormatContext *s)
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
st->disposition |= AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS;
- if (st->nb_index_entries) {
+ if (st->nb_index_entries && read_contents) {
// Retrieve the first frame, if possible
AVPacket pkt;
AVIndexEntry *sample = &st->index_entries[0];
@@ -5819,6 +5820,10 @@ static void mov_read_chapters(AVFormatContext *s)
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
st->discard = AVDISCARD_ALL;
+
+ if (!read_contents)
+ continue;
+
for (i = 0; i < st->nb_index_entries; i++) {
AVIndexEntry *sample = &st->index_entries[i];
int64_t end = i+1 < st->nb_index_entries ? st->index_entries[i+1].timestamp : st->duration;
@@ -5869,7 +5874,8 @@ static void mov_read_chapters(AVFormatContext *s)
}
}
finish:
- avio_seek(sc->pb, cur_pos, SEEK_SET);
+ if (read_contents)
+ avio_seek(sc->pb, cur_pos, SEEK_SET);
}
}
@@ -6206,9 +6212,11 @@ static int mov_read_header(AVFormatContext *s)
}
av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb));
+
+ if (mov->nb_chapter_tracks > 0)
+ mov_read_chapters(s);
+
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
- if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters)
- mov_read_chapters(s);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codecpar->codec_tag == AV_RL32("tmcd")) {
mov_read_timecode_track(s, s->streams[i]);
--
2.14.1
More information about the ffmpeg-devel
mailing list