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 static final int MAX_INPUT_BUFFER_COUNT = 10;
|
||||||
|
|
||||||
private final Format format;
|
private final Format format;
|
||||||
|
private final long initialTimestampOffsetUs;
|
||||||
private final AtomicLong nextMediaItemOffsetUs;
|
private final AtomicLong nextMediaItemOffsetUs;
|
||||||
private final Queue<DecoderInputBuffer> availableInputBuffers;
|
private final Queue<DecoderInputBuffer> availableInputBuffers;
|
||||||
private final Queue<DecoderInputBuffer> pendingInputBuffers;
|
private final Queue<DecoderInputBuffer> pendingInputBuffers;
|
||||||
@ -45,9 +46,11 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
Format format,
|
Format format,
|
||||||
TransformationRequest transformationRequest,
|
TransformationRequest transformationRequest,
|
||||||
MuxerWrapper muxerWrapper,
|
MuxerWrapper muxerWrapper,
|
||||||
FallbackListener fallbackListener) {
|
FallbackListener fallbackListener,
|
||||||
|
long initialTimestampOffsetUs) {
|
||||||
super(format, muxerWrapper);
|
super(format, muxerWrapper);
|
||||||
this.format = format;
|
this.format = format;
|
||||||
|
this.initialTimestampOffsetUs = initialTimestampOffsetUs;
|
||||||
nextMediaItemOffsetUs = new AtomicLong();
|
nextMediaItemOffsetUs = new AtomicLong();
|
||||||
availableInputBuffers = new ConcurrentLinkedDeque<>();
|
availableInputBuffers = new ConcurrentLinkedDeque<>();
|
||||||
ByteBuffer emptyBuffer = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());
|
ByteBuffer emptyBuffer = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());
|
||||||
@ -82,7 +85,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
if (inputBuffer.isEndOfStream()) {
|
if (inputBuffer.isEndOfStream()) {
|
||||||
inputEnded = true;
|
inputEnded = true;
|
||||||
} else {
|
} else {
|
||||||
inputBuffer.timeUs += mediaItemOffsetUs;
|
inputBuffer.timeUs += mediaItemOffsetUs + initialTimestampOffsetUs;
|
||||||
pendingInputBuffers.add(inputBuffer);
|
pendingInputBuffers.add(inputBuffer);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -617,7 +617,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
assetLoaderInputTracker.getAssetLoaderInputFormat(sequenceIndex, trackType),
|
assetLoaderInputTracker.getAssetLoaderInputFormat(sequenceIndex, trackType),
|
||||||
transformationRequest,
|
transformationRequest,
|
||||||
muxerWrapper,
|
muxerWrapper,
|
||||||
fallbackListener));
|
fallbackListener,
|
||||||
|
videoSampleTimestampOffsetUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user