mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Rename LAST_FRAME_DURATION_BEHAVIOR to LAST_SAMPLE_DURATION_BEHAVIOR
The original idea was to set duration for the last video frame, but this behavior actually applies to all tracks. PiperOrigin-RevId: 667990099
This commit is contained in:
parent
d0676245b5
commit
ebd60acc95
@ -131,7 +131,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
MetadataCollector metadataCollector,
|
MetadataCollector metadataCollector,
|
||||||
long minInputPtsUs,
|
long minInputPtsUs,
|
||||||
boolean isFragmentedMp4,
|
boolean isFragmentedMp4,
|
||||||
@Mp4Muxer.LastFrameDurationBehavior int lastFrameDurationBehavior) {
|
@Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior) {
|
||||||
// The timestamp will always fit into a 32-bit integer. This is already validated in the
|
// The timestamp will always fit into a 32-bit integer. This is already validated in the
|
||||||
// Mp4Muxer.setTimestampData() API. The value after type casting might be negative, but it is
|
// Mp4Muxer.setTimestampData() API. The value after type casting might be negative, but it is
|
||||||
// still valid because it is meant to be read as an unsigned integer.
|
// still valid because it is meant to be read as an unsigned integer.
|
||||||
@ -157,7 +157,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
track.writtenSamples(),
|
track.writtenSamples(),
|
||||||
minInputPtsUs,
|
minInputPtsUs,
|
||||||
track.videoUnitTimebase(),
|
track.videoUnitTimebase(),
|
||||||
lastFrameDurationBehavior);
|
lastSampleDurationBehavior);
|
||||||
|
|
||||||
long trackDurationInTrackUnitsVu = 0;
|
long trackDurationInTrackUnitsVu = 0;
|
||||||
for (int j = 0; j < sampleDurationsVu.size(); j++) {
|
for (int j = 0; j < sampleDurationsVu.size(); j++) {
|
||||||
@ -808,7 +808,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
* Otherwise this should be equal to the presentation timestamp of first sample present in the
|
* Otherwise this should be equal to the presentation timestamp of first sample present in the
|
||||||
* {@code samplesInfo} list.
|
* {@code samplesInfo} list.
|
||||||
* @param videoUnitTimescale The timescale of the track.
|
* @param videoUnitTimescale The timescale of the track.
|
||||||
* @param lastDurationBehavior The behaviour for the last sample duration.
|
* @param lastSampleDurationBehavior The behaviour for the last sample duration.
|
||||||
* @return A list of all the sample durations.
|
* @return A list of all the sample durations.
|
||||||
*/
|
*/
|
||||||
// TODO: b/280084657 - Add support for setting last sample duration.
|
// TODO: b/280084657 - Add support for setting last sample duration.
|
||||||
@ -816,7 +816,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
List<BufferInfo> samplesInfo,
|
List<BufferInfo> samplesInfo,
|
||||||
long firstSamplePresentationTimeUs,
|
long firstSamplePresentationTimeUs,
|
||||||
int videoUnitTimescale,
|
int videoUnitTimescale,
|
||||||
@Mp4Muxer.LastFrameDurationBehavior int lastDurationBehavior) {
|
@Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior) {
|
||||||
List<Long> presentationTimestampsUs = new ArrayList<>(samplesInfo.size());
|
List<Long> presentationTimestampsUs = new ArrayList<>(samplesInfo.size());
|
||||||
List<Integer> durationsVu = new ArrayList<>(samplesInfo.size());
|
List<Integer> durationsVu = new ArrayList<>(samplesInfo.size());
|
||||||
|
|
||||||
@ -855,7 +855,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
// Default duration for the last sample.
|
// Default duration for the last sample.
|
||||||
durationsVu.add(0);
|
durationsVu.add(0);
|
||||||
|
|
||||||
adjustLastSampleDuration(durationsVu, lastDurationBehavior);
|
adjustLastSampleDuration(durationsVu, lastSampleDurationBehavior);
|
||||||
return durationsVu;
|
return durationsVu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1264,7 +1264,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
// TODO: b/317117431 - Change this method to getLastSampleDuration().
|
// TODO: b/317117431 - Change this method to getLastSampleDuration().
|
||||||
/** Adjusts the duration of the very last sample if needed. */
|
/** Adjusts the duration of the very last sample if needed. */
|
||||||
private static void adjustLastSampleDuration(
|
private static void adjustLastSampleDuration(
|
||||||
List<Integer> durationsToBeAdjustedVu, @Mp4Muxer.LastFrameDurationBehavior int behavior) {
|
List<Integer> durationsToBeAdjustedVu, @Mp4Muxer.LastSampleDurationBehavior int behavior) {
|
||||||
// Technically, MP4 file stores frame durations, not timestamps. If a frame starts at a
|
// Technically, MP4 file stores frame durations, not timestamps. If a frame starts at a
|
||||||
// given timestamp then the duration of the last frame is not obvious. If samples follow each
|
// given timestamp then the duration of the last frame is not obvious. If samples follow each
|
||||||
// other in roughly regular intervals (e.g. in a normal, 30 fps video), it can be safely assumed
|
// other in roughly regular intervals (e.g. in a normal, 30 fps video), it can be safely assumed
|
||||||
@ -1278,14 +1278,14 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (behavior) {
|
switch (behavior) {
|
||||||
case Mp4Muxer.LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION:
|
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION:
|
||||||
// This is the default MediaMuxer behavior: the last sample duration is a copy of the
|
// This is the default MediaMuxer behavior: the last sample duration is a copy of the
|
||||||
// previous sample duration.
|
// previous sample duration.
|
||||||
durationsToBeAdjustedVu.set(
|
durationsToBeAdjustedVu.set(
|
||||||
durationsToBeAdjustedVu.size() - 1,
|
durationsToBeAdjustedVu.size() - 1,
|
||||||
durationsToBeAdjustedVu.get(durationsToBeAdjustedVu.size() - 2));
|
durationsToBeAdjustedVu.get(durationsToBeAdjustedVu.size() - 2));
|
||||||
break;
|
break;
|
||||||
case Mp4Muxer.LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME:
|
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE:
|
||||||
// Keep the last sample duration as short as possible.
|
// Keep the last sample duration as short as possible.
|
||||||
checkState(Iterables.getLast(durationsToBeAdjustedVu) == 0L);
|
checkState(Iterables.getLast(durationsToBeAdjustedVu) == 0L);
|
||||||
break;
|
break;
|
||||||
|
@ -68,7 +68,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
private final AnnexBToAvccConverter annexBToAvccConverter;
|
private final AnnexBToAvccConverter annexBToAvccConverter;
|
||||||
private final long fragmentDurationUs;
|
private final long fragmentDurationUs;
|
||||||
private final boolean sampleCopyEnabled;
|
private final boolean sampleCopyEnabled;
|
||||||
private final @Mp4Muxer.LastFrameDurationBehavior int lastFrameDurationBehavior;
|
private final @Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior;
|
||||||
private final List<Track> tracks;
|
private final List<Track> tracks;
|
||||||
|
|
||||||
private @MonotonicNonNull Track videoTrack;
|
private @MonotonicNonNull Track videoTrack;
|
||||||
@ -100,7 +100,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
this.annexBToAvccConverter = annexBToAvccConverter;
|
this.annexBToAvccConverter = annexBToAvccConverter;
|
||||||
this.fragmentDurationUs = fragmentDurationMs * 1_000;
|
this.fragmentDurationUs = fragmentDurationMs * 1_000;
|
||||||
this.sampleCopyEnabled = sampleCopyEnabled;
|
this.sampleCopyEnabled = sampleCopyEnabled;
|
||||||
lastFrameDurationBehavior = Mp4Muxer.LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION;
|
lastSampleDurationBehavior = Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION;
|
||||||
tracks = new ArrayList<>();
|
tracks = new ArrayList<>();
|
||||||
minInputPresentationTimeUs = Long.MAX_VALUE;
|
minInputPresentationTimeUs = Long.MAX_VALUE;
|
||||||
currentFragmentSequenceNumber = 1;
|
currentFragmentSequenceNumber = 1;
|
||||||
@ -207,7 +207,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
metadataCollector,
|
metadataCollector,
|
||||||
/* minInputPtsUs= */ 0L,
|
/* minInputPtsUs= */ 0L,
|
||||||
/* isFragmentedMp4= */ true,
|
/* isFragmentedMp4= */ true,
|
||||||
lastFrameDurationBehavior));
|
lastSampleDurationBehavior));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldFlushPendingSamples(
|
private boolean shouldFlushPendingSamples(
|
||||||
@ -333,7 +333,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
? minInputPresentationTimeUs
|
? minInputPresentationTimeUs
|
||||||
: pendingSamplesBufferInfo.get(0).presentationTimeUs,
|
: pendingSamplesBufferInfo.get(0).presentationTimeUs,
|
||||||
track.videoUnitTimebase(),
|
track.videoUnitTimebase(),
|
||||||
Mp4Muxer.LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION);
|
Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION);
|
||||||
|
|
||||||
List<Integer> sampleCompositionTimeOffsets =
|
List<Integer> sampleCompositionTimeOffsets =
|
||||||
Boxes.calculateSampleCompositionTimeOffsets(
|
Boxes.calculateSampleCompositionTimeOffsets(
|
||||||
|
@ -145,19 +145,19 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target(TYPE_USE)
|
@Target(TYPE_USE)
|
||||||
@IntDef({
|
@IntDef({
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION,
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME
|
LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION,
|
||||||
})
|
})
|
||||||
public @interface LastFrameDurationBehavior {}
|
public @interface LastSampleDurationBehavior {}
|
||||||
|
|
||||||
/** Insert a zero-length last sample. */
|
/** Insert a zero-length last sample. */
|
||||||
public static final int LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME = 0;
|
public static final int LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the difference between the last timestamp and the one before that as the duration of the
|
* Use the difference between the last timestamp and the one before that as the duration of the
|
||||||
* last sample.
|
* last sample.
|
||||||
*/
|
*/
|
||||||
public static final int LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION = 1;
|
public static final int LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION = 1;
|
||||||
|
|
||||||
/** The specific MP4 file format. */
|
/** The specific MP4 file format. */
|
||||||
@Documented
|
@Documented
|
||||||
@ -183,7 +183,7 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private final FileOutputStream outputStream;
|
private final FileOutputStream outputStream;
|
||||||
|
|
||||||
private @LastFrameDurationBehavior int lastFrameDurationBehavior;
|
private @LastSampleDurationBehavior int lastSampleDurationBehavior;
|
||||||
@Nullable private AnnexBToAvccConverter annexBToAvccConverter;
|
@Nullable private AnnexBToAvccConverter annexBToAvccConverter;
|
||||||
private boolean sampleCopyEnabled;
|
private boolean sampleCopyEnabled;
|
||||||
private boolean attemptStreamableOutputEnabled;
|
private boolean attemptStreamableOutputEnabled;
|
||||||
@ -197,21 +197,21 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
*/
|
*/
|
||||||
public Builder(FileOutputStream outputStream) {
|
public Builder(FileOutputStream outputStream) {
|
||||||
this.outputStream = outputStream;
|
this.outputStream = outputStream;
|
||||||
lastFrameDurationBehavior = LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME;
|
lastSampleDurationBehavior = LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE;
|
||||||
sampleCopyEnabled = true;
|
sampleCopyEnabled = true;
|
||||||
attemptStreamableOutputEnabled = true;
|
attemptStreamableOutputEnabled = true;
|
||||||
outputFileFormat = FILE_FORMAT_DEFAULT;
|
outputFileFormat = FILE_FORMAT_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link LastFrameDurationBehavior} for the video track.
|
* Sets the {@link LastSampleDurationBehavior}.
|
||||||
*
|
*
|
||||||
* <p>The default value is {@link #LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME}.
|
* <p>The default value is {@link #LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE}.
|
||||||
*/
|
*/
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public Mp4Muxer.Builder setLastFrameDurationBehavior(
|
public Mp4Muxer.Builder setLastSampleDurationBehavior(
|
||||||
@LastFrameDurationBehavior int lastFrameDurationBehavior) {
|
@LastSampleDurationBehavior int lastSampleDurationBehavior) {
|
||||||
this.lastFrameDurationBehavior = lastFrameDurationBehavior;
|
this.lastSampleDurationBehavior = lastSampleDurationBehavior;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
"EditablevideoParameters must be set for FILE_FORMAT_EDITABLE_VIDEO");
|
"EditablevideoParameters must be set for FILE_FORMAT_EDITABLE_VIDEO");
|
||||||
return new Mp4Muxer(
|
return new Mp4Muxer(
|
||||||
outputStream,
|
outputStream,
|
||||||
lastFrameDurationBehavior,
|
lastSampleDurationBehavior,
|
||||||
annexBToAvccConverter == null ? AnnexBToAvccConverter.DEFAULT : annexBToAvccConverter,
|
annexBToAvccConverter == null ? AnnexBToAvccConverter.DEFAULT : annexBToAvccConverter,
|
||||||
sampleCopyEnabled,
|
sampleCopyEnabled,
|
||||||
attemptStreamableOutputEnabled,
|
attemptStreamableOutputEnabled,
|
||||||
@ -303,7 +303,7 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
|
|
||||||
private final FileOutputStream outputStream;
|
private final FileOutputStream outputStream;
|
||||||
private final FileChannel outputChannel;
|
private final FileChannel outputChannel;
|
||||||
private final @LastFrameDurationBehavior int lastFrameDurationBehavior;
|
private final @LastSampleDurationBehavior int lastSampleDurationBehavior;
|
||||||
private final AnnexBToAvccConverter annexBToAvccConverter;
|
private final AnnexBToAvccConverter annexBToAvccConverter;
|
||||||
private final boolean sampleCopyEnabled;
|
private final boolean sampleCopyEnabled;
|
||||||
private final boolean attemptStreamableOutputEnabled;
|
private final boolean attemptStreamableOutputEnabled;
|
||||||
@ -320,7 +320,7 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
|
|
||||||
private Mp4Muxer(
|
private Mp4Muxer(
|
||||||
FileOutputStream outputStream,
|
FileOutputStream outputStream,
|
||||||
@LastFrameDurationBehavior int lastFrameDurationBehavior,
|
@LastSampleDurationBehavior int lastFrameDurationBehavior,
|
||||||
AnnexBToAvccConverter annexBToAvccConverter,
|
AnnexBToAvccConverter annexBToAvccConverter,
|
||||||
boolean sampleCopyEnabled,
|
boolean sampleCopyEnabled,
|
||||||
boolean attemptStreamableOutputEnabled,
|
boolean attemptStreamableOutputEnabled,
|
||||||
@ -328,7 +328,7 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
@Nullable EditableVideoParameters editableVideoParameters) {
|
@Nullable EditableVideoParameters editableVideoParameters) {
|
||||||
this.outputStream = outputStream;
|
this.outputStream = outputStream;
|
||||||
outputChannel = outputStream.getChannel();
|
outputChannel = outputStream.getChannel();
|
||||||
this.lastFrameDurationBehavior = lastFrameDurationBehavior;
|
this.lastSampleDurationBehavior = lastFrameDurationBehavior;
|
||||||
this.annexBToAvccConverter = annexBToAvccConverter;
|
this.annexBToAvccConverter = annexBToAvccConverter;
|
||||||
this.sampleCopyEnabled = sampleCopyEnabled;
|
this.sampleCopyEnabled = sampleCopyEnabled;
|
||||||
this.attemptStreamableOutputEnabled = attemptStreamableOutputEnabled;
|
this.attemptStreamableOutputEnabled = attemptStreamableOutputEnabled;
|
||||||
@ -504,7 +504,7 @@ public final class Mp4Muxer implements Muxer {
|
|||||||
cacheFileOutputStream.getChannel(),
|
cacheFileOutputStream.getChannel(),
|
||||||
checkNotNull(editableVideoMetadataCollector),
|
checkNotNull(editableVideoMetadataCollector),
|
||||||
annexBToAvccConverter,
|
annexBToAvccConverter,
|
||||||
lastFrameDurationBehavior,
|
lastSampleDurationBehavior,
|
||||||
sampleCopyEnabled,
|
sampleCopyEnabled,
|
||||||
attemptStreamableOutputEnabled);
|
attemptStreamableOutputEnabled);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
private final FileChannel outputFileChannel;
|
private final FileChannel outputFileChannel;
|
||||||
private final MetadataCollector metadataCollector;
|
private final MetadataCollector metadataCollector;
|
||||||
private final AnnexBToAvccConverter annexBToAvccConverter;
|
private final AnnexBToAvccConverter annexBToAvccConverter;
|
||||||
private final @Mp4Muxer.LastFrameDurationBehavior int lastFrameDurationBehavior;
|
private final @Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior;
|
||||||
private final boolean sampleCopyEnabled;
|
private final boolean sampleCopyEnabled;
|
||||||
private final List<Track> tracks;
|
private final List<Track> tracks;
|
||||||
private final List<Track> editableVideoTracks;
|
private final List<Track> editableVideoTracks;
|
||||||
@ -77,8 +77,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
* @param annexBToAvccConverter The {@link AnnexBToAvccConverter} to be used to convert H.264 and
|
* @param annexBToAvccConverter The {@link AnnexBToAvccConverter} to be used to convert H.264 and
|
||||||
* H.265 NAL units from the Annex-B format (using start codes to delineate NAL units) to the
|
* H.265 NAL units from the Annex-B format (using start codes to delineate NAL units) to the
|
||||||
* AVCC format (which uses length prefixes).
|
* AVCC format (which uses length prefixes).
|
||||||
* @param lastFrameDurationBehavior The {@link Mp4Muxer.LastFrameDurationBehavior} for the video
|
* @param lastSampleDurationBehavior The {@link Mp4Muxer.LastSampleDurationBehavior}.
|
||||||
* track.
|
|
||||||
* @param sampleCopyEnabled Whether sample copying is enabled.
|
* @param sampleCopyEnabled Whether sample copying is enabled.
|
||||||
* @param attemptStreamableOutputEnabled Whether to attempt to write a streamable output.
|
* @param attemptStreamableOutputEnabled Whether to attempt to write a streamable output.
|
||||||
*/
|
*/
|
||||||
@ -86,13 +85,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
FileChannel fileChannel,
|
FileChannel fileChannel,
|
||||||
MetadataCollector metadataCollector,
|
MetadataCollector metadataCollector,
|
||||||
AnnexBToAvccConverter annexBToAvccConverter,
|
AnnexBToAvccConverter annexBToAvccConverter,
|
||||||
@Mp4Muxer.LastFrameDurationBehavior int lastFrameDurationBehavior,
|
@Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior,
|
||||||
boolean sampleCopyEnabled,
|
boolean sampleCopyEnabled,
|
||||||
boolean attemptStreamableOutputEnabled) {
|
boolean attemptStreamableOutputEnabled) {
|
||||||
this.outputFileChannel = fileChannel;
|
this.outputFileChannel = fileChannel;
|
||||||
this.metadataCollector = metadataCollector;
|
this.metadataCollector = metadataCollector;
|
||||||
this.annexBToAvccConverter = annexBToAvccConverter;
|
this.annexBToAvccConverter = annexBToAvccConverter;
|
||||||
this.lastFrameDurationBehavior = lastFrameDurationBehavior;
|
this.lastSampleDurationBehavior = lastSampleDurationBehavior;
|
||||||
this.sampleCopyEnabled = sampleCopyEnabled;
|
this.sampleCopyEnabled = sampleCopyEnabled;
|
||||||
tracks = new ArrayList<>();
|
tracks = new ArrayList<>();
|
||||||
editableVideoTracks = new ArrayList<>();
|
editableVideoTracks = new ArrayList<>();
|
||||||
@ -205,7 +204,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
editableVideoMetadataCollector,
|
editableVideoMetadataCollector,
|
||||||
findMinimumPresentationTimestampUsAcrossTracks(editableVideoTracks),
|
findMinimumPresentationTimestampUsAcrossTracks(editableVideoTracks),
|
||||||
/* isFragmentedMp4= */ false,
|
/* isFragmentedMp4= */ false,
|
||||||
lastFrameDurationBehavior);
|
lastSampleDurationBehavior);
|
||||||
ByteBuffer edvdBoxHeader =
|
ByteBuffer edvdBoxHeader =
|
||||||
getEdvdBoxHeader(/* payloadSize= */ ftypBox.remaining() + moovBox.remaining());
|
getEdvdBoxHeader(/* payloadSize= */ ftypBox.remaining() + moovBox.remaining());
|
||||||
return BoxUtils.concatenateBuffers(edvdBoxHeader, ftypBox, moovBox);
|
return BoxUtils.concatenateBuffers(edvdBoxHeader, ftypBox, moovBox);
|
||||||
@ -323,7 +322,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
metadataCollector,
|
metadataCollector,
|
||||||
minInputPtsUs,
|
minInputPtsUs,
|
||||||
/* isFragmentedMp4= */ false,
|
/* isFragmentedMp4= */ false,
|
||||||
lastFrameDurationBehavior);
|
lastSampleDurationBehavior);
|
||||||
} else {
|
} else {
|
||||||
// Skip moov box, if there are no samples.
|
// Skip moov box, if there are no samples.
|
||||||
moovHeader = ByteBuffer.allocate(0);
|
moovHeader = ByteBuffer.allocate(0);
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.muxer;
|
package androidx.media3.muxer;
|
||||||
|
|
||||||
import static androidx.media3.muxer.Mp4Muxer.LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION;
|
import static androidx.media3.muxer.Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION;
|
||||||
import static androidx.media3.muxer.Mp4Muxer.LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME;
|
import static androidx.media3.muxer.Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE;
|
||||||
import static androidx.media3.muxer.MuxerTestUtil.FAKE_AUDIO_FORMAT;
|
import static androidx.media3.muxer.MuxerTestUtil.FAKE_AUDIO_FORMAT;
|
||||||
import static androidx.media3.muxer.MuxerTestUtil.FAKE_CSD_0;
|
import static androidx.media3.muxer.MuxerTestUtil.FAKE_CSD_0;
|
||||||
import static androidx.media3.muxer.MuxerTestUtil.FAKE_VIDEO_FORMAT;
|
import static androidx.media3.muxer.MuxerTestUtil.FAKE_VIDEO_FORMAT;
|
||||||
@ -477,7 +477,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
assertThat(durationsVu).containsExactly(0);
|
assertThat(durationsVu).containsExactly(0);
|
||||||
}
|
}
|
||||||
@ -493,7 +493,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
assertThat(durationsVu).containsExactly(0);
|
assertThat(durationsVu).containsExactly(0);
|
||||||
}
|
}
|
||||||
@ -509,7 +509,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
assertThat(durationsVu).containsExactly(3_000, 5_000, 0);
|
assertThat(durationsVu).containsExactly(3_000, 5_000, 0);
|
||||||
}
|
}
|
||||||
@ -525,7 +525,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION);
|
LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION);
|
||||||
|
|
||||||
assertThat(durationsVu).containsExactly(3_000, 5_000, 5_000);
|
assertThat(durationsVu).containsExactly(3_000, 5_000, 5_000);
|
||||||
}
|
}
|
||||||
@ -541,7 +541,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
assertThat(durationsVu).containsExactly(100, 100, 800, 100, 0);
|
assertThat(durationsVu).containsExactly(100, 100, 800, 100, 0);
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
||||||
|
|
||||||
@ -612,7 +612,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 0L,
|
/* firstSamplePresentationTimeUs= */ 0L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
||||||
|
|
||||||
@ -651,7 +651,7 @@ public class BoxesTest {
|
|||||||
sampleBufferInfos,
|
sampleBufferInfos,
|
||||||
/* firstSamplePresentationTimeUs= */ 23698215060L,
|
/* firstSamplePresentationTimeUs= */ 23698215060L,
|
||||||
VU_TIMEBASE,
|
VU_TIMEBASE,
|
||||||
LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME);
|
LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE);
|
||||||
|
|
||||||
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
ByteBuffer cttsBox = Boxes.ctts(sampleBufferInfos, durationsVu, VU_TIMEBASE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user