Message ID | tencent_F0FE7E0EAF523BA5C081B4A868BA0375690A@qq.com |
---|---|
State | Accepted |
Commit | 811f2f91da101db02ee8b1f0e4f6276e5aecda5e |
Headers | show |
Series | [FFmpeg-devel,v3] avformat/mov: discard data streams with all zero sample_delta | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_armv7_RPi4 | success | Make finished |
andriy/make_fate_armv7_RPi4 | success | Make fate finished |
> On Jul 6, 2022, at 3:05 PM, Zhao Zhili <quinkblack@foxmail.com> wrote: > > From: Zhao Zhili <zhilizhao@tencent.com> > > Streams with all zero sample_delta in 'stts' have all zero dts. > They have higher chance be chose by mov_find_next_sample(), which > leads to seek again and again. > > For example, GoPro created a 'GoPro SOS' stream: > Stream #0:4[0x5](eng): Data: none (fdsc / 0x63736466), 13 kb/s (default) > Metadata: > creation_time : 2022-06-21T08:49:19.000000Z > handler_name : GoPro SOS > > With 'ffprobe -show_frames http://example.com/gopro.mp4', ffprobe > blocks until all samples in 'GoPro SOS' stream are consumed first. > > Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> > --- > v3: 'for ffmpeg' -> 'for ffmpeg command.' > v2: suggest how to override discard flag in log message. > libavformat/mov.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 88669faa70..9a24e5effa 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -3062,6 +3062,21 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) > st->nb_frames= total_sample_count; > if (duration) > st->duration= FFMIN(st->duration, duration); > + > + // All samples have zero duration. They have higher chance be chose by > + // mov_find_next_sample, which leads to seek again and again. > + // > + // It's AVERROR_INVALIDDATA actually, but such files exist in the wild. > + // So only mark data stream as discarded for safety. > + if (!duration && sc->stts_count && > + st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { > + av_log(c->fc, AV_LOG_WARNING, > + "All samples in data stream index:id [%d:%d] have zero " > + "duration, stream set to be discarded by default. Override " > + "using AVStream->discard or -discard for ffmpeg command.\n", > + st->index, st->id); > + st->discard = AVDISCARD_ALL; > + } > sc->track_end = duration; > return 0; > } Will apply tomorrow if no more comments.
diff --git a/libavformat/mov.c b/libavformat/mov.c index 88669faa70..9a24e5effa 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3062,6 +3062,21 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->nb_frames= total_sample_count; if (duration) st->duration= FFMIN(st->duration, duration); + + // All samples have zero duration. They have higher chance be chose by + // mov_find_next_sample, which leads to seek again and again. + // + // It's AVERROR_INVALIDDATA actually, but such files exist in the wild. + // So only mark data stream as discarded for safety. + if (!duration && sc->stts_count && + st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { + av_log(c->fc, AV_LOG_WARNING, + "All samples in data stream index:id [%d:%d] have zero " + "duration, stream set to be discarded by default. Override " + "using AVStream->discard or -discard for ffmpeg command.\n", + st->index, st->id); + st->discard = AVDISCARD_ALL; + } sc->track_end = duration; return 0; }