Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

MasayukiSuda/Mp4Composer-android

Repository files navigation

PlatformAPI

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

allprojects {repositories {...maven { url'https://jitpack.io' }}}

Step 2. Add the dependency

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

methoddescription
rotationRotation of the movie, default Rotation.NORMAL
sizeResolution of the movie, default same resolution of src movie. If you specify a resolution that MediaCodec does not support, an error will occur.
fillModeOptions for scaling the bounds of an movie. PRESERVE_ASPECT_FIT is fit center. PRESERVE_ASPECT_CROP is center crop , default PRESERVE_ASPECT_FIT.
FILLMODE_CUSTOM is used to crop a video. Checkthis for behavior. Sample source code isthis.
filterThis filter is OpenGL Shaders to apply effects on video. Custom filters can be created by inheritingGlFilter.java. , default GlFilter(No filter). Filters ishere.
videoBitrateSet Video Bitrate, default video bitrate is 0.25 * 30 * outputWidth * outputHeight
muteMute audio track on exported video. Defaultmute = false.
trimTrim both audio and video tracks to the provided start and end times, inclusive. Default does not trim anything from the start or end.
flipVerticalFlip Vertical on exported video. DefaultflipVertical = false.
flipHorizontalFlip Horizontal on exported video. DefaultflipHorizontal = false.
videoFormatMimeTypeThe mime type of the video format on exported video. default AUTO. Suppurt HEVC, AVC, MPEG4, H263. Checkthis.
timeScaleSet 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


[8]ページ先頭

©2009-2025 Movatter.jp