Search in sources :

Example 16 with Transformer

use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.

the class RepeatedTranscodeTransformationTest method repeatedTranscodeNoAudio_givesConsistentLengthOutput.

@Test
public void repeatedTranscodeNoAudio_givesConsistentLengthOutput() throws Exception {
    Context context = ApplicationProvider.getApplicationContext();
    Matrix transformationMatrix = new Matrix();
    transformationMatrix.postTranslate((float) 0.1, (float) 0.1);
    Transformer transformer = new Transformer.Builder(context).setRemoveAudio(true).setTransformationRequest(new TransformationRequest.Builder().setVideoMimeType(MimeTypes.VIDEO_H265).setTransformationMatrix(transformationMatrix).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= */
        "repeatedTranscodeNoAudio_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) Matrix(android.graphics.Matrix) Transformer(com.google.android.exoplayer2.transformer.Transformer) AndroidTestUtil.runTransformer(com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer) TransformationRequest(com.google.android.exoplayer2.transformer.TransformationRequest) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with Transformer

use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.

the class SetTransformationMatrixTransformationTest method setTransformationMatrixTransform.

@Test
public void setTransformationMatrixTransform() throws Exception {
    Context context = ApplicationProvider.getApplicationContext();
    Matrix transformationMatrix = new Matrix();
    transformationMatrix.postTranslate(/* dx= */
    .2f, /* dy= */
    .1f);
    Transformer transformer = new Transformer.Builder(context).setTransformationRequest(new TransformationRequest.Builder().setTransformationMatrix(transformationMatrix).build()).build();
    runTransformer(context, /* testId= */
    "setTransformationMatrixTransform", transformer, REMOTE_MP4_10_SECONDS_URI_STRING, /* timeoutSeconds= */
    120);
}
Also used : Context(android.content.Context) Matrix(android.graphics.Matrix) AndroidTestUtil.runTransformer(com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer) Transformer(com.google.android.exoplayer2.transformer.Transformer) Test(org.junit.Test)

Example 18 with Transformer

use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.

the class TransformerEndToEndTest method videoTranscoding_completesWithConsistentFrameCount.

@Test
public void videoTranscoding_completesWithConsistentFrameCount() throws Exception {
    Context context = ApplicationProvider.getApplicationContext();
    FrameCountingMuxer.Factory muxerFactory = new FrameCountingMuxer.Factory(new FrameworkMuxer.Factory());
    Transformer transformer = new Transformer.Builder(context).setTransformationRequest(new TransformationRequest.Builder().setVideoMimeType(MimeTypes.VIDEO_H264).build()).setMuxerFactory(muxerFactory).build();
    // Result of the following command:
    // ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames bear-vp9.webm
    int expectedFrameCount = 82;
    runTransformer(context, /* testId= */
    "videoTranscoding_completesWithConsistentFrameCount", transformer, VP9_VIDEO_URI_STRING, /* timeoutSeconds= */
    120);
    FrameCountingMuxer frameCountingMuxer = checkNotNull(muxerFactory.getLastFrameCountingMuxerCreated());
    assertThat(frameCountingMuxer.getFrameCount()).isEqualTo(expectedFrameCount);
}
Also used : Context(android.content.Context) AndroidTestUtil.runTransformer(com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer) Test(org.junit.Test)

Example 19 with Transformer

use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.

the class SefTransformationTest method sefTransform.

@Test
public void sefTransform() throws Exception {
    Context context = ApplicationProvider.getApplicationContext();
    Transformer transformer = new Transformer.Builder(context).setTransformationRequest(new TransformationRequest.Builder().setFlattenForSlowMotion(true).build()).build();
    runTransformer(context, /* testId = */
    "sefTransform", transformer, SEF_ASSET_URI_STRING, /* timeoutSeconds= */
    120);
}
Also used : Context(android.content.Context) AndroidTestUtil.runTransformer(com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer) Transformer(com.google.android.exoplayer2.transformer.Transformer) Test(org.junit.Test)

Example 20 with Transformer

use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.

the class TransformationTest method transform.

@Test
public void transform() throws Exception {
    Context context = ApplicationProvider.getApplicationContext();
    Transformer transformer = new Transformer.Builder(context).build();
    runTransformer(context, /* testId= */
    "transform", transformer, MP4_ASSET_URI_STRING, /* timeoutSeconds= */
    120);
}
Also used : Context(android.content.Context) AndroidTestUtil.runTransformer(com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer) Transformer(com.google.android.exoplayer2.transformer.Transformer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)37 MediaItem (com.google.android.exoplayer2.MediaItem)29 Context (android.content.Context)10 AndroidTestUtil.runTransformer (com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer)10 Transformer (com.google.android.exoplayer2.transformer.Transformer)10 Handler (android.os.Handler)6 Matrix (android.graphics.Matrix)5 IOException (java.io.IOException)4 Message (android.os.Message)3 Nullable (androidx.annotation.Nullable)3 AndroidTestUtil (com.google.android.exoplayer2.transformer.AndroidTestUtil)3 HashSet (java.util.HashSet)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 Uri (android.net.Uri)2 HandlerThread (android.os.HandlerThread)2 TransformationRequest (com.google.android.exoplayer2.transformer.TransformationRequest)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)2