diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/EditingMetricsCollector.java b/libraries/transformer/src/main/java/androidx/media3/transformer/EditingMetricsCollector.java index ef0b1f3305..4ed0ed0b1f 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/EditingMetricsCollector.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/EditingMetricsCollector.java @@ -254,24 +254,28 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; MediaItemInfo.Builder mediaItemInfoBuilder = new MediaItemInfo.Builder(); long durationMs = usToMs(processedInput.durationUs); mediaItemInfoBuilder.setClipDurationMillis(durationMs); - Format format = processedInput.format; - if (format != null) { - if (format.containerMimeType != null) { - mediaItemInfoBuilder.setContainerMimeType(format.containerMimeType); + @Nullable Format videoFormat = processedInput.videoFormat; + if (videoFormat != null) { + if (videoFormat.containerMimeType != null) { + mediaItemInfoBuilder.setContainerMimeType(videoFormat.containerMimeType); } - if (format.sampleMimeType != null) { - mediaItemInfoBuilder.addSampleMimeType(format.sampleMimeType); + if (videoFormat.sampleMimeType != null) { + mediaItemInfoBuilder.addSampleMimeType(videoFormat.sampleMimeType); } - if (format.frameRate != Format.NO_VALUE) { - mediaItemInfoBuilder.setVideoFrameRate(format.frameRate); + if (videoFormat.frameRate != Format.NO_VALUE) { + mediaItemInfoBuilder.setVideoFrameRate(videoFormat.frameRate); } Size videoSize = new Size( - format.width != Format.NO_VALUE ? format.width : MediaItemInfo.VALUE_UNSPECIFIED, - format.height != Format.NO_VALUE ? format.height : MediaItemInfo.VALUE_UNSPECIFIED); + videoFormat.width != Format.NO_VALUE + ? videoFormat.width + : MediaItemInfo.VALUE_UNSPECIFIED, + videoFormat.height != Format.NO_VALUE + ? videoFormat.height + : MediaItemInfo.VALUE_UNSPECIFIED); mediaItemInfoBuilder.setVideoSize(videoSize); - if (format.colorInfo != null) { - ColorInfo colorInfo = format.colorInfo; + if (videoFormat.colorInfo != null) { + ColorInfo colorInfo = videoFormat.colorInfo; int colorStandard = DATA_SPACE_STANDARD_CONVERSION_MAP.get( colorInfo.colorSpace, DataSpace.STANDARD_UNSPECIFIED); diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/ExportResult.java b/libraries/transformer/src/main/java/androidx/media3/transformer/ExportResult.java index d1e6de94ec..f87cc643b4 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/ExportResult.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/ExportResult.java @@ -285,11 +285,14 @@ public final class ExportResult { /** The processed {@link MediaItem}. */ public final MediaItem mediaItem; - /** The duration of the media item, in microseconds. */ + /** The duration of the {@link MediaItem}, in microseconds. */ public final long durationUs; - /** The {@link Format} of the media item. */ - @Nullable public final Format format; + /** The audio {@link Format} of the {@link MediaItem}. */ + @Nullable public final Format audioFormat; + + /** The video {@link Format} of the {@link MediaItem}. */ + @Nullable public final Format videoFormat; /** * The name of the audio decoder used to process {@code mediaItem}. This field is {@code null} @@ -307,12 +310,14 @@ public final class ExportResult { public ProcessedInput( MediaItem mediaItem, long durationUs, - @Nullable Format format, + @Nullable Format audioFormat, + @Nullable Format videoFormat, @Nullable String audioDecoderName, @Nullable String videoDecoderName) { this.mediaItem = mediaItem; this.durationUs = durationUs; - this.format = format; + this.audioFormat = audioFormat; + this.videoFormat = videoFormat; this.audioDecoderName = audioDecoderName; this.videoDecoderName = videoDecoderName; } diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/SequenceAssetLoader.java b/libraries/transformer/src/main/java/androidx/media3/transformer/SequenceAssetLoader.java index 479d0faa42..5437b09a43 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/SequenceAssetLoader.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/SequenceAssetLoader.java @@ -98,7 +98,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; private boolean decodeVideo; private int sequenceLoopCount; private int processedInputsSize; - private @MonotonicNonNull Format currentInputFormat; + private @MonotonicNonNull Format currentAudioInputFormat; + private @MonotonicNonNull Format currentVideoInputFormat; // Accessed when switching asset loader. private volatile boolean released; @@ -195,7 +196,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; new ExportResult.ProcessedInput( mediaItem, currentAssetDurationUs, - currentInputFormat, + currentAudioInputFormat, + currentVideoInputFormat, decoders.get(C.TRACK_TYPE_AUDIO), decoders.get(C.TRACK_TYPE_VIDEO))); processedInputsSize++; @@ -234,7 +236,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; isAudio ? "audio" : "video", inputFormat); - currentInputFormat = inputFormat; + if (isAudio) { + currentAudioInputFormat = inputFormat; + } else { + currentVideoInputFormat = inputFormat; + } + if (!isCurrentAssetFirstAsset) { boolean decode = isAudio ? decodeAudio : decodeVideo; if (decode) {