Search in sources :

Example 31 with Transformer

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

the class TransformerEndToEndTest method startTransformation_removeVideo_completesSuccessfully.

@Test
public void startTransformation_removeVideo_completesSuccessfully() throws Exception {
    Transformer transformer = createTransformerBuilder().setRemoveVideo(true).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_VIDEO);
    transformer.startTransformation(mediaItem, outputPath);
    TransformerTestRunner.runUntilCompleted(transformer);
    DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO + ".novideo"));
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 32 with Transformer

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

the class TransformerEndToEndTest method startTransformation_videoOnlyPassthrough_completesSuccessfully.

@Test
public void startTransformation_videoOnlyPassthrough_completesSuccessfully() throws Exception {
    Transformer transformer = createTransformerBuilder().build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_VIDEO_ONLY);
    transformer.startTransformation(mediaItem, outputPath);
    TransformerTestRunner.runUntilCompleted(transformer);
    DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_VIDEO_ONLY));
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 33 with Transformer

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

the class TransformerEndToEndTest method startTransformation_withVideoEncoderFormatUnsupported_completesWithError.

@Test
public void startTransformation_withVideoEncoderFormatUnsupported_completesWithError() throws Exception {
    Transformer transformer = createTransformerBuilder().setTransformationRequest(new TransformationRequest.Builder().setVideoMimeType(// unsupported encoder MIME type
    MimeTypes.VIDEO_H263).build()).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_VIDEO_ONLY);
    transformer.startTransformation(mediaItem, outputPath);
    TransformationException exception = TransformerTestRunner.runUntilError(transformer);
    assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
    assertThat(exception.errorCode).isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 34 with Transformer

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

the class TransformerEndToEndTest method startTransformation_withAudioDecoderFormatUnsupported_completesWithError.

@Test
public void startTransformation_withAudioDecoderFormatUnsupported_completesWithError() throws Exception {
    Transformer transformer = createTransformerBuilder().setTransformationRequest(new TransformationRequest.Builder().setAudioMimeType(// supported by encoder and muxer
    MimeTypes.AUDIO_AAC).build()).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_DECODER);
    transformer.startTransformation(mediaItem, outputPath);
    TransformationException exception = TransformerTestRunner.runUntilError(transformer);
    assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
    assertThat(exception.errorCode).isEqualTo(TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 35 with Transformer

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

the class TransformerEndToEndTest method startTransformation_flattenForSlowMotion_completesSuccessfully.

@Test
public void startTransformation_flattenForSlowMotion_completesSuccessfully() throws Exception {
    Transformer transformer = createTransformerBuilder().setTransformationRequest(new TransformationRequest.Builder().setFlattenForSlowMotion(true).build()).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_WITH_SEF_SLOW_MOTION);
    transformer.startTransformation(mediaItem, outputPath);
    TransformerTestRunner.runUntilCompleted(transformer);
    DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_WITH_SEF_SLOW_MOTION));
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) 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