Add mediaItem durationUs to Transformer's ExportResult.ProcessedInput

This will allow us to access the duration of the input media items and collect them for metrics.

PiperOrigin-RevId: 713686613
This commit is contained in:
shahddaghash 2025-01-09 08:45:46 -08:00 committed by Copybara-Service
parent b225383958
commit 64462b99fc
2 changed files with 12 additions and 2 deletions

View File

@ -284,6 +284,9 @@ public final class ExportResult {
/** The processed {@link MediaItem}. */
public final MediaItem mediaItem;
/** The duration of the media item, in microseconds. */
public final long durationUs;
/**
* The name of the audio decoder used to process {@code mediaItem}. This field is {@code null}
* if no audio decoder was used.
@ -298,8 +301,12 @@ public final class ExportResult {
/** Creates an instance. */
public ProcessedInput(
MediaItem mediaItem, @Nullable String audioDecoderName, @Nullable String videoDecoderName) {
MediaItem mediaItem,
long durationUs,
@Nullable String audioDecoderName,
@Nullable String videoDecoderName) {
this.mediaItem = mediaItem;
this.durationUs = durationUs;
this.audioDecoderName = audioDecoderName;
this.videoDecoderName = videoDecoderName;
}

View File

@ -191,7 +191,10 @@ import java.util.concurrent.atomic.AtomicInteger;
ImmutableMap<Integer, String> decoders = getDecoderNames();
processedInputsBuilder.add(
new ExportResult.ProcessedInput(
mediaItem, decoders.get(C.TRACK_TYPE_AUDIO), decoders.get(C.TRACK_TYPE_VIDEO)));
mediaItem,
currentAssetDurationUs,
decoders.get(C.TRACK_TYPE_AUDIO),
decoders.get(C.TRACK_TYPE_VIDEO)));
processedInputsSize++;
}
}