adjust timestamps for cea608 and emsg in FMP4
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208526775
This commit is contained in:
parent
32035e1bf3
commit
c4024e17f6
@ -585,10 +585,13 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||||||
|
|
||||||
// Output the sample metadata.
|
// Output the sample metadata.
|
||||||
if (segmentIndexEarliestPresentationTimeUs != C.TIME_UNSET) {
|
if (segmentIndexEarliestPresentationTimeUs != C.TIME_UNSET) {
|
||||||
|
long sampleTimeUs = segmentIndexEarliestPresentationTimeUs + presentationTimeDeltaUs;
|
||||||
|
if (timestampAdjuster != null) {
|
||||||
|
sampleTimeUs = timestampAdjuster.adjustSampleTimestamp(sampleTimeUs);
|
||||||
|
}
|
||||||
for (TrackOutput emsgTrackOutput : emsgTrackOutputs) {
|
for (TrackOutput emsgTrackOutput : emsgTrackOutputs) {
|
||||||
emsgTrackOutput.sampleMetadata(
|
emsgTrackOutput.sampleMetadata(
|
||||||
segmentIndexEarliestPresentationTimeUs + presentationTimeDeltaUs,
|
sampleTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, /* offset= */ 0, null);
|
||||||
C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0 /* offset */, null);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We need the first sample timestamp in the segment before we can output the metadata.
|
// We need the first sample timestamp in the segment before we can output the metadata.
|
||||||
@ -1195,6 +1198,10 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||||||
Track track = currentTrackBundle.track;
|
Track track = currentTrackBundle.track;
|
||||||
TrackOutput output = currentTrackBundle.output;
|
TrackOutput output = currentTrackBundle.output;
|
||||||
int sampleIndex = currentTrackBundle.currentSampleIndex;
|
int sampleIndex = currentTrackBundle.currentSampleIndex;
|
||||||
|
long sampleTimeUs = fragment.getSamplePresentationTime(sampleIndex) * 1000L;
|
||||||
|
if (timestampAdjuster != null) {
|
||||||
|
sampleTimeUs = timestampAdjuster.adjustSampleTimestamp(sampleTimeUs);
|
||||||
|
}
|
||||||
if (track.nalUnitLengthFieldLength != 0) {
|
if (track.nalUnitLengthFieldLength != 0) {
|
||||||
// Zero the top three bytes of the array that we'll use to decode nal unit lengths, in case
|
// Zero the top three bytes of the array that we'll use to decode nal unit lengths, in case
|
||||||
// they're only 1 or 2 bytes long.
|
// they're only 1 or 2 bytes long.
|
||||||
@ -1235,8 +1242,7 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||||||
// If the format is H.265/HEVC the NAL unit header has two bytes so skip one more byte.
|
// If the format is H.265/HEVC the NAL unit header has two bytes so skip one more byte.
|
||||||
nalBuffer.setPosition(MimeTypes.VIDEO_H265.equals(track.format.sampleMimeType) ? 1 : 0);
|
nalBuffer.setPosition(MimeTypes.VIDEO_H265.equals(track.format.sampleMimeType) ? 1 : 0);
|
||||||
nalBuffer.setLimit(unescapedLength);
|
nalBuffer.setLimit(unescapedLength);
|
||||||
CeaUtil.consume(fragment.getSamplePresentationTime(sampleIndex) * 1000L, nalBuffer,
|
CeaUtil.consume(sampleTimeUs, nalBuffer, cea608TrackOutputs);
|
||||||
cea608TrackOutputs);
|
|
||||||
} else {
|
} else {
|
||||||
// Write the payload of the NAL unit.
|
// Write the payload of the NAL unit.
|
||||||
writtenBytes = output.sampleData(input, sampleCurrentNalBytesRemaining, false);
|
writtenBytes = output.sampleData(input, sampleCurrentNalBytesRemaining, false);
|
||||||
@ -1252,11 +1258,6 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long sampleTimeUs = fragment.getSamplePresentationTime(sampleIndex) * 1000L;
|
|
||||||
if (timestampAdjuster != null) {
|
|
||||||
sampleTimeUs = timestampAdjuster.adjustSampleTimestamp(sampleTimeUs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@C.BufferFlags int sampleFlags = fragment.sampleIsSyncFrameTable[sampleIndex]
|
@C.BufferFlags int sampleFlags = fragment.sampleIsSyncFrameTable[sampleIndex]
|
||||||
? C.BUFFER_FLAG_KEY_FRAME : 0;
|
? C.BUFFER_FLAG_KEY_FRAME : 0;
|
||||||
|
|
||||||
@ -1283,10 +1284,17 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||||||
while (!pendingMetadataSampleInfos.isEmpty()) {
|
while (!pendingMetadataSampleInfos.isEmpty()) {
|
||||||
MetadataSampleInfo sampleInfo = pendingMetadataSampleInfos.removeFirst();
|
MetadataSampleInfo sampleInfo = pendingMetadataSampleInfos.removeFirst();
|
||||||
pendingMetadataSampleBytes -= sampleInfo.size;
|
pendingMetadataSampleBytes -= sampleInfo.size;
|
||||||
|
long metadataTimeUs = sampleTimeUs + sampleInfo.presentationTimeDeltaUs;
|
||||||
|
if (timestampAdjuster != null) {
|
||||||
|
metadataTimeUs = timestampAdjuster.adjustSampleTimestamp(metadataTimeUs);
|
||||||
|
}
|
||||||
for (TrackOutput emsgTrackOutput : emsgTrackOutputs) {
|
for (TrackOutput emsgTrackOutput : emsgTrackOutputs) {
|
||||||
emsgTrackOutput.sampleMetadata(
|
emsgTrackOutput.sampleMetadata(
|
||||||
sampleTimeUs + sampleInfo.presentationTimeDeltaUs,
|
metadataTimeUs,
|
||||||
C.BUFFER_FLAG_KEY_FRAME, sampleInfo.size, pendingMetadataSampleBytes, null);
|
C.BUFFER_FLAG_KEY_FRAME,
|
||||||
|
sampleInfo.size,
|
||||||
|
pendingMetadataSampleBytes,
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user