Document that the MediaItem's image duration should be set for images
PiperOrigin-RevId: 678702334
This commit is contained in:
parent
2dc32360d6
commit
3ec9c99644
@ -49,6 +49,8 @@
|
||||
allow invoking events of subclass listeners
|
||||
([1736](https://github.com/androidx/media/pull/1736)).
|
||||
* Transformer:
|
||||
* Make setting the image duration using
|
||||
`MediaItem.Builder.setImageDurationMs` mandatory for image export.
|
||||
* Add export support for gaps in sequences of audio EditedMediaItems.
|
||||
* Track Selection:
|
||||
* Extractors:
|
||||
|
@ -16,15 +16,19 @@
|
||||
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.os.Looper;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.BitmapLoader;
|
||||
import androidx.media3.common.util.Clock;
|
||||
import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.datasource.DataSourceBitmapLoader;
|
||||
@ -39,6 +43,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@UnstableApi
|
||||
public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
|
||||
|
||||
private static final String TAG = "DefaultAssetLoaderFact";
|
||||
|
||||
// Limit decoded images to 4096x4096 - should be large enough for most image to video
|
||||
// transcode operations, and smaller than GL_MAX_TEXTURE_SIZE for most devices.
|
||||
// TODO: b/356072337 - consider reading this from GL_MAX_TEXTURE_SIZE. This requires an
|
||||
@ -136,6 +142,9 @@ public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
|
||||
CompositionSettings compositionSettings) {
|
||||
MediaItem mediaItem = editedMediaItem.mediaItem;
|
||||
if (isImage(mediaItem)) {
|
||||
if (checkNotNull(mediaItem.localConfiguration).imageDurationMs == C.TIME_UNSET) {
|
||||
Log.w(TAG, "The imageDurationMs field must be set on image MediaItems.");
|
||||
}
|
||||
if (imageAssetLoaderFactory == null) {
|
||||
imageAssetLoaderFactory = new ImageAssetLoader.Factory(context, bitmapLoader);
|
||||
}
|
||||
|
@ -50,10 +50,16 @@ public final class EditedMediaItem {
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* <p>For image inputs, the values passed into {@link #setRemoveAudio}, {@link #setRemoveVideo}
|
||||
* and {@link #setFlattenForSlowMotion} will be ignored. For multi-picture formats (e.g. gifs),
|
||||
* a single image frame from the container is displayed if the {@link DefaultAssetLoaderFactory}
|
||||
* is used.
|
||||
* <p>For image inputs:
|
||||
*
|
||||
* <ul>
|
||||
* <li>The {@linkplain MediaItem.Builder#setImageDurationMs(long) image duration} should
|
||||
* always be set.
|
||||
* <li>The values passed into {@link #setRemoveAudio}, {@link #setRemoveVideo} and {@link
|
||||
* #setFlattenForSlowMotion} will be ignored.
|
||||
* <li>For multi-picture formats (e.g. gifs), a single image frame from the container is
|
||||
* displayed if the {@link DefaultAssetLoaderFactory} is used.
|
||||
* </ul>
|
||||
*
|
||||
* @param mediaItem The {@link MediaItem} on which transformations are applied.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user