This library generate an Mp4 movie using Android MediaCodec API and apply filter, scale, and rotate Mp4.
Idea from: android-transcoder
Sample Video No filter |
GlGlayScaleFilter apply |
GlMonochromeFilter apply |
GlWatermarkFilter apply |
dependencies {
// jCenter
implementation 'com.daasuu:Mp4Composer-android:0.1.5'
}
new Mp4Composer(srcMp4Path, destMp4Path)
.rotation(Rotation.ROTATION_90)
.size((width) 540, (height) 960)
.fillMode(FillMode.PRESERVE_ASPECT_FIT)
.filter(new GlSepiaFilter())
.listener(new Mp4Composer.Listener() {
@Override
public void onProgress(double progress) {
Log.d(TAG, "onProgress = " + progress);
}
@Override
public void onCompleted() {
Log.d(TAG, "onCompleted()");
runOnUiThread(() -> {
Toast.makeText(context, "codec complete path =" + destPath, Toast.LENGTH_SHORT).show();
});
}
@Override
public void onCanceled() {
Log.d(TAG, "onCanceled");
}
@Override
public void onFailed(Exception exception) {
Log.e(TAG, "onFailed()", exception);
}
})
.start();
method | description |
---|---|
rotation | Rotation of the movie, default Rotation.NORMAL |
size | Resolution of the movie, default same resolution of src movie |
fillMode | Options for scaling the bounds of an movie. PRESERVE_ASPECT_FIT is fit center. PRESERVE_ASPECT_CROP is center crop , default PRESERVE_ASPECT_FIT |
filter | This filter is OpenGL Shaders to apply effects on video. Custom filters can be created by inheriting GlFilter.java. , default GlFilter(No filter). Filters is here. |
videoBitrate | Set Video Bitrate, default video bitrate is 0.25 * 30 * outputWidth * outputHeight |
mute | Mute audio track on exported video. Default mute = false . |
flipVertical | Flip Vertical on exported video. Default flipVertical = false . |
flipHorizontal | Flip Horizontal on exported video. Default flipHorizontal = false . |