Last active
October 24, 2023 15:18
-
-
Save prateek54/30250599fa5bd5fc9f0d430ad6589afc to your computer and use it in GitHub Desktop.
Method to Transform the video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val effect = arrayListOf<Effect>() | |
effect.add(RgbFilter.createGrayscaleFilter()) | |
effect.add(MatrixTransformationFactory.createZoomInTransition()) | |
effect.add(ScaleAndRotateTransformation.Builder().setRotationDegrees(90F).build()) | |
val transformer = with(Transformer.Builder(this)) { | |
addListener(object : Transformer.Listener { | |
override fun onCompleted(composition: Composition, exportResult: ExportResult) { | |
//Play the video from the path you specified below | |
} | |
override fun onError( | |
composition: Composition, | |
exportResult: ExportResult, | |
exportException: ExportException | |
) { | |
//Handle error scenarios | |
} | |
}) | |
build() | |
} | |
val inputMediaItem = MediaItem.fromUri(videoUrl) | |
val filePath = File(externalCacheDir, fileName) | |
val editedMediaItem = EditedMediaItem.Builder(inputMediaItem).apply { | |
setRemoveAudio(true) | |
setEffects(Effects(mutableListOf(), effect)) | |
} | |
transformer.start(editedMediaItem.build(), filePath.absolutePath) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment