Pass initial timestamp offset to EncodedSampleExporter
When transmuxing, we usually only need to offset the timestamp by the position of a mediaItem in a sequence. Trim optimization introduces another type of offset: for the transmux of the second part of the video we need to offset the timestamps by the total duration already trancoded by transformer. PiperOrigin-RevId: 576134656
This commit is contained in:
parent
d6b11738e2
commit
beed1bd76e
@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
private static final int MAX_INPUT_BUFFER_COUNT = 10;
|
||||
|
||||
private final Format format;
|
||||
private final long initialTimestampOffsetUs;
|
||||
private final AtomicLong nextMediaItemOffsetUs;
|
||||
private final Queue<DecoderInputBuffer> availableInputBuffers;
|
||||
private final Queue<DecoderInputBuffer> pendingInputBuffers;
|
||||
@ -45,9 +46,11 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
Format format,
|
||||
TransformationRequest transformationRequest,
|
||||
MuxerWrapper muxerWrapper,
|
||||
FallbackListener fallbackListener) {
|
||||
FallbackListener fallbackListener,
|
||||
long initialTimestampOffsetUs) {
|
||||
super(format, muxerWrapper);
|
||||
this.format = format;
|
||||
this.initialTimestampOffsetUs = initialTimestampOffsetUs;
|
||||
nextMediaItemOffsetUs = new AtomicLong();
|
||||
availableInputBuffers = new ConcurrentLinkedDeque<>();
|
||||
ByteBuffer emptyBuffer = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());
|
||||
@ -82,7 +85,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
if (inputBuffer.isEndOfStream()) {
|
||||
inputEnded = true;
|
||||
} else {
|
||||
inputBuffer.timeUs += mediaItemOffsetUs;
|
||||
inputBuffer.timeUs += mediaItemOffsetUs + initialTimestampOffsetUs;
|
||||
pendingInputBuffers.add(inputBuffer);
|
||||
}
|
||||
return true;
|
||||
|
@ -617,7 +617,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
assetLoaderInputTracker.getAssetLoaderInputFormat(sequenceIndex, trackType),
|
||||
transformationRequest,
|
||||
muxerWrapper,
|
||||
fallbackListener));
|
||||
fallbackListener,
|
||||
videoSampleTimestampOffsetUs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user