History

avformat/mov: discard data streams with all zero sample_delta

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.

Zhao Zhili committed 4 years ago

Commit 811f2f91 parent f6112551 file · +15 −0Browse files

Unified · Split

libavformat/mov.c+15−0
@@ -3062,6 +3062,21 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 3061 unmodified lines
30623062 st->nb_frames= total_sample_count;
30633063 if (duration)
30643064 st->duration= FFMIN(st->duration, duration);
3065+
3066+ // All samples have zero duration. They have higher chance be chose by
3067+ // mov_find_next_sample, which leads to seek again and again.
3068+ //
3069+ // It's AVERROR_INVALIDDATA actually, but such files exist in the wild.
3070+ // So only mark data stream as discarded for safety.
3071+ if (!duration && sc->stts_count &&
3072+ st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
3073+ av_log(c->fc, AV_LOG_WARNING,
3074+ "All samples in data stream index:id [%d:%d] have zero "
3075+ "duration, stream set to be discarded by default. Override "
3076+ "using AVStream->discard or -discard for ffmpeg command.\n",
3077+ st->index, st->id);
3078+ st->discard = AVDISCARD_ALL;
3079+ }
30653080 sc->track_end = duration;
30663081 return 0;
30673082 }

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