MyGit

MasayukiSuda/Mp4Composer-android

Fork: 211 Star: 906 (更新于 1970-01-01 00:00:00)

license: MIT

Language: Java .

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

最后发布版本: v0.4.1 ( 2020-11-25 23:32:02)

GitHub网址

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

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

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. PRESERVE_ASPECT_FIT is fit center. PRESERVE_ASPECT_CROP is center crop , default PRESERVE_ASPECT_FIT.
FILLMODE_CUSTOM is used to crop a video. Check 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

最近版本更新:(数据更新于 1970-01-01 00:00:00)

2020-11-25 23:32:02 v0.4.1

2020-05-29 21:49:31 v0.4.0

2020-02-03 00:01:53 v0.3.9

2020-01-23 22:36:57 v0.3.8

2020-01-16 21:51:13 v0.3.7

2020-01-13 15:26:06 v0.3.6

2020-01-06 23:10:27 v0.3.5

2019-11-11 22:02:43 v0.3.4

2019-10-13 23:31:01 v0.3.3

2019-08-10 19:02:28 v0.3.2

主题(topics):

android, android-library, android-transcoder, crop-video, glsl-shader, h264, h265, mediacodec, opengles, shader, video-compressor, video-crop, video-editing, video-editor, video-filtering, video-processing, video-scaler, video-transcoding, video-trim, video-trimmer

MasayukiSuda/Mp4Composer-android同语言 Java最近更新仓库

2024-11-05 19:32:42 xiaojieonly/Ehviewer_CN_SXJ

2024-11-05 04:13:47 Stirling-Tools/Stirling-PDF

2024-11-04 02:03:13 exzhawk/EhViewer

2024-11-03 00:43:09 PBH-BTN/PeerBanHelper

2024-10-31 18:52:00 CodePhiliaX/Chat2DB

2024-10-31 11:19:43 mybatis-flex/mybatis-flex