Need help with Mp4Composer-android?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

MasayukiSuda
689 Stars 161 Forks MIT License 194 Commits 21 Opened issues

Description

This library generate an Mp4 movie using Android MediaCodec API and apply filter, scale, trim, transcode, crop, timeScale, mute and rotate Mp4.

Services available

!
?

Need anything else?

Contributors list

# 20,572
Java
Android
interpo...
video-f...
113 commits
# 24,543
Java
Android
video-f...
video-c...
33 commits
# 212,202
Android
video-f...
video-t...
Swift
4 commits
# 270,128
HTML
CSS
Telegra...
video-c...
1 commit
# 95,194
Android
video-c...
video-t...
Groovy
1 commit
# 250,975
Java
Android
video-c...
video-t...
1 commit
# 330,571
Android
video-c...
video-t...
TypeScr...
1 commit

Mp4Composer-android

Platform API

This library generate an Mp4 movie using Android MediaCodec API and apply filter, scale, trim, transcode, crop, mute and rotate Mp4.
Idea from: android-transcoder


Sample Video
No filter

GlGlayScaleFilter
apply

GlMonochromeFilter
apply

GlWatermarkFilter
apply

Gradle

Step 1. Add the JitPack repository to your build file

groovy
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
Step 2. Add the dependency
groovy
dependencies {
        implementation 'com.github.MasayukiSuda:Mp4Composer-android:v0.4.1'
}

Usage

    new Mp4Composer(srcMp4Path, destMp4Path)
            .rotation(Rotation.ROTATION_90)
            .size((width) 540, (height) 960)
            .fillMode(FillMode.PRESERVE_ASPECT_FIT)
            .filter(new GlFilterGroup(new GlMonochromeFilter(), new GlVignetteFilter()))
            .trim((trimStartMs) 200, (trimEndMs) 5000)
            .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();

Builder Method

| method | description | |:---|:---| | rotation | Rotation of the movie, default Rotation.NORMAL | | size | Resolution of the movie, default same resolution of src movie. If you specify a resolution that MediaCodec does not support, an error will occur. | | fillMode | Options for scaling the bounds of an movie. PRESERVEASPECTFIT is fit center. PRESERVEASPECTCROP is center crop , default PRESERVEASPECTFIT.
FILLMODECUSTOM is used to crop a video. Check <a href="https://github.com/MasayukiSuda/Mp4Composer-android/blob/master/art/fillmodecustom.gif">this for behavior. Sample source code is this. | | 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
. | | trim | Trim both audio and video tracks to the provided start and end times, inclusive. Default does not trim anything from the start or end. | | flipVertical | Flip Vertical on exported video. Default
flipVertical = false
. | | flipHorizontal | Flip Horizontal on exported video. Default
flipHorizontal = false
. | | videoFormatMimeType | The mime type of the video format on exported video. default AUTO. Suppurt HEVC, AVC, MPEG4, H263. Check this. | | timeScale | Set TimeScale. default value is 1f. should be in range 0.125 (-8X) to 8.0 (8X) |

References And Special Thanks to

Sample Dependencies

License

MIT License

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.