Search in sources :

Example 51 with Transformer

use of androidx.media3.transformer.Transformer in project ExoPlayer by google.

the class RepeatedTranscodeTransformationTest method repeatedTranscodeNoVideo_givesConsistentLengthOutput.

@Test
public void repeatedTranscodeNoVideo_givesConsistentLengthOutput() throws Exception {
    Context context = ApplicationProvider.getApplicationContext();
    Transformer transformer = new Transformer.Builder(context).setRemoveVideo(true).setTransformationRequest(new TransformationRequest.Builder().setAudioMimeType(MimeTypes.AUDIO_AMR_NB).build()).build();
    Set<Long> differentOutputSizesBytes = new HashSet<>();
    for (int i = 0; i < TRANSCODE_COUNT; i++) {
        // Use a long video in case an error occurs a while after the start of the video.
        AndroidTestUtil.TransformationResult result = runTransformer(context, /* testId= */
        "repeatedTranscodeNoVideo_givesConsistentLengthOutput_" + i, transformer, AndroidTestUtil.REMOTE_MP4_10_SECONDS_URI_STRING, /* timeoutSeconds= */
        120);
        differentOutputSizesBytes.add(Assertions.checkNotNull(result.fileSizeBytes));
    }
    assertWithMessage("Different transcoding output sizes detected. Sizes: " + differentOutputSizesBytes).that(differentOutputSizesBytes.size()).isEqualTo(1);
}
Also used : Context(android.content.Context) AndroidTestUtil(com.google.android.exoplayer2.transformer.AndroidTestUtil) Transformer(com.google.android.exoplayer2.transformer.Transformer) AndroidTestUtil.runTransformer(com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)45 MediaItem (androidx.media3.common.MediaItem)29 Context (android.content.Context)18 AndroidTestUtil.runTransformer (androidx.media3.transformer.AndroidTestUtil.runTransformer)10 Transformer (androidx.media3.transformer.Transformer)10 Transformer (com.google.android.exoplayer2.transformer.Transformer)10 Matrix (android.graphics.Matrix)9 AndroidTestUtil.runTransformer (com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer)8 Handler (android.os.Handler)7 HashSet (java.util.HashSet)7 Nullable (androidx.annotation.Nullable)5 IOException (java.io.IOException)5 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)4 Uri (android.net.Uri)3 Message (android.os.Message)3 AndroidTestUtil (androidx.media3.transformer.AndroidTestUtil)3 AndroidTestUtil (com.google.android.exoplayer2.transformer.AndroidTestUtil)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3