use of androidx.media3.transformer.Transformer in project ExoPlayer by google.
the class TransformerActivity method startTransformation.
@RequiresNonNull({ "playerView", "debugTextView", "informationTextView", "progressIndicator", "transformationStopwatch", "progressViewGroup", "debugFrame" })
private void startTransformation() {
requestTransformerPermission();
Intent intent = getIntent();
Uri uri = checkNotNull(intent.getData());
try {
externalCacheFile = createExternalCacheFile("transformer-output.mp4");
String filePath = externalCacheFile.getAbsolutePath();
@Nullable Bundle bundle = intent.getExtras();
Transformer transformer = createTransformer(bundle, filePath);
transformationStopwatch.start();
transformer.startTransformation(MediaItem.fromUri(uri), filePath);
this.transformer = transformer;
} catch (IOException e) {
throw new IllegalStateException(e);
}
informationTextView.setText(R.string.transformation_started);
playerView.setVisibility(View.GONE);
Handler mainHandler = new Handler(getMainLooper());
ProgressHolder progressHolder = new ProgressHolder();
mainHandler.post(new Runnable() {
@Override
public void run() {
if (transformer != null && transformer.getProgress(progressHolder) != Transformer.PROGRESS_STATE_NO_TRANSFORMATION) {
progressIndicator.setProgress(progressHolder.progress);
informationTextView.setText(getString(R.string.transformation_timer, transformationStopwatch.elapsed(TimeUnit.SECONDS)));
mainHandler.postDelayed(/* r= */
this, /* delayMillis= */
500);
}
}
});
}
use of androidx.media3.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);
}
use of androidx.media3.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);
}
use of androidx.media3.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);
}
use of androidx.media3.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);
}
Aggregations