mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Fix clipping in AudioSamplePipeline
When clipping a MediaItem with start time > 0, the audio was ending before the video. This is because: - Audio timestamps are computed based on the sample sizes, with a start time set to streamOffsetUs (i.e. the streamStartPositionUs is not taken into account). - The SamplePipeline was subtracting streamStartPositionUs from the timestamps before sending the samples to the muxer. - As a result, the audio timestamps were shifted by streamStartPositionUs, while they should be shifter by streamOffsetUs. PiperOrigin-RevId: 511175923
This commit is contained in:
parent
d0dc4817c6
commit
faad46318b
3 changed files with 2 additions and 4 deletions
|
|
@ -60,7 +60,6 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||
// TODO(b/260618558): Move silent audio generation upstream of this component.
|
||||
public AudioSamplePipeline(
|
||||
Format firstInputFormat,
|
||||
long streamStartPositionUs,
|
||||
long streamOffsetUs,
|
||||
TransformationRequest transformationRequest,
|
||||
boolean flattenForSlowMotion,
|
||||
|
|
@ -69,7 +68,7 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||
MuxerWrapper muxerWrapper,
|
||||
FallbackListener fallbackListener)
|
||||
throws ExportException {
|
||||
super(firstInputFormat, streamStartPositionUs, muxerWrapper);
|
||||
super(firstInputFormat, /* streamStartPositionUs= */ streamOffsetUs, muxerWrapper);
|
||||
|
||||
silentAudioGenerator = new SilentAudioGenerator(firstInputFormat);
|
||||
availableInputBuffers = new ConcurrentLinkedDeque<>();
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
compositeAssetLoaderListener.onTrackAdded(
|
||||
firstAudioFormat,
|
||||
SUPPORTED_OUTPUT_TYPE_DECODED,
|
||||
/* streamStartPositionUs= */ streamOffsetUs,
|
||||
streamStartPositionUs,
|
||||
streamOffsetUs));
|
||||
sampleConsumersByTrackType.put(C.TRACK_TYPE_AUDIO, audioSampleConsumer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,7 +434,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
if (MimeTypes.isAudio(firstInputFormat.sampleMimeType)) {
|
||||
return new AudioSamplePipeline(
|
||||
firstInputFormat,
|
||||
streamStartPositionUs,
|
||||
streamOffsetUs,
|
||||
transformationRequest,
|
||||
firstEditedMediaItem.flattenForSlowMotion,
|
||||
|
|
|
|||
Loading…
Reference in a new issue