History

avformat/mov: add interleaved_read option

For badly interleaved files, interleave packets from multiple tracks at the demuxer level can trigger seeking back and forth, which can be dramatically slow depending on the protocol. Demuxer level interleave can be useless sometimes, e.g., reading mp4 via http and then transcoding/remux to DASH. Disable this option when you don't need the demuxer level interleave, and want to avoid the IO penalizes.

Zhao Zhili committed 3 years ago

Commit a8d9da41 parent 6434e444 files · +13 −2Browse files

Showing the changes to libavformat (3 of 4 files). Show all

Unified · Split

3 files
  1. libavformat/isom.h +1 −0
  2. libavformat/mov.c +4 −1
  3. libavformat/version.h +1 −1
libavformat/isom.h+1−0
@@ -327,6 +327,7 @@ typedef struct MOVContext { · 326 unmodified lines
327 int64_t extent_offset;327 int64_t extent_offset;
328 } *avif_info;328 } *avif_info;
329 int avif_info_size;329 int avif_info_size;
330 int interleaved_read;
330} MOVContext;331} MOVContext;
331 332
332int ff_mp4_read_descr_len(AVIOContext *pb);333int ff_mp4_read_descr_len(AVIOContext *pb);
libavformat/mov.c+4−1
@@ -8780,6 +8780,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) · 8779 unmodified lines
8780 AVIndexEntry *sample = NULL;8780 AVIndexEntry *sample = NULL;
8781 int64_t best_dts = INT64_MAX;8781 int64_t best_dts = INT64_MAX;
8782 int i;8782 int i;
8783 MOVContext *mov = s->priv_data;
8784 int no_interleave = !mov->interleaved_read || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL);
8783 for (i = 0; i < s->nb_streams; i++) {8785 for (i = 0; i < s->nb_streams; i++) {
8784 AVStream *avst = s->streams[i];8786 AVStream *avst = s->streams[i];
8785 FFStream *const avsti = ffstream(avst);8787 FFStream *const avsti = ffstream(avst);
@@ -8788,7 +8790,7 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) · 2 unmodified lines
8788 AVIndexEntry *current_sample = &avsti->index_entries[msc->current_sample];8790 AVIndexEntry *current_sample = &avsti->index_entries[msc->current_sample];
8789 int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);8791 int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);
8790 av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);8792 av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);
8791 if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && current_sample->pos < sample->pos) ||8793 if (!sample || (no_interleave && current_sample->pos < sample->pos) ||
8792 ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&8794 ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
8793 ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && dts != AV_NOPTS_VALUE &&8795 ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && dts != AV_NOPTS_VALUE &&
8794 ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||8796 ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
@@ -9282,6 +9284,7 @@ static const AVOption mov_options[] = { · 487 unmodified lines
9282 { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), AV_OPT_TYPE_BOOL,9284 { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), AV_OPT_TYPE_BOOL,
9283 {.i64 = 0}, 0, 1, FLAGS },9285 {.i64 = 0}, 0, 1, FLAGS },
9284 { "max_stts_delta", "treat offsets above this value as invalid", OFFSET(max_stts_delta), AV_OPT_TYPE_INT, {.i64 = UINT_MAX-48000*10 }, 0, UINT_MAX, .flags = AV_OPT_FLAG_DECODING_PARAM },9286 { "max_stts_delta", "treat offsets above this value as invalid", OFFSET(max_stts_delta), AV_OPT_TYPE_INT, {.i64 = UINT_MAX-48000*10 }, 0, UINT_MAX, .flags = AV_OPT_FLAG_DECODING_PARAM },
9287 { "interleaved_read", "Interleave packets from multiple tracks at demuxer level", OFFSET(interleaved_read), AV_OPT_TYPE_BOOL, {.i64 = 1 }, 0, 1, .flags = AV_OPT_FLAG_DECODING_PARAM },
9285 9288
9286 { NULL },9289 { NULL },
9287};9290};
libavformat/version.h+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32#include "version_major.h"32#include "version_major.h"
33 33
34#define LIBAVFORMAT_VERSION_MINOR 1234#define LIBAVFORMAT_VERSION_MINOR 12
35#define LIBAVFORMAT_VERSION_MICRO 10035#define LIBAVFORMAT_VERSION_MICRO 101
36 36
37#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \37#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
38 LIBAVFORMAT_VERSION_MINOR, \38 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t