Adjust timestamps in fMP4 if there is an initial composition offset

In some ISO-BMFF files, there is an initial non-zero composition offset,
but there is no EditList present.

This is against ISO-BMFF spec recommentation [1] and we believe in most
cases it is just missing the EditList.

[1] 14496-12:2015 8.6.6.1
It is recommended that such an edit be used to establish a presentation
time of 0 for the first presented sample, when composition offsets are
used.

Issue: #112.
Change-Id: I178d5ec9d8c294c9f70aac4f4dd6254c824e2255
This commit is contained in:
KongQun Yang 2018-08-08 10:57:58 -07:00
parent 0fe31423cb
commit 36a7c7d935
1 changed files with 9 additions and 2 deletions

View File

@ -681,7 +681,14 @@ int64_t TrackRunIterator::GetTimestampAdjustment(const Movie& movie,
} else { } else {
CompositionOffsetIterator composition_offset_iter( CompositionOffsetIterator composition_offset_iter(
track.media.information.sample_table.composition_time_to_sample); track.media.information.sample_table.composition_time_to_sample);
if (composition_offset_iter.IsValid()) if (!composition_offset_iter.IsValid()) {
// This is the init (sub)segment of a fragmented mp4, which does not
// contain any samples. Exit with 0 adjustment and without storing
// |timestamp_adjustment|. This function will be called again later
// with track fragment |traf|. |timestamp_adjustment| will be computed
// and stored then.
return 0;
}
composition_offset = composition_offset_iter.sample_offset(); composition_offset = composition_offset_iter.sample_offset();
} }