├── .github
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── custom.md
│ └── feature_request.md
├── .gitignore
├── .idea
├── .name
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── jarRepositories.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── PULL_REQUEST_TEMPLATE.md
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── fahimfarhan
│ │ └── simplevideoeditor
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ │ ├── CMakeLists.txt
│ │ └── yuv-decoder.c
│ ├── ic_launcher-playstore.png
│ ├── java
│ │ └── com
│ │ │ └── fahimfarhan
│ │ │ └── simplevideoeditor
│ │ │ ├── MainActivity.java
│ │ │ ├── customview
│ │ │ ├── AwesomeVideoView.java
│ │ │ ├── GLGestureView.java
│ │ │ ├── RoundCornerImageView.java
│ │ │ └── SimpleCropView.java
│ │ │ ├── gpuimage
│ │ │ ├── BitmapToUri.java
│ │ │ ├── GLTextureView.java
│ │ │ ├── GPUImage.java
│ │ │ ├── GPUImageFilterTools.kt
│ │ │ ├── GPUImageNativeLibrary.java
│ │ │ ├── GPUImageRenderer.java
│ │ │ ├── GPUImageView.java
│ │ │ ├── PixelBuffer.java
│ │ │ ├── gpufilter
│ │ │ │ ├── GPUImage3x3TextureSamplingFilter.java
│ │ │ │ ├── GPUImageBilateralBlurFilter.java
│ │ │ │ ├── GPUImageBoxBlurFilter.java
│ │ │ │ ├── GPUImageBrightnessFilter.java
│ │ │ │ ├── GPUImageBulgeDistortionFilter.java
│ │ │ │ ├── GPUImageCGAColorspaceFilter.java
│ │ │ │ ├── GPUImageColorInvertFilter.java
│ │ │ │ ├── GPUImageColorMatrixFilter.java
│ │ │ │ ├── GPUImageContrastFilter.java
│ │ │ │ ├── GPUImageCrosshatchFilter.java
│ │ │ │ ├── GPUImageDirectionalSobelEdgeDetectionFilter.java
│ │ │ │ ├── GPUImageExposureFilter.java
│ │ │ │ ├── GPUImageFilter.java
│ │ │ │ ├── GPUImageFilterGroup.java
│ │ │ │ ├── GPUImageGammaFilter.java
│ │ │ │ ├── GPUImageGaussianBlurFilter.java
│ │ │ │ ├── GPUImageGrayscaleFilter.java
│ │ │ │ ├── GPUImageHalftoneFilter.java
│ │ │ │ ├── GPUImageHazeFilter.java
│ │ │ │ ├── GPUImageHighlightShadowFilter.java
│ │ │ │ ├── GPUImageHueFilter.java
│ │ │ │ ├── GPUImageLuminanceFilter.java
│ │ │ │ ├── GPUImageLuminanceThresholdFilter.java
│ │ │ │ ├── GPUImageMonochromeFilter.java
│ │ │ │ ├── GPUImageOpacityFilter.java
│ │ │ │ ├── GPUImageOverlayBlendFilter.java
│ │ │ │ ├── GPUImagePixelationFilter.java
│ │ │ │ ├── GPUImagePosterizeFilter.java
│ │ │ │ ├── GPUImageRGBFilter.java
│ │ │ │ ├── GPUImageSaturationFilter.java
│ │ │ │ ├── GPUImageSepiaToneFilter.java
│ │ │ │ ├── GPUImageSharpenFilter.java
│ │ │ │ ├── GPUImageSolarizeFilter.java
│ │ │ │ ├── GPUImageSphereRefractionFilter.java
│ │ │ │ ├── GPUImageSwirlFilter.java
│ │ │ │ ├── GPUImageToneCurveFilter.java
│ │ │ │ ├── GPUImageTwoInputFilter.java
│ │ │ │ ├── GPUImageTwoPassFilter.java
│ │ │ │ ├── GPUImageTwoPassTextureSamplingFilter.java
│ │ │ │ ├── GPUImageVibranceFilter.java
│ │ │ │ ├── GPUImageVignetteFilter.java
│ │ │ │ ├── GPUImageWeakPixelInclusionFilter.java
│ │ │ │ ├── GPUImageWhiteBalanceFilter.java
│ │ │ │ └── GPUImageZoomBlurFilter.java
│ │ │ └── utils
│ │ │ │ ├── OpenGlUtils.java
│ │ │ │ ├── Rotation.java
│ │ │ │ └── TextureRotationUtil.java
│ │ │ ├── mp4composer
│ │ │ ├── PathUtil.java
│ │ │ ├── guestures
│ │ │ │ ├── AllGestureDetector.java
│ │ │ │ ├── DragGestureDetector.java
│ │ │ │ ├── GesturePlayerTextureView.java
│ │ │ │ ├── PinchGestureDetector.java
│ │ │ │ ├── PlayerTextureView.java
│ │ │ │ ├── PortraitView.java
│ │ │ │ └── RotateGestureDetector.java
│ │ │ └── mp4compose
│ │ │ │ ├── FillMode.java
│ │ │ │ ├── FillModeCustomItem.java
│ │ │ │ ├── FilterAdjuster.java
│ │ │ │ ├── FilterType.java
│ │ │ │ ├── Rotation.java
│ │ │ │ ├── SampleType.java
│ │ │ │ ├── VideoFormatMimeType.java
│ │ │ │ ├── composer
│ │ │ │ ├── AudioChannel.java
│ │ │ │ ├── AudioComposer.java
│ │ │ │ ├── DecoderSurface.java
│ │ │ │ ├── EncoderSurface.java
│ │ │ │ ├── IAudioComposer.java
│ │ │ │ ├── Mp4Composer.java
│ │ │ │ ├── Mp4ComposerEngine.java
│ │ │ │ ├── MuxRender.java
│ │ │ │ ├── RemixAudioComposer.java
│ │ │ │ └── VideoComposer.java
│ │ │ │ ├── filter
│ │ │ │ ├── GlBilateralFilter.java
│ │ │ │ ├── GlBoxBlurFilter.java
│ │ │ │ ├── GlBrightnessFilter.java
│ │ │ │ ├── GlBulgeDistortionFilter.java
│ │ │ │ ├── GlCGAColorspaceFilter.java
│ │ │ │ ├── GlContrastFilter.java
│ │ │ │ ├── GlCrosshatchFilter.java
│ │ │ │ ├── GlExposureFilter.java
│ │ │ │ ├── GlFilter.java
│ │ │ │ ├── GlFilterGroup.java
│ │ │ │ ├── GlGammaFilter.java
│ │ │ │ ├── GlGaussianBlurFilter.java
│ │ │ │ ├── GlGrayScaleFilter.java
│ │ │ │ ├── GlHalftoneFilter.java
│ │ │ │ ├── GlHazeFilter.java
│ │ │ │ ├── GlHighlightShadowFilter.java
│ │ │ │ ├── GlHueFilter.java
│ │ │ │ ├── GlInvertFilter.java
│ │ │ │ ├── GlLookUpTableFilter.java
│ │ │ │ ├── GlLuminanceFilter.java
│ │ │ │ ├── GlLuminanceThresholdFilter.java
│ │ │ │ ├── GlLut512Filter.java
│ │ │ │ ├── GlLutFilter.java
│ │ │ │ ├── GlMonochromeFilter.java
│ │ │ │ ├── GlOpacityFilter.java
│ │ │ │ ├── GlOverlayFilter.java
│ │ │ │ ├── GlPixelationFilter.java
│ │ │ │ ├── GlPosterizeFilter.java
│ │ │ │ ├── GlRGBFilter.java
│ │ │ │ ├── GlSaturationFilter.java
│ │ │ │ ├── GlSepiaFilter.java
│ │ │ │ ├── GlSharpenFilter.java
│ │ │ │ ├── GlSolarizeFilter.java
│ │ │ │ ├── GlSphereRefractionFilter.java
│ │ │ │ ├── GlSwirlFilter.java
│ │ │ │ ├── GlThreex3TextureSamplingFilter.java
│ │ │ │ ├── GlToneCurveFilter.java
│ │ │ │ ├── GlToneFilter.java
│ │ │ │ ├── GlVibranceFilter.java
│ │ │ │ ├── GlVignetteFilter.java
│ │ │ │ ├── GlWatermarkFilter.java
│ │ │ │ ├── GlWeakPixelInclusionFilter.java
│ │ │ │ ├── GlWhiteBalanceFilter.java
│ │ │ │ └── GlZoomBlurFilter.java
│ │ │ │ ├── gl
│ │ │ │ ├── DefaultConfigChooser.java
│ │ │ │ ├── DefaultContextFactory.java
│ │ │ │ ├── GlBitmapOverlaySample.java
│ │ │ │ ├── GlConfigChooser.java
│ │ │ │ ├── GlContextFactory.java
│ │ │ │ ├── GlFrameBufferObjectRenderer.java
│ │ │ │ ├── GlFramebufferObject.java
│ │ │ │ ├── GlPixelationFilter.java
│ │ │ │ ├── GlPreview.java
│ │ │ │ ├── GlPreviewFilter.java
│ │ │ │ ├── GlPreviewRenderer.java
│ │ │ │ └── GlSurfaceTexture.java
│ │ │ │ ├── glplayer
│ │ │ │ ├── GPUPlayerRenderer.java
│ │ │ │ ├── GPUPlayerView.java
│ │ │ │ ├── GestureGpuPlayerView.java
│ │ │ │ └── PlayerScaleType.java
│ │ │ │ ├── logger
│ │ │ │ ├── AndroidLogger.java
│ │ │ │ └── Logger.java
│ │ │ │ ├── source
│ │ │ │ ├── DataSource.java
│ │ │ │ ├── FileDescriptorDataSource.java
│ │ │ │ ├── FilePathDataSource.java
│ │ │ │ └── UriDataSource.java
│ │ │ │ └── utils
│ │ │ │ └── EglUtil.java
│ │ │ ├── start
│ │ │ └── StartFragment.java
│ │ │ └── videoeditor
│ │ │ ├── EditOptionsAdapter.java
│ │ │ ├── FilterOptionsAdapter.java
│ │ │ ├── VideoEditModel.java
│ │ │ ├── VideoEditorContract.java
│ │ │ ├── VideoEditorFragment2.java
│ │ │ ├── VideoEditorPresenter.java
│ │ │ └── WaitingFragment.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_fiber_circle_white_24dp.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_launcher_foreground.xml
│ │ ├── ic_movie_black_24dp.xml
│ │ ├── ic_smile_heart_eyes.png
│ │ ├── ic_video_effects.xml
│ │ ├── ic_video_format.xml
│ │ ├── ic_video_trim.xml
│ │ ├── lookup_sample.png
│ │ ├── mountain.png
│ │ ├── round_edit_option_notselected.xml
│ │ ├── round_edit_option_selected.xml
│ │ ├── sample_bitmap.jpg
│ │ ├── video_crop_btn.xml
│ │ ├── video_crop_notselected.xml
│ │ └── video_crop_selected.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── awesome_video_view.xml
│ │ ├── filter_preview_video_item.xml
│ │ ├── fragment_start.xml
│ │ ├── fragment_video_waiting.xml
│ │ ├── fragment_videoeditor2.xml
│ │ ├── toolbar.xml
│ │ ├── video_edit_options_item.xml
│ │ ├── video_layout_filter.xml
│ │ ├── video_layout_format.xml
│ │ ├── video_layout_trim.xml
│ │ └── video_layout_waiting.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── raw
│ │ └── tone_cuver_sample.acv
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── fahimfarhan
│ └── simplevideoeditor
│ └── ExampleUnitTest.java
├── build.gradle
├── docs
└── crop.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── start
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── app
│ │ └── fahimfarhan
│ │ └── start
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── app
│ │ │ └── fahimfarhan
│ │ │ └── start
│ │ │ └── StartActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_start.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── app
│ └── fahimfarhan
│ └── start
│ └── ExampleUnitTest.java
└── startjitpack
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── app
│ └── fahimfarhan
│ └── startjitpack
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── app
│ │ └── fahimfarhan
│ │ └── startjitpack
│ │ └── MainActivity.java
└── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ └── activity_main2.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
└── test
└── java
└── app
└── fahimfarhan
└── startjitpack
└── ExampleUnitTest.java
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | When contributing to this repository, please first discuss the change you wish to make via issue,
4 | email, or any other method with the owners of this repository before making a change.
5 |
6 | Please note we have a code of conduct, please follow it in all your interactions with the project.
7 |
8 | ## Pull Request Process
9 |
10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11 | build.
12 | 2. Update the README.md with details of changes to the interface, this includes new environment
13 | variables, exposed ports, useful file locations and container parameters.
14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this
15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16 | 4. ( For normal projects ) I review the changes. If I find them okay, I'll merge them in.
17 | 5. ( For group projects ) You may merge the Pull Request in once you have the sign-off of two other developers, or if you
18 | do not have permission to do that, you may request the second reviewer to merge it for you.
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | SImpleVideoEditor
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Qazi Fahim Farhan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 | Please ensure your pull request adheres to the following guidelines:
3 |
4 | - [ ] Use the following format: `* [owner/repo](link)`
5 | - [ ] Link additions should be added to the bottom of the relevant category.
6 | - [ ] New categories or improvements to the existing categorization are welcome.
7 | - [ ] Search previous suggestions before making a new one, as yours may be a duplicate.
8 | - [ ] Sort by alphabetical order
9 |
10 | Thanks for contributing!
11 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.3"
8 |
9 | defaultConfig {
10 | // applicationId "com.fahimfarhan.simplevideoeditor"
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 |
18 | externalNativeBuild {
19 | cmake { cppFlags "" }
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | externalNativeBuild {
31 | cmake { path "src/main/cpp/CMakeLists.txt" }
32 | }
33 |
34 | compileOptions {
35 | sourceCompatibility JavaVersion.VERSION_1_8
36 | targetCompatibility JavaVersion.VERSION_1_8
37 | }
38 |
39 | }
40 |
41 | dependencies {
42 | implementation fileTree(dir: 'libs', include: ['*.jar'])
43 |
44 | implementation 'androidx.appcompat:appcompat:1.1.0'
45 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
46 | testImplementation 'junit:junit:4.12'
47 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
48 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
49 | implementation "androidx.core:core-ktx:1.2.0"
50 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51 | // exoplayer
52 | implementation 'com.google.android.exoplayer:exoplayer:2.11.1'
53 | // recyclerview
54 | implementation "androidx.recyclerview:recyclerview:1.2.0-alpha03"
55 | // videotrimmer ui
56 | implementation 'com.github.freddyfang:android-video-trimmer:v1.0.0'
57 | }
58 | repositories {
59 | mavenCentral()
60 | }
61 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/fahimfarhan/simplevideoeditor/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.fahimfarhan.simplevideoeditor", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | yuv-decoder
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | yuv-decoder.c)
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log)
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | yuv-decoder
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib}
45 | GLESv2
46 | jnigraphics)
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/customview/GLGestureView.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.customview;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 |
8 | import com.fahimfarhan.simplevideoeditor.mp4composer.guestures.AllGestureDetector;
9 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.glplayer.GPUPlayerView;
10 |
11 |
12 | public class GLGestureView extends GPUPlayerView implements View.OnTouchListener {
13 | private AllGestureDetector allGestureDetector;
14 | boolean isTouchEnagled = true;
15 | private OnSizeChangeListener listener;
16 |
17 | public GLGestureView(Context context) {
18 | // super(context);
19 | this(context,null);
20 | }
21 |
22 | public GLGestureView(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | this.allGestureDetector = new AllGestureDetector(this);
25 | allGestureDetector.setLimitScaleMin(0.1f);
26 | allGestureDetector.noRotate();
27 | allGestureDetector.setLimitScaleMax(2f);
28 | isTouchEnagled = true;
29 | this.setOnTouchListener(this);
30 | }
31 |
32 | public void setTouchEnagled(boolean isTouchEnagled) { this.isTouchEnagled = isTouchEnagled; }
33 |
34 |
35 | @Override
36 | public boolean onTouch(View v, MotionEvent event) {
37 | if(isTouchEnagled){
38 | this.allGestureDetector.onTouch(event);
39 | return true;
40 | }
41 | return false;
42 | }
43 |
44 | @Override
45 | public void onSurfaceSizeChanged(int width, int height) {
46 | super.onSurfaceSizeChanged(width,height);
47 | }
48 |
49 | @Override
50 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
51 | super.onSizeChanged(w, h, oldw, oldh);
52 | if(this.listener !=null) listener.doOnSizeChange(w,h, oldw, oldh); // if nothing happens, try with onSurfaceSIzeCHanged
53 | }
54 |
55 | public void setOnSizeChangeListener(OnSizeChangeListener listener1) { this.listener = listener1; }
56 |
57 | public interface OnSizeChangeListener{
58 | void doOnSizeChange(int width, int height, int oldwidth, int oldheight);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/customview/RoundCornerImageView.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.customview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Path;
7 | import android.graphics.RectF;
8 | import android.util.AttributeSet;
9 |
10 | import androidx.annotation.Nullable;
11 |
12 | public class RoundCornerImageView extends androidx.appcompat.widget.AppCompatImageView {
13 |
14 | public static float radius = 18.0f;
15 |
16 | public RoundCornerImageView(Context context) {
17 | super(context);
18 | }
19 |
20 | public RoundCornerImageView(Context context, @Nullable AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public RoundCornerImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
25 | super(context, attrs, defStyleAttr);
26 | }
27 |
28 | @Override
29 | protected void onDraw(Canvas canvas) {
30 | //float radius = 36.0f;
31 | Path clipPath = new Path();
32 | RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
33 | clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
34 | canvas.clipPath(clipPath);
35 | // canvas.drawColor(Color.BLACK);
36 | super.onDraw(canvas);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/BitmapToUri.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.gpuimage;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.net.Uri;
6 | import android.provider.MediaStore;
7 |
8 | import java.io.ByteArrayOutputStream;
9 | import java.io.IOException;
10 | import java.io.OutputStream;
11 |
12 | public class BitmapToUri {
13 | private static final String VIDEO_THUMBNAIL_TITLE = "VIDEO_THUMBNAIL_TITLE";
14 | public static Uri getImageUriFromBitmap(Context context, Bitmap bitmap){
15 | OutputStream bytesOutputStream = new ByteArrayOutputStream();
16 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytesOutputStream);
17 | try {
18 | bytesOutputStream.close();
19 | } catch (IOException e) { e.printStackTrace(); }
20 |
21 | String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, VIDEO_THUMBNAIL_TITLE, null);
22 | return Uri.parse(path.toString());
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/GPUImageNativeLibrary.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.gpuimage;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | public class GPUImageNativeLibrary {
6 | static {
7 | System.loadLibrary("yuv-decoder");
8 | }
9 |
10 | public static native void YUVtoRBGA(byte[] yuv, int width, int height, int[] out);
11 |
12 | public static native void YUVtoARBG(byte[] yuv, int width, int height, int[] out);
13 |
14 | public static native void adjustBitmap(Bitmap srcBitmap);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageBrightnessFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * brightness value ranges from -1.0 to 1.0, with 0.0 as the normal level
23 | */
24 | public class GPUImageBrightnessFilter extends GPUImageFilter {
25 | public static final String BRIGHTNESS_FRAGMENT_SHADER = "" +
26 | "varying highp vec2 textureCoordinate;\n" +
27 | " \n" +
28 | " uniform sampler2D inputImageTexture;\n" +
29 | " uniform lowp float brightness;\n" +
30 | " \n" +
31 | " void main()\n" +
32 | " {\n" +
33 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
34 | " \n" +
35 | " gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);\n" +
36 | " }";
37 |
38 | private int brightnessLocation;
39 | private float brightness;
40 |
41 | public GPUImageBrightnessFilter() {
42 | this(0.0f);
43 | }
44 |
45 | public GPUImageBrightnessFilter(final float brightness) {
46 | super(NO_FILTER_VERTEX_SHADER, BRIGHTNESS_FRAGMENT_SHADER);
47 | this.brightness = brightness;
48 | }
49 |
50 | @Override
51 | public void onInit() {
52 | super.onInit();
53 | brightnessLocation = GLES20.glGetUniformLocation(getProgram(), "brightness");
54 | }
55 |
56 | @Override
57 | public void onInitialized() {
58 | super.onInitialized();
59 | setBrightness(brightness);
60 | }
61 |
62 | public void setBrightness(final float brightness) {
63 | this.brightness = brightness;
64 | setFloat(brightnessLocation, this.brightness);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageColorInvertFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | /**
20 | * Invert all the colors in the image.
21 | */
22 | public class GPUImageColorInvertFilter extends GPUImageFilter {
23 | public static final String COLOR_INVERT_FRAGMENT_SHADER = "" +
24 | "varying highp vec2 textureCoordinate;\n" +
25 | "\n" +
26 | "uniform sampler2D inputImageTexture;\n" +
27 | "\n" +
28 | "void main()\n" +
29 | "{\n" +
30 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
31 | " \n" +
32 | " gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);\n" +
33 | "}";
34 |
35 | public GPUImageColorInvertFilter() {
36 | super(NO_FILTER_VERTEX_SHADER, COLOR_INVERT_FRAGMENT_SHADER);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageContrastFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * Changes the contrast of the image.
23 | *
24 | * contrast value ranges from 0.0 to 4.0, with 1.0 as the normal level
25 | */
26 | public class GPUImageContrastFilter extends GPUImageFilter {
27 | public static final String CONTRAST_FRAGMENT_SHADER = "" +
28 | "varying highp vec2 textureCoordinate;\n" +
29 | " \n" +
30 | " uniform sampler2D inputImageTexture;\n" +
31 | " uniform lowp float contrast;\n" +
32 | " \n" +
33 | " void main()\n" +
34 | " {\n" +
35 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
36 | " \n" +
37 | " gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);\n" +
38 | " }";
39 |
40 | private int contrastLocation;
41 | private float contrast;
42 |
43 | public GPUImageContrastFilter() {
44 | this(1.2f);
45 | }
46 |
47 | public GPUImageContrastFilter(float contrast) {
48 | super(NO_FILTER_VERTEX_SHADER, CONTRAST_FRAGMENT_SHADER);
49 | this.contrast = contrast;
50 | }
51 |
52 | @Override
53 | public void onInit() {
54 | super.onInit();
55 | contrastLocation = GLES20.glGetUniformLocation(getProgram(), "contrast");
56 | }
57 |
58 | @Override
59 | public void onInitialized() {
60 | super.onInitialized();
61 | setContrast(contrast);
62 | }
63 |
64 | public void setContrast(final float contrast) {
65 | this.contrast = contrast;
66 | setFloat(contrastLocation, this.contrast);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageExposureFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * exposure: The adjusted exposure (-10.0 - 10.0, with 0.0 as the default)
23 | */
24 | public class GPUImageExposureFilter extends GPUImageFilter {
25 | public static final String EXPOSURE_FRAGMENT_SHADER = "" +
26 | " varying highp vec2 textureCoordinate;\n" +
27 | " \n" +
28 | " uniform sampler2D inputImageTexture;\n" +
29 | " uniform highp float exposure;\n" +
30 | " \n" +
31 | " void main()\n" +
32 | " {\n" +
33 | " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
34 | " \n" +
35 | " gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);\n" +
36 | " } ";
37 |
38 | private int exposureLocation;
39 | private float exposure;
40 |
41 | public GPUImageExposureFilter() {
42 | this(1.0f);
43 | }
44 |
45 | public GPUImageExposureFilter(final float exposure) {
46 | super(NO_FILTER_VERTEX_SHADER, EXPOSURE_FRAGMENT_SHADER);
47 | this.exposure = exposure;
48 | }
49 |
50 | @Override
51 | public void onInit() {
52 | super.onInit();
53 | exposureLocation = GLES20.glGetUniformLocation(getProgram(), "exposure");
54 | }
55 |
56 | @Override
57 | public void onInitialized() {
58 | super.onInitialized();
59 | setExposure(exposure);
60 | }
61 |
62 | public void setExposure(final float exposure) {
63 | this.exposure = exposure;
64 | setFloat(exposureLocation, this.exposure);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageGammaFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * gamma value ranges from 0.0 to 3.0, with 1.0 as the normal level
23 | */
24 | public class GPUImageGammaFilter extends GPUImageFilter {
25 | public static final String GAMMA_FRAGMENT_SHADER = "" +
26 | "varying highp vec2 textureCoordinate;\n" +
27 | " \n" +
28 | " uniform sampler2D inputImageTexture;\n" +
29 | " uniform lowp float gamma;\n" +
30 | " \n" +
31 | " void main()\n" +
32 | " {\n" +
33 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
34 | " \n" +
35 | " gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);\n" +
36 | " }";
37 |
38 | private int gammaLocation;
39 | private float gamma;
40 |
41 | public GPUImageGammaFilter() {
42 | this(1.2f);
43 | }
44 |
45 | public GPUImageGammaFilter(final float gamma) {
46 | super(NO_FILTER_VERTEX_SHADER, GAMMA_FRAGMENT_SHADER);
47 | this.gamma = gamma;
48 | }
49 |
50 | @Override
51 | public void onInit() {
52 | super.onInit();
53 | gammaLocation = GLES20.glGetUniformLocation(getProgram(), "gamma");
54 | }
55 |
56 | @Override
57 | public void onInitialized() {
58 | super.onInitialized();
59 | setGamma(gamma);
60 | }
61 |
62 | public void setGamma(final float gamma) {
63 | this.gamma = gamma;
64 | setFloat(gammaLocation, this.gamma);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageGrayscaleFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | /**
20 | * Applies a grayscale effect to the image.
21 | */
22 | public class GPUImageGrayscaleFilter extends GPUImageFilter {
23 | public static final String GRAYSCALE_FRAGMENT_SHADER = "" +
24 | "precision highp float;\n" +
25 | "\n" +
26 | "varying vec2 textureCoordinate;\n" +
27 | "\n" +
28 | "uniform sampler2D inputImageTexture;\n" +
29 | "\n" +
30 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
31 | "\n" +
32 | "void main()\n" +
33 | "{\n" +
34 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
35 | " float luminance = dot(textureColor.rgb, W);\n" +
36 | "\n" +
37 | " gl_FragColor = vec4(vec3(luminance), textureColor.a);\n" +
38 | "}";
39 |
40 | public GPUImageGrayscaleFilter() {
41 | super(NO_FILTER_VERTEX_SHADER, GRAYSCALE_FRAGMENT_SHADER);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageLuminanceFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | public class GPUImageLuminanceFilter extends GPUImageFilter {
20 |
21 | public static final String LUMINANCE_FRAGMENT_SHADER = "" +
22 | "precision highp float;\n" +
23 | "\n" +
24 | "varying vec2 textureCoordinate;\n" +
25 | "\n" +
26 | "uniform sampler2D inputImageTexture;\n" +
27 | "\n" +
28 | "// Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n" +
29 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
30 | "\n" +
31 | "void main()\n" +
32 | "{\n" +
33 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
34 | " float luminance = dot(textureColor.rgb, W);\n" +
35 | " \n" +
36 | " gl_FragColor = vec4(vec3(luminance), textureColor.a);\n" +
37 | "}";
38 |
39 | public GPUImageLuminanceFilter() {
40 | super(NO_FILTER_VERTEX_SHADER, LUMINANCE_FRAGMENT_SHADER);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageLuminanceThresholdFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | public class GPUImageLuminanceThresholdFilter extends GPUImageFilter {
22 |
23 | public static final String LUMINANCE_THRESHOLD_FRAGMENT_SHADER = "" +
24 | "varying highp vec2 textureCoordinate;\n" +
25 | "\n" +
26 | "uniform sampler2D inputImageTexture;\n" +
27 | "uniform highp float threshold;\n" +
28 | "\n" +
29 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
30 | "\n" +
31 | "void main()\n" +
32 | "{\n" +
33 | " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
34 | " highp float luminance = dot(textureColor.rgb, W);\n" +
35 | " highp float thresholdResult = step(threshold, luminance);\n" +
36 | " \n" +
37 | " gl_FragColor = vec4(vec3(thresholdResult), textureColor.w);\n" +
38 | "}";
39 |
40 | private int uniformThresholdLocation;
41 | private float threshold;
42 |
43 | public GPUImageLuminanceThresholdFilter() {
44 | this(0.5f);
45 | }
46 |
47 | public GPUImageLuminanceThresholdFilter(float threshold) {
48 | super(NO_FILTER_VERTEX_SHADER, LUMINANCE_THRESHOLD_FRAGMENT_SHADER);
49 | this.threshold = threshold;
50 | }
51 |
52 | @Override
53 | public void onInit() {
54 | super.onInit();
55 | uniformThresholdLocation = GLES20.glGetUniformLocation(getProgram(), "threshold");
56 | }
57 |
58 | @Override
59 | public void onInitialized() {
60 | super.onInitialized();
61 | setThreshold(threshold);
62 | }
63 |
64 | public void setThreshold(final float threshold) {
65 | this.threshold = threshold;
66 | setFloat(uniformThresholdLocation, threshold);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageOpacityFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * Adjusts the alpha channel of the incoming image
23 | * opacity: The value to multiply the incoming alpha channel for each pixel by (0.0 - 1.0, with 1.0 as the default)
24 | */
25 | public class GPUImageOpacityFilter extends GPUImageFilter {
26 | public static final String OPACITY_FRAGMENT_SHADER = "" +
27 | " varying highp vec2 textureCoordinate;\n" +
28 | " \n" +
29 | " uniform sampler2D inputImageTexture;\n" +
30 | " uniform lowp float opacity;\n" +
31 | " \n" +
32 | " void main()\n" +
33 | " {\n" +
34 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
35 | " \n" +
36 | " gl_FragColor = vec4(textureColor.rgb, textureColor.a * opacity);\n" +
37 | " }\n";
38 |
39 | private int opacityLocation;
40 | private float opacity;
41 |
42 | public GPUImageOpacityFilter() {
43 | this(1.0f);
44 | }
45 |
46 | public GPUImageOpacityFilter(final float opacity) {
47 | super(NO_FILTER_VERTEX_SHADER, OPACITY_FRAGMENT_SHADER);
48 | this.opacity = opacity;
49 | }
50 |
51 | @Override
52 | public void onInit() {
53 | super.onInit();
54 | opacityLocation = GLES20.glGetUniformLocation(getProgram(), "opacity");
55 | }
56 |
57 | @Override
58 | public void onInitialized() {
59 | super.onInitialized();
60 | setOpacity(opacity);
61 | }
62 |
63 | public void setOpacity(final float opacity) {
64 | this.opacity = opacity;
65 | setFloat(opacityLocation, this.opacity);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImagePosterizeFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * Reduces the color range of the image.
23 | *
24 | * colorLevels: ranges from 1 to 256, with a default of 10
25 | */
26 | public class GPUImagePosterizeFilter extends GPUImageFilter {
27 | public static final String POSTERIZE_FRAGMENT_SHADER = "" +
28 | "varying highp vec2 textureCoordinate;\n" +
29 | "\n" +
30 | "uniform sampler2D inputImageTexture;\n" +
31 | "uniform highp float colorLevels;\n" +
32 | "\n" +
33 | "void main()\n" +
34 | "{\n" +
35 | " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
36 | " \n" +
37 | " gl_FragColor = floor((textureColor * colorLevels) + vec4(0.5)) / colorLevels;\n" +
38 | "}";
39 |
40 | private int glUniformColorLevels;
41 | private int colorLevels;
42 |
43 | public GPUImagePosterizeFilter() {
44 | this(10);
45 | }
46 |
47 | public GPUImagePosterizeFilter(final int colorLevels) {
48 | super(GPUImageFilter.NO_FILTER_VERTEX_SHADER, POSTERIZE_FRAGMENT_SHADER);
49 | this.colorLevels = colorLevels;
50 | }
51 |
52 | @Override
53 | public void onInit() {
54 | super.onInit();
55 | glUniformColorLevels = GLES20.glGetUniformLocation(getProgram(), "colorLevels");
56 | }
57 |
58 | @Override
59 | public void onInitialized() {
60 | super.onInitialized();
61 | setColorLevels(colorLevels);
62 | }
63 |
64 | public void setColorLevels(final int colorLevels) {
65 | this.colorLevels = colorLevels;
66 | setFloat(glUniformColorLevels, colorLevels);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageSaturationFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * saturation: The degree of saturation or desaturation to apply to the image (0.0 - 2.0, with 1.0 as the default)
23 | */
24 | public class GPUImageSaturationFilter extends GPUImageFilter {
25 | public static final String SATURATION_FRAGMENT_SHADER = "" +
26 | " varying highp vec2 textureCoordinate;\n" +
27 | " \n" +
28 | " uniform sampler2D inputImageTexture;\n" +
29 | " uniform lowp float saturation;\n" +
30 | " \n" +
31 | " // Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n" +
32 | " const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n" +
33 | " \n" +
34 | " void main()\n" +
35 | " {\n" +
36 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
37 | " lowp float luminance = dot(textureColor.rgb, luminanceWeighting);\n" +
38 | " lowp vec3 greyScaleColor = vec3(luminance);\n" +
39 | " \n" +
40 | " gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);\n" +
41 | " \n" +
42 | " }";
43 |
44 | private int saturationLocation;
45 | private float saturation;
46 |
47 | public GPUImageSaturationFilter() {
48 | this(1.0f);
49 | }
50 |
51 | public GPUImageSaturationFilter(final float saturation) {
52 | super(NO_FILTER_VERTEX_SHADER, SATURATION_FRAGMENT_SHADER);
53 | this.saturation = saturation;
54 | }
55 |
56 | @Override
57 | public void onInit() {
58 | super.onInit();
59 | saturationLocation = GLES20.glGetUniformLocation(getProgram(), "saturation");
60 | }
61 |
62 | @Override
63 | public void onInitialized() {
64 | super.onInitialized();
65 | setSaturation(saturation);
66 | }
67 |
68 | public void setSaturation(final float saturation) {
69 | this.saturation = saturation;
70 | setFloat(saturationLocation, this.saturation);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageSepiaToneFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | /**
20 | * Applies a simple sepia effect.
21 | */
22 | public class GPUImageSepiaToneFilter extends GPUImageColorMatrixFilter {
23 |
24 | public GPUImageSepiaToneFilter() {
25 | this(1.0f);
26 | }
27 |
28 | public GPUImageSepiaToneFilter(final float intensity) {
29 | super(intensity, new float[]{
30 | 0.3588f, 0.7044f, 0.1368f, 0.0f,
31 | 0.2990f, 0.5870f, 0.1140f, 0.0f,
32 | 0.2392f, 0.4696f, 0.0912f, 0.0f,
33 | 0f, 0f, 0f, 1.0f
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageSolarizeFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GPUImageSolarizeFilter extends GPUImageFilter {
6 | public static final String SOLATIZE_FRAGMENT_SHADER = "" +
7 | "varying highp vec2 textureCoordinate;\n" +
8 | "\n" +
9 | "uniform sampler2D inputImageTexture;\n" +
10 | "uniform highp float threshold;\n" +
11 | "\n" +
12 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
13 | "\n" +
14 | "void main()\n" +
15 | "{\n" +
16 | " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
17 | " highp float luminance = dot(textureColor.rgb, W);\n" +
18 | " highp float thresholdResult = step(luminance, threshold);\n" +
19 | " highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n" +
20 | " \n" +
21 | " gl_FragColor = vec4(finalColor, textureColor.w);\n" +
22 | "}";
23 |
24 | private int uniformThresholdLocation;
25 | private float threshold;
26 |
27 | public GPUImageSolarizeFilter() {
28 | this(0.5f);
29 | }
30 |
31 | public GPUImageSolarizeFilter(float threshold) {
32 | super(NO_FILTER_VERTEX_SHADER, SOLATIZE_FRAGMENT_SHADER);
33 | this.threshold = threshold;
34 | }
35 |
36 | @Override
37 | public void onInit() {
38 | super.onInit();
39 | uniformThresholdLocation = GLES20.glGetUniformLocation(getProgram(), "threshold");
40 | }
41 |
42 | @Override
43 | public void onInitialized() {
44 | super.onInitialized();
45 | setThreshold(threshold);
46 | }
47 |
48 | public void setThreshold(final float threshold) {
49 | this.threshold = threshold;
50 | setFloat(uniformThresholdLocation, threshold);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageTwoPassFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | public class GPUImageTwoPassFilter extends GPUImageFilterGroup {
20 | public GPUImageTwoPassFilter(String firstVertexShader, String firstFragmentShader,
21 | String secondVertexShader, String secondFragmentShader) {
22 | super(null);
23 | addFilter(new GPUImageFilter(firstVertexShader, firstFragmentShader));
24 | addFilter(new GPUImageFilter(secondVertexShader, secondFragmentShader));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageTwoPassTextureSamplingFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
18 |
19 | import android.opengl.GLES20;
20 |
21 | public class GPUImageTwoPassTextureSamplingFilter extends GPUImageTwoPassFilter {
22 | public GPUImageTwoPassTextureSamplingFilter(String firstVertexShader, String firstFragmentShader,
23 | String secondVertexShader, String secondFragmentShader) {
24 | super(firstVertexShader, firstFragmentShader,
25 | secondVertexShader, secondFragmentShader);
26 | }
27 |
28 | @Override
29 | public void onInit() {
30 | super.onInit();
31 | initTexelOffsets();
32 | }
33 |
34 | protected void initTexelOffsets() {
35 | float ratio = getHorizontalTexelOffsetRatio();
36 | GPUImageFilter filter = getFilters().get(0);
37 | int texelWidthOffsetLocation = GLES20.glGetUniformLocation(filter.getProgram(), "texelWidthOffset");
38 | int texelHeightOffsetLocation = GLES20.glGetUniformLocation(filter.getProgram(), "texelHeightOffset");
39 | filter.setFloat(texelWidthOffsetLocation, ratio / getOutputWidth());
40 | filter.setFloat(texelHeightOffsetLocation, 0);
41 |
42 | ratio = getVerticalTexelOffsetRatio();
43 | filter = getFilters().get(1);
44 | texelWidthOffsetLocation = GLES20.glGetUniformLocation(filter.getProgram(), "texelWidthOffset");
45 | texelHeightOffsetLocation = GLES20.glGetUniformLocation(filter.getProgram(), "texelHeightOffset");
46 | filter.setFloat(texelWidthOffsetLocation, 0);
47 | filter.setFloat(texelHeightOffsetLocation, ratio / getOutputHeight());
48 | }
49 |
50 | @Override
51 | public void onOutputSizeChanged(int width, int height) {
52 | super.onOutputSizeChanged(width, height);
53 | initTexelOffsets();
54 | }
55 |
56 | public float getVerticalTexelOffsetRatio() {
57 | return 1f;
58 | }
59 |
60 | public float getHorizontalTexelOffsetRatio() {
61 | return 1f;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/gpufilter/GPUImageVibranceFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.gpuimage.gpufilter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GPUImageVibranceFilter extends GPUImageFilter {
6 | public static final String VIBRANCE_FRAGMENT_SHADER = "" +
7 | "varying highp vec2 textureCoordinate;\n" +
8 | "\n" +
9 | "uniform sampler2D inputImageTexture;\n" +
10 | "uniform lowp float vibrance;\n" +
11 | "\n" +
12 | "void main() {\n" +
13 | " lowp vec4 color = texture2D(inputImageTexture, textureCoordinate);\n" +
14 | " lowp float average = (color.r + color.g + color.b) / 3.0;\n" +
15 | " lowp float mx = max(color.r, max(color.g, color.b));\n" +
16 | " lowp float amt = (mx - average) * (-vibrance * 3.0);\n" +
17 | " color.rgb = mix(color.rgb, vec3(mx), amt);\n" +
18 | " gl_FragColor = color;\n" +
19 | "}";
20 |
21 | private int vibranceLocation;
22 | private float vibrance;
23 |
24 | @Override
25 | public void onInit() {
26 | super.onInit();
27 | vibranceLocation = GLES20.glGetUniformLocation(getProgram(), "vibrance");
28 | }
29 |
30 | public GPUImageVibranceFilter() {
31 | this(0f);
32 | }
33 |
34 | public GPUImageVibranceFilter(float vibrance) {
35 | super(NO_FILTER_VERTEX_SHADER, VIBRANCE_FRAGMENT_SHADER);
36 | this.vibrance = vibrance;
37 | }
38 |
39 | @Override
40 | public void onInitialized() {
41 | super.onInitialized();
42 | setVibrance(vibrance);
43 | }
44 |
45 | public void setVibrance(final float vibrance) {
46 | this.vibrance = vibrance;
47 | if (isInitialized()) {
48 | setFloat(vibranceLocation, vibrance);
49 | }
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/gpuimage/utils/Rotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 CyberAgent, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fahimfarhan.simplevideoeditor.gpuimage.utils;
18 |
19 | public enum Rotation {
20 | NORMAL, ROTATION_90, ROTATION_180, ROTATION_270;
21 |
22 | /**
23 | * Retrieves the int representation of the Rotation.
24 | *
25 | * @return 0, 90, 180 or 270
26 | */
27 | public int asInt() {
28 | switch (this) {
29 | case NORMAL:
30 | return 0;
31 | case ROTATION_90:
32 | return 90;
33 | case ROTATION_180:
34 | return 180;
35 | case ROTATION_270:
36 | return 270;
37 | default:
38 | throw new IllegalStateException("Unknown Rotation!");
39 | }
40 | }
41 |
42 | /**
43 | * Create a Rotation from an integer. Needs to be either 0, 90, 180 or 270.
44 | *
45 | * @param rotation 0, 90, 180 or 270
46 | * @return Rotation object
47 | */
48 | public static Rotation fromInt(int rotation) {
49 | switch (rotation) {
50 | case 0:
51 | return NORMAL;
52 | case 90:
53 | return ROTATION_90;
54 | case 180:
55 | return ROTATION_180;
56 | case 270:
57 | return ROTATION_270;
58 | case 360:
59 | return NORMAL;
60 | default:
61 | throw new IllegalStateException(
62 | rotation + " is an unknown rotation. Needs to be either 0, 90, 180 or 270!");
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/guestures/GesturePlayerTextureView.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.guestures;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 |
8 | @SuppressLint("ViewConstructor")
9 | public class GesturePlayerTextureView extends PlayerTextureView implements View.OnTouchListener {
10 |
11 | private final AllGestureDetector allGestureDetector;
12 |
13 | // 基準となる枠のサイズ
14 | private float baseWidthSize = 0;
15 |
16 | public GesturePlayerTextureView(Context context, String path) {
17 | super(context, path);
18 | setOnTouchListener(this);
19 | allGestureDetector = new AllGestureDetector(this);
20 | allGestureDetector.setLimitScaleMin(0.1f);
21 | allGestureDetector.noRotate();
22 | }
23 |
24 | @Override
25 | public boolean onTouch(View v, MotionEvent event) {
26 | allGestureDetector.onTouch(event);
27 | return true;
28 | }
29 |
30 | public void setBaseWidthSize(float baseSize) {
31 | this.baseWidthSize = baseSize;
32 | requestLayout();
33 | }
34 |
35 | public void updateRotate() {
36 | final int rotation = (int) getRotation();
37 |
38 | switch (rotation) {
39 | case 0:
40 | super.setRotation(90f);
41 | break;
42 | case 90:
43 | super.setRotation(180f);
44 | break;
45 | case 180:
46 | super.setRotation(270f);
47 | break;
48 | case 270:
49 | super.setRotation(0f);
50 | break;
51 | }
52 |
53 | allGestureDetector.updateAngle();
54 | }
55 |
56 |
57 | @Override
58 | public void setRotation(float rotation) {
59 | // do nothing
60 | }
61 |
62 | @Override
63 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
64 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
65 | if (videoAspect == DEFAULT_ASPECT || baseWidthSize == 0) return;
66 |
67 | // 正方形
68 | if (videoAspect == 1.0f) {
69 | setMeasuredDimension((int) baseWidthSize, (int) baseWidthSize);
70 | return;
71 | }
72 |
73 | // 縦長 or 横長
74 | setMeasuredDimension((int) baseWidthSize, (int) (baseWidthSize / videoAspect));
75 |
76 | }
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/guestures/PortraitView.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.guestures;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.FrameLayout;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 |
10 | public class PortraitView extends FrameLayout {
11 | public PortraitView(@NonNull Context context) {
12 | super(context);
13 | }
14 |
15 | public PortraitView(@NonNull Context context, @Nullable AttributeSet attrs) {
16 | super(context, attrs);
17 | }
18 |
19 | public PortraitView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
20 | super(context, attrs, defStyleAttr);
21 | }
22 |
23 | @Override
24 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
25 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
26 | int height = getMeasuredHeight();
27 | setMeasuredDimension((int) (height / 16f * 9), height);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/FillMode.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose;
2 |
3 | /**
4 | * Created by sudamasayuki on 2018/01/01.
5 | */
6 |
7 | public enum FillMode {
8 | PRESERVE_ASPECT_FIT,
9 | PRESERVE_ASPECT_CROP,
10 | CUSTOM;
11 |
12 | public static float[] getScaleAspectFit(int angle, int widthIn, int heightIn, int widthOut, int heightOut) {
13 | final float[] scale = {1, 1};
14 | scale[0] = scale[1] = 1;
15 | if (angle == 90 || angle == 270) {
16 | int cx = widthIn;
17 | widthIn = heightIn;
18 | heightIn = cx;
19 | }
20 |
21 | float aspectRatioIn = (float) widthIn / (float) heightIn;
22 | float heightOutCalculated = (float) widthOut / aspectRatioIn;
23 |
24 | if (heightOutCalculated < heightOut) {
25 | scale[1] = heightOutCalculated / heightOut;
26 | } else {
27 | scale[0] = heightOut * aspectRatioIn / widthOut;
28 | }
29 |
30 | return scale;
31 | }
32 |
33 | public static float[] getScaleAspectCrop(int angle, int widthIn, int heightIn, int widthOut, int heightOut) {
34 | final float[] scale = {1, 1};
35 | scale[0] = scale[1] = 1;
36 | if (angle == 90 || angle == 270) {
37 | int cx = widthIn;
38 | widthIn = heightIn;
39 | heightIn = cx;
40 | }
41 |
42 | float aspectRatioIn = (float) widthIn / (float) heightIn;
43 | float aspectRatioOut = (float) widthOut / (float) heightOut;
44 |
45 | if (aspectRatioIn > aspectRatioOut) {
46 | float widthOutCalculated = (float) heightOut * aspectRatioIn;
47 | scale[0] = widthOutCalculated / widthOut;
48 | } else {
49 | float heightOutCalculated = (float) widthOut / aspectRatioIn;
50 | scale[1] = heightOutCalculated / heightOut;
51 | }
52 |
53 | return scale;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/FillModeCustomItem.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * Created by sudamasayuki2 on 2018/01/08.
8 | */
9 |
10 | public class FillModeCustomItem implements Parcelable {
11 | private final float scale;
12 | private final float rotate;
13 | private final float translateX;
14 | private final float translateY;
15 | private final float videoWidth;
16 | private final float videoHeight;
17 |
18 | public FillModeCustomItem(float scale, float rotate, float translateX, float translateY, float videoWidth, float videoHeight) {
19 | this.scale = scale;
20 | this.rotate = rotate;
21 | this.translateX = translateX;
22 | this.translateY = translateY;
23 | this.videoWidth = videoWidth;
24 | this.videoHeight = videoHeight;
25 | }
26 |
27 | public float getScale() {
28 | return scale;
29 | }
30 |
31 | public float getRotate() {
32 | return rotate;
33 | }
34 |
35 | public float getTranslateX() {
36 | return translateX;
37 | }
38 |
39 | public float getTranslateY() {
40 | return translateY;
41 | }
42 |
43 | public float getVideoWidth() {
44 | return videoWidth;
45 | }
46 |
47 | public float getVideoHeight() {
48 | return videoHeight;
49 | }
50 |
51 | @Override
52 | public int describeContents() {
53 | return 0;
54 | }
55 |
56 | @Override
57 | public void writeToParcel(Parcel dest, int flags) {
58 | dest.writeFloat(this.scale);
59 | dest.writeFloat(this.rotate);
60 | dest.writeFloat(this.translateX);
61 | dest.writeFloat(this.translateY);
62 | dest.writeFloat(this.videoWidth);
63 | dest.writeFloat(this.videoHeight);
64 | }
65 |
66 | protected FillModeCustomItem(Parcel in) {
67 | this.scale = in.readFloat();
68 | this.rotate = in.readFloat();
69 | this.translateX = in.readFloat();
70 | this.translateY = in.readFloat();
71 | this.videoWidth = in.readFloat();
72 | this.videoHeight = in.readFloat();
73 | }
74 |
75 | public static final Creator CREATOR = new Creator() {
76 | @Override
77 | public FillModeCustomItem createFromParcel(Parcel source) {
78 | return new FillModeCustomItem(source);
79 | }
80 |
81 | @Override
82 | public FillModeCustomItem[] newArray(int size) {
83 | return new FillModeCustomItem[size];
84 | }
85 | };
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/FilterAdjuster.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose;
2 |
3 |
4 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter.GlFilter;
5 |
6 | public interface FilterAdjuster {
7 | public void adjust(GlFilter filter, int percentage);
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/Rotation.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose;
2 |
3 | /**
4 | * Created by sudamasayuki on 2017/11/15.
5 | */
6 |
7 | public enum Rotation {
8 | NORMAL(0),
9 | ROTATION_90(90),
10 | ROTATION_180(180),
11 | ROTATION_270(270);
12 |
13 | private final int rotation;
14 |
15 | Rotation(int rotation) {
16 | this.rotation = rotation;
17 | }
18 |
19 | public int getRotation() {
20 | return rotation;
21 | }
22 |
23 | public static Rotation fromInt(int rotate) {
24 | int calcRotate = rotate;
25 | if (calcRotate > 360) {
26 | calcRotate -= 360;
27 | }
28 |
29 | for (Rotation rotation : Rotation.values()) {
30 | if (calcRotate == rotation.getRotation()) return rotation;
31 | }
32 |
33 | return NORMAL;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/SampleType.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose;
2 |
3 | public enum SampleType {VIDEO, AUDIO}
4 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/VideoFormatMimeType.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose;
2 |
3 | import android.media.MediaFormat;
4 |
5 | public enum VideoFormatMimeType {
6 | HEVC(MediaFormat.MIMETYPE_VIDEO_HEVC),
7 | AVC(MediaFormat.MIMETYPE_VIDEO_AVC),
8 | MPEG4(MediaFormat.MIMETYPE_VIDEO_MPEG4),
9 | H263(MediaFormat.MIMETYPE_VIDEO_H263),
10 | AUTO("");
11 |
12 | private final String videoFormatMimeType;
13 |
14 | VideoFormatMimeType(String videoFormatMimeType) {
15 | this.videoFormatMimeType = videoFormatMimeType;
16 | }
17 |
18 | public String getFormat() {
19 | return videoFormatMimeType;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/composer/IAudioComposer.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.composer;
2 |
3 | /**
4 | * Created by sudamasayuki2 on 2018/02/24.
5 | */
6 |
7 | interface IAudioComposer {
8 |
9 | void setup();
10 |
11 | boolean stepPipeline();
12 |
13 | long getWrittenPresentationTimeUs();
14 |
15 | boolean isFinished();
16 |
17 | void release();
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlBrightnessFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlBrightnessFilter extends GlFilter {
6 | private static final String BRIGHTNESS_FRAGMENT_SHADER = "" +
7 | "precision mediump float;" +
8 | " varying vec2 vTextureCoord;\n" +
9 | " \n" +
10 | " uniform lowp sampler2D sTexture;\n" +
11 | " uniform lowp float brightness;\n" +
12 | " \n" +
13 | " void main()\n" +
14 | " {\n" +
15 | " lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
16 | " \n" +
17 | " gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);\n" +
18 | " }";
19 |
20 | public GlBrightnessFilter() {
21 | super(DEFAULT_VERTEX_SHADER, BRIGHTNESS_FRAGMENT_SHADER);
22 | }
23 |
24 | private float brightness = 0f;
25 |
26 | public void setBrightness(float brightness) {
27 | this.brightness = brightness;
28 | }
29 |
30 | @Override
31 | public void onDraw() {
32 | GLES20.glUniform1f(getHandle("brightness"), brightness);
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlBulgeDistortionFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Created by sudamasayuki on 2018/01/06.
7 | */
8 |
9 | public class GlBulgeDistortionFilter extends GlFilter {
10 |
11 | private static final String FRAGMENT_SHADER =
12 | "precision mediump float;" +
13 |
14 | "varying highp vec2 vTextureCoord;" +
15 | "uniform lowp sampler2D sTexture;" +
16 |
17 | "uniform highp vec2 center;" +
18 | "uniform highp float radius;" +
19 | "uniform highp float scale;" +
20 |
21 | "void main() {" +
22 | "highp vec2 textureCoordinateToUse = vTextureCoord;" +
23 | "highp float dist = distance(center, vTextureCoord);" +
24 | "textureCoordinateToUse -= center;" +
25 | "if (dist < radius) {" +
26 | "highp float percent = 1.0 - ((radius - dist) / radius) * scale;" +
27 | "percent = percent * percent;" +
28 | "textureCoordinateToUse = textureCoordinateToUse * percent;" +
29 | "}" +
30 | "textureCoordinateToUse += center;" +
31 |
32 | "gl_FragColor = texture2D(sTexture, textureCoordinateToUse);" +
33 | "}";
34 |
35 | private float centerX = 0.5f;
36 | private float centerY = 0.5f;
37 | private float radius = 0.25f;
38 | private float scale = 0.5f;
39 |
40 | public GlBulgeDistortionFilter() {
41 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
42 | }
43 |
44 | public float getCenterX() {
45 | return centerX;
46 | }
47 |
48 | public void setCenterX(final float centerX) {
49 | this.centerX = centerX;
50 | }
51 |
52 | public float getCenterY() {
53 | return centerY;
54 | }
55 |
56 | public void setCenterY(final float centerY) {
57 | this.centerY = centerY;
58 | }
59 |
60 | public float getRadius() {
61 | return radius;
62 | }
63 |
64 | public void setRadius(final float radius) {
65 | this.radius = radius;
66 | }
67 |
68 | public float getScale() {
69 | return scale;
70 | }
71 |
72 | public void setScale(final float scale) {
73 | this.scale = scale;
74 | }
75 |
76 | //////////////////////////////////////////////////////////////////////////
77 |
78 | @Override
79 | public void onDraw() {
80 | GLES20.glUniform2f(getHandle("center"), centerX, centerY);
81 | GLES20.glUniform1f(getHandle("radius"), radius);
82 | GLES20.glUniform1f(getHandle("scale"), scale);
83 | }
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlCGAColorspaceFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | /**
4 | * Created by sudamasayuki on 2018/01/06.
5 | */
6 |
7 | public class GlCGAColorspaceFilter extends GlFilter {
8 |
9 | private static final String FRAGMENT_SHADER =
10 | "precision mediump float;" +
11 |
12 | "varying vec2 vTextureCoord;" +
13 | "uniform lowp sampler2D sTexture;" +
14 |
15 | "void main() {" +
16 | "highp vec2 sampleDivisor = vec2(1.0 / 200.0, 1.0 / 320.0);" +
17 |
18 | "highp vec2 samplePos = vTextureCoord - mod(vTextureCoord, sampleDivisor);" +
19 | "highp vec4 color = texture2D(sTexture, samplePos);" +
20 |
21 | "mediump vec4 colorCyan = vec4(85.0 / 255.0, 1.0, 1.0, 1.0);" +
22 | "mediump vec4 colorMagenta = vec4(1.0, 85.0 / 255.0, 1.0, 1.0);" +
23 | "mediump vec4 colorWhite = vec4(1.0, 1.0, 1.0, 1.0);" +
24 | "mediump vec4 colorBlack = vec4(0.0, 0.0, 0.0, 1.0);" +
25 |
26 | "mediump vec4 endColor;" +
27 | "highp float blackDistance = distance(color, colorBlack);" +
28 | "highp float whiteDistance = distance(color, colorWhite);" +
29 | "highp float magentaDistance = distance(color, colorMagenta);" +
30 | "highp float cyanDistance = distance(color, colorCyan);" +
31 |
32 | "mediump vec4 finalColor;" +
33 |
34 | "highp float colorDistance = min(magentaDistance, cyanDistance);" +
35 | "colorDistance = min(colorDistance, whiteDistance);" +
36 | "colorDistance = min(colorDistance, blackDistance);" +
37 |
38 | "if (colorDistance == blackDistance) {" +
39 | "finalColor = colorBlack;" +
40 | "} else if (colorDistance == whiteDistance) {" +
41 | "finalColor = colorWhite;" +
42 | "} else if (colorDistance == cyanDistance) {" +
43 | "finalColor = colorCyan;" +
44 | "} else {" +
45 | "finalColor = colorMagenta;" +
46 | "}" +
47 |
48 | "gl_FragColor = finalColor;" +
49 | "}";
50 |
51 |
52 | public GlCGAColorspaceFilter() {
53 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlContrastFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Changes the contrast of the image.
7 | * contrast value ranges from 0.0 to 4.0, with 1.0 as the normal level
8 | */
9 | public class GlContrastFilter extends GlFilter {
10 |
11 | private static final String CONTRAST_FRAGMENT_SHADER = "" +
12 | "precision mediump float;" +
13 | " varying vec2 vTextureCoord;\n" +
14 | " \n" +
15 | " uniform lowp sampler2D sTexture;\n" +
16 | " uniform lowp float contrast;\n" +
17 | " \n" +
18 | " void main()\n" +
19 | " {\n" +
20 | " lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
21 | " \n" +
22 | " gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);\n" +
23 | " }";
24 |
25 |
26 | public GlContrastFilter() {
27 | super(DEFAULT_VERTEX_SHADER, CONTRAST_FRAGMENT_SHADER);
28 | }
29 |
30 | private float contrast = 1.2f;
31 |
32 | public void setContrast(float contrast) {
33 | this.contrast = contrast;
34 | }
35 |
36 | @Override
37 | public void onDraw() {
38 | GLES20.glUniform1f(getHandle("contrast"), contrast);
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlExposureFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * exposure: The adjusted exposure (-10.0 - 10.0, with 0.0 as the default)
7 | */
8 | public class GlExposureFilter extends GlFilter {
9 |
10 | private static final String EXPOSURE_FRAGMENT_SHADER = "" +
11 | "precision mediump float;" +
12 | " varying vec2 vTextureCoord;\n" +
13 | " \n" +
14 | " uniform lowp sampler2D sTexture;\n" +
15 | " uniform highp float exposure;\n" +
16 | " \n" +
17 | " void main()\n" +
18 | " {\n" +
19 | " highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
20 | " \n" +
21 | " gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);\n" +
22 | " } ";
23 |
24 | public GlExposureFilter() {
25 | super(DEFAULT_VERTEX_SHADER, EXPOSURE_FRAGMENT_SHADER);
26 | }
27 |
28 | private float exposure = 1f;
29 |
30 | public void setExposure(float exposure) {
31 | this.exposure = exposure;
32 | }
33 |
34 | @Override
35 | public void onDraw() {
36 | GLES20.glUniform1f(getHandle("exposure"), exposure);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlGammaFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlGammaFilter extends GlFilter {
6 | private static final String GAMMA_FRAGMENT_SHADER = "" +
7 | "precision mediump float;" +
8 | " varying vec2 vTextureCoord;\n" +
9 | " \n" +
10 | " uniform lowp sampler2D sTexture;\n" +
11 | " uniform lowp float gamma;\n" +
12 | " \n" +
13 | " void main()\n" +
14 | " {\n" +
15 | " lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
16 | " \n" +
17 | " gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);\n" +
18 | " }";
19 |
20 | public GlGammaFilter() {
21 | super(DEFAULT_VERTEX_SHADER, GAMMA_FRAGMENT_SHADER);
22 | }
23 |
24 | private float gamma = 1.2f;
25 |
26 | public void setGamma(float gamma) {
27 | this.gamma = gamma;
28 | }
29 |
30 | @Override
31 | public void onDraw() {
32 | GLES20.glUniform1f(getHandle("gamma"), gamma);
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlGrayScaleFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | /**
4 | * Created by sudamasayuki on 2017/11/14.
5 | */
6 |
7 | public class GlGrayScaleFilter extends GlFilter {
8 | private static final String FRAGMENT_SHADER =
9 | "precision mediump float;" +
10 | "varying vec2 vTextureCoord;" +
11 | "uniform lowp sampler2D sTexture;" +
12 | "const highp vec3 weight = vec3(0.2125, 0.7154, 0.0721);" +
13 | "void main() {" +
14 | "float luminance = dot(texture2D(sTexture, vTextureCoord).rgb, weight);" +
15 | "gl_FragColor = vec4(vec3(luminance), 1.0);" +
16 | "}";
17 |
18 | public GlGrayScaleFilter() {
19 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlHalftoneFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlHalftoneFilter extends GlFilter {
6 |
7 | private static final String HALFTONE_FRAGMENT_SHADER = "" +
8 | "precision mediump float;" +
9 | " varying vec2 vTextureCoord;\n" +
10 |
11 | " uniform lowp sampler2D sTexture;\n" +
12 |
13 | "uniform highp float fractionalWidthOfPixel;\n" +
14 | "uniform highp float aspectRatio;\n" +
15 |
16 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
17 |
18 | "void main()\n" +
19 | "{\n" +
20 | " highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);\n" +
21 | " highp vec2 samplePos = vTextureCoord - mod(vTextureCoord, sampleDivisor) + 0.5 * sampleDivisor;\n" +
22 | " highp vec2 textureCoordinateToUse = vec2(vTextureCoord.x, (vTextureCoord.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n" +
23 | " highp vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n" +
24 | " highp float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse);\n" +
25 | " lowp vec3 sampledColor = texture2D(sTexture, samplePos).rgb;\n" +
26 | " highp float dotScaling = 1.0 - dot(sampledColor, W);\n" +
27 | " lowp float checkForPresenceWithinDot = 1.0 - step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling);\n" +
28 | " gl_FragColor = vec4(vec3(checkForPresenceWithinDot), 1.0);\n" +
29 | "}";
30 |
31 | public GlHalftoneFilter() {
32 | super(DEFAULT_VERTEX_SHADER, HALFTONE_FRAGMENT_SHADER);
33 | }
34 |
35 | private float fractionalWidthOfPixel = 0.01f;
36 | private float aspectRatio = 1f;
37 |
38 | public void setFractionalWidthOfAPixel(float fractionalWidthOfAPixel) {
39 | this.fractionalWidthOfPixel = fractionalWidthOfAPixel;
40 | }
41 |
42 | @Override
43 | public void setFrameSize(int width, int height) {
44 | super.setFrameSize(width, height);
45 | aspectRatio = (float) height / (float) width;
46 | }
47 |
48 | @Override
49 | public void onDraw() {
50 | GLES20.glUniform1f(getHandle("fractionalWidthOfPixel"), fractionalWidthOfPixel);
51 | GLES20.glUniform1f(getHandle("aspectRatio"), aspectRatio);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlHazeFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Created by sudamasayuki on 2018/01/06.
7 | */
8 |
9 | public class GlHazeFilter extends GlFilter {
10 |
11 | private static final String FRAGMENT_SHADER =
12 | "precision mediump float;" +
13 | "varying highp vec2 vTextureCoord;" +
14 | "uniform lowp sampler2D sTexture;" +
15 | "uniform lowp float distance;" +
16 | "uniform highp float slope;" +
17 |
18 | "void main() {" +
19 | "highp vec4 color = vec4(1.0);" +
20 |
21 | "highp float d = vTextureCoord.y * slope + distance;" +
22 |
23 | "highp vec4 c = texture2D(sTexture, vTextureCoord);" +
24 | "c = (c - d * color) / (1.0 -d);" +
25 | "gl_FragColor = c;" + // consider using premultiply(c);
26 | "}";
27 |
28 | private float distance = 0.2f;
29 | private float slope = 0.0f;
30 |
31 | public GlHazeFilter() {
32 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
33 | }
34 |
35 | public float getDistance() {
36 | return distance;
37 | }
38 |
39 | public void setDistance(final float distance) {
40 | this.distance = distance;
41 | }
42 |
43 | public float getSlope() {
44 | return slope;
45 | }
46 |
47 | public void setSlope(final float slope) {
48 | this.slope = slope;
49 | }
50 |
51 | @Override
52 | public void onDraw() {
53 | GLES20.glUniform1f(getHandle("distance"), distance);
54 | GLES20.glUniform1f(getHandle("slope"), slope);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlHighlightShadowFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlHighlightShadowFilter extends GlFilter {
6 |
7 | private static final String HIGHLIGHT_SHADOW_FRAGMENT_SHADER = "" +
8 | "precision mediump float;" +
9 | " uniform lowp sampler2D sTexture;\n" +
10 | " varying vec2 vTextureCoord;\n" +
11 | " \n" +
12 | " uniform lowp float shadows;\n" +
13 | " uniform lowp float highlights;\n" +
14 | " \n" +
15 | " const mediump vec3 luminanceWeighting = vec3(0.3, 0.3, 0.3);\n" +
16 | " \n" +
17 | " void main()\n" +
18 | " {\n" +
19 | " lowp vec4 source = texture2D(sTexture, vTextureCoord);\n" +
20 | " mediump float luminance = dot(source.rgb, luminanceWeighting);\n" +
21 | " \n" +
22 | " mediump float shadow = clamp((pow(luminance, 1.0/(shadows+1.0)) + (-0.76)*pow(luminance, 2.0/(shadows+1.0))) - luminance, 0.0, 1.0);\n" +
23 | " mediump float highlight = clamp((1.0 - (pow(1.0-luminance, 1.0/(2.0-highlights)) + (-0.8)*pow(1.0-luminance, 2.0/(2.0-highlights)))) - luminance, -1.0, 0.0);\n" +
24 | " lowp vec3 result = vec3(0.0, 0.0, 0.0) + ((luminance + shadow + highlight) - 0.0) * ((source.rgb - vec3(0.0, 0.0, 0.0))/(luminance - 0.0));\n" +
25 | " \n" +
26 | " gl_FragColor = vec4(result.rgb, source.a);\n" +
27 | " }";
28 |
29 | public GlHighlightShadowFilter() {
30 | super(DEFAULT_VERTEX_SHADER, HIGHLIGHT_SHADOW_FRAGMENT_SHADER);
31 | }
32 |
33 | private float shadows = 1f;
34 | private float highlights = 0f;
35 |
36 | public void setShadows(float shadows) {
37 | this.shadows = shadows;
38 | }
39 |
40 | public void setHighlights(float highlights) {
41 | this.highlights = highlights;
42 | }
43 |
44 | @Override
45 | public void onDraw() {
46 | GLES20.glUniform1f(getHandle("shadows"), shadows);
47 | GLES20.glUniform1f(getHandle("highlights"), highlights);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlHueFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlHueFilter extends GlFilter {
6 |
7 | private static final String HUE_FRAGMENT_SHADER = "" +
8 | "precision highp float;\n" +
9 | " varying vec2 vTextureCoord;\n" +
10 | "\n" +
11 | " uniform lowp sampler2D sTexture;\n" +
12 | "uniform mediump float hueAdjust;\n" +
13 | "const highp vec4 kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);\n" +
14 | "const highp vec4 kRGBToI = vec4 (0.595716, -0.274453, -0.321263, 0.0);\n" +
15 | "const highp vec4 kRGBToQ = vec4 (0.211456, -0.522591, 0.31135, 0.0);\n" +
16 | "\n" +
17 | "const highp vec4 kYIQToR = vec4 (1.0, 0.9563, 0.6210, 0.0);\n" +
18 | "const highp vec4 kYIQToG = vec4 (1.0, -0.2721, -0.6474, 0.0);\n" +
19 | "const highp vec4 kYIQToB = vec4 (1.0, -1.1070, 1.7046, 0.0);\n" +
20 | "\n" +
21 | "void main ()\n" +
22 | "{\n" +
23 | " // Sample the input pixel\n" +
24 | " highp vec4 color = texture2D(sTexture, vTextureCoord);\n" +
25 | "\n" +
26 | " // Convert to YIQ\n" +
27 | " highp float YPrime = dot (color, kRGBToYPrime);\n" +
28 | " highp float I = dot (color, kRGBToI);\n" +
29 | " highp float Q = dot (color, kRGBToQ);\n" +
30 | "\n" +
31 | " // Calculate the hue and chroma\n" +
32 | " highp float hue = atan (Q, I);\n" +
33 | " highp float chroma = sqrt (I * I + Q * Q);\n" +
34 | "\n" +
35 | " // Make the user's adjustments\n" +
36 | " hue += (-hueAdjust); //why negative rotation?\n" +
37 | "\n" +
38 | " // Convert back to YIQ\n" +
39 | " Q = chroma * sin (hue);\n" +
40 | " I = chroma * cos (hue);\n" +
41 | "\n" +
42 | " // Convert back to RGB\n" +
43 | " highp vec4 yIQ = vec4 (YPrime, I, Q, 0.0);\n" +
44 | " color.r = dot (yIQ, kYIQToR);\n" +
45 | " color.g = dot (yIQ, kYIQToG);\n" +
46 | " color.b = dot (yIQ, kYIQToB);\n" +
47 | "\n" +
48 | " // Save the result\n" +
49 | " gl_FragColor = color;\n" +
50 | "}\n";
51 |
52 | public GlHueFilter() {
53 | super(DEFAULT_VERTEX_SHADER, HUE_FRAGMENT_SHADER);
54 | }
55 |
56 | private float hue = 90f;
57 |
58 | public void setHue(float hue) {
59 | this.hue = hue;
60 | }
61 |
62 |
63 | @Override
64 | public void onDraw() {
65 | GLES20.glUniform1f(getHandle("hueAdjust"), hue);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlInvertFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | /**
4 | * Created by sudamasayuki on 2018/01/06.
5 | */
6 |
7 | public class GlInvertFilter extends GlFilter {
8 | private static final String FRAGMENT_SHADER =
9 | "precision mediump float;" +
10 | "varying vec2 vTextureCoord;" +
11 | "uniform lowp sampler2D sTexture;" +
12 | "void main() {" +
13 | "lowp vec4 color = texture2D(sTexture, vTextureCoord);" +
14 | "gl_FragColor = vec4((1.0 - color.rgb), color.w);" +
15 | "}";
16 |
17 | public GlInvertFilter() {
18 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlLuminanceFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | public class GlLuminanceFilter extends GlFilter {
4 |
5 | private static final String LUMINANCE_FRAGMENT_SHADER = "" +
6 | "precision mediump float;" +
7 | "\n" +
8 | " varying vec2 vTextureCoord;\n" +
9 | "\n" +
10 | " uniform lowp sampler2D sTexture;\n" +
11 | "\n" +
12 | "// Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n" +
13 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
14 | "\n" +
15 | "void main()\n" +
16 | "{\n" +
17 | " lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
18 | " float luminance = dot(textureColor.rgb, W);\n" +
19 | " \n" +
20 | " gl_FragColor = vec4(vec3(luminance), textureColor.a);\n" +
21 | "}";
22 |
23 | public GlLuminanceFilter() {
24 | super(DEFAULT_VERTEX_SHADER, LUMINANCE_FRAGMENT_SHADER);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlLuminanceThresholdFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlLuminanceThresholdFilter extends GlFilter {
6 |
7 | private static final String LUMINANCE_THRESHOLD_FRAGMENT_SHADER = "" +
8 | "precision mediump float;" +
9 | "varying highp vec2 vTextureCoord;\n" +
10 | "\n" +
11 | "uniform lowp sampler2D sTexture;\n" +
12 | "uniform highp float threshold;\n" +
13 | "\n" +
14 | "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
15 | "\n" +
16 | "void main()\n" +
17 | "{\n" +
18 | " highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
19 | " highp float luminance = dot(textureColor.rgb, W);\n" +
20 | " highp float thresholdResult = step(threshold, luminance);\n" +
21 | " \n" +
22 | " gl_FragColor = vec4(vec3(thresholdResult), textureColor.w);\n" +
23 | "}";
24 |
25 | public GlLuminanceThresholdFilter() {
26 | super(DEFAULT_VERTEX_SHADER, LUMINANCE_THRESHOLD_FRAGMENT_SHADER);
27 | }
28 |
29 | private float threshold = 0.5f;
30 |
31 | public void setThreshold(float threshold) {
32 | this.threshold = threshold;
33 | }
34 |
35 | @Override
36 | public void onDraw() {
37 | GLES20.glUniform1f(getHandle("threshold"), threshold);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlMonochromeFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Created by sudamasayuki on 2018/01/06.
7 | */
8 |
9 | public class GlMonochromeFilter extends GlFilter {
10 |
11 | private static final String FRAGMENT_SHADER =
12 | "precision lowp float;" +
13 |
14 | "varying highp vec2 vTextureCoord;" +
15 | "uniform lowp sampler2D sTexture;" +
16 | "uniform float intensity;" +
17 |
18 | "const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);" +
19 |
20 | "void main() {" +
21 |
22 | "lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);" +
23 | "float luminance = dot(textureColor.rgb, luminanceWeighting);" +
24 |
25 | "lowp vec4 desat = vec4(vec3(luminance), 1.0);" +
26 |
27 | "lowp vec4 outputColor = vec4(" +
28 | "(desat.r < 0.5 ? (2.0 * desat.r * 0.6) : (1.0 - 2.0 * (1.0 - desat.r) * (1.0 - 0.6)))," +
29 | "(desat.g < 0.5 ? (2.0 * desat.g * 0.45) : (1.0 - 2.0 * (1.0 - desat.g) * (1.0 - 0.45)))," +
30 | "(desat.b < 0.5 ? (2.0 * desat.b * 0.3) : (1.0 - 2.0 * (1.0 - desat.b) * (1.0 - 0.3)))," +
31 | "1.0" +
32 | ");" +
33 |
34 | "gl_FragColor = vec4(mix(textureColor.rgb, outputColor.rgb, intensity), textureColor.a);" +
35 | "}";
36 |
37 | private float intensity = 1.0f;
38 |
39 | public GlMonochromeFilter() {
40 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
41 | }
42 |
43 | public float getIntensity() {
44 | return intensity;
45 | }
46 |
47 | public void setIntensity(float intensity) {
48 | this.intensity = intensity;
49 | }
50 |
51 | @Override
52 | public void onDraw() {
53 | GLES20.glUniform1f(getHandle("intensity"), intensity);
54 | }
55 |
56 |
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlOpacityFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Adjusts the alpha channel of the incoming image
7 | * opacity: The value to multiply the incoming alpha channel for each pixel by (0.0 - 1.0, with 1.0 as the default)
8 | */
9 | public class GlOpacityFilter extends GlFilter {
10 |
11 | private static final String OPACITY_FRAGMENT_SHADER = "" +
12 | "precision mediump float;" +
13 | " varying highp vec2 vTextureCoord;\n" +
14 | " \n" +
15 | " uniform lowp sampler2D sTexture;\n" +
16 | " uniform lowp float opacity;\n" +
17 | " \n" +
18 | " void main()\n" +
19 | " {\n" +
20 | " lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
21 | " \n" +
22 | " gl_FragColor = vec4(textureColor.rgb, textureColor.a * opacity);\n" +
23 | " }\n";
24 |
25 | public GlOpacityFilter() {
26 | super(DEFAULT_VERTEX_SHADER, OPACITY_FRAGMENT_SHADER);
27 | }
28 |
29 | private float opacity = 1f;
30 |
31 | public void setOpacity(float opacity) {
32 | this.opacity = opacity;
33 | }
34 |
35 | @Override
36 | public void onDraw() {
37 | GLES20.glUniform1f(getHandle("opacity"), opacity);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlPixelationFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlPixelationFilter extends GlFilter {
6 |
7 | private static final String PIXELATION_FRAGMENT_SHADER = "" +
8 | "precision highp float;\n" +
9 |
10 | "varying highp vec2 vTextureCoord;\n" +
11 |
12 | "uniform float imageWidthFactor;\n" +
13 | "uniform float imageHeightFactor;\n" +
14 | "uniform lowp sampler2D sTexture;\n" +
15 | "uniform float pixel;\n" +
16 |
17 | "void main()\n" +
18 | "{\n" +
19 | " vec2 uv = vTextureCoord.xy;\n" +
20 | " float dx = pixel * imageWidthFactor;\n" +
21 | " float dy = pixel * imageHeightFactor;\n" +
22 | " vec2 coord = vec2(dx * floor(uv.x / dx), dy * floor(uv.y / dy));\n" +
23 | " vec3 tc = texture2D(sTexture, coord).xyz;\n" +
24 | " gl_FragColor = vec4(tc, 1.0);\n" +
25 | "}";
26 |
27 | public GlPixelationFilter() {
28 | super(DEFAULT_VERTEX_SHADER, PIXELATION_FRAGMENT_SHADER);
29 | }
30 |
31 | private float pixel = 1f;
32 | private float imageWidthFactor = 1f / 720;
33 | private float imageHeightFactor = 1f / 720;
34 |
35 | @Override
36 | public void setFrameSize(int width, int height) {
37 | super.setFrameSize(width, height);
38 | imageWidthFactor = 1f / width;
39 | imageHeightFactor = 1f / height;
40 | }
41 |
42 | @Override
43 | public void onDraw() {
44 | GLES20.glUniform1f(getHandle("pixel"), pixel);
45 | GLES20.glUniform1f(getHandle("imageWidthFactor"), imageWidthFactor);
46 | GLES20.glUniform1f(getHandle("imageHeightFactor"), imageHeightFactor);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlPosterizeFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlPosterizeFilter extends GlFilter {
6 |
7 | private static final String POSTERIZE_FRAGMENT_SHADER = "" +
8 | "precision mediump float;" +
9 | " varying vec2 vTextureCoord;\n" +
10 | "\n" +
11 | "uniform lowp sampler2D sTexture;\n" +
12 | "uniform highp float colorLevels;\n" +
13 | "\n" +
14 | "void main()\n" +
15 | "{\n" +
16 | " highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
17 | " \n" +
18 | " gl_FragColor = floor((textureColor * colorLevels) + vec4(0.5)) / colorLevels;\n" +
19 | "}";
20 |
21 | public GlPosterizeFilter() {
22 | super(DEFAULT_VERTEX_SHADER, POSTERIZE_FRAGMENT_SHADER);
23 | }
24 |
25 | private int colorLevels = 10;
26 |
27 | public void setColorLevels(int colorLevels) {
28 | if (colorLevels < 0) {
29 | this.colorLevels = 0;
30 | } else if (colorLevels > 256) {
31 | this.colorLevels = 256;
32 | } else {
33 | this.colorLevels = colorLevels;
34 | }
35 | }
36 |
37 | @Override
38 | public void onDraw() {
39 | GLES20.glUniform1f(getHandle("colorLevels"), colorLevels);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlRGBFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Adjusts the individual RGB channels of an image
7 | * red: Normalized values by which each color channel is multiplied. The range is from 0.0 up, with 1.0 as the default.
8 | * green:
9 | * blue:
10 | */
11 | public class GlRGBFilter extends GlFilter {
12 |
13 | private static final String RGB_FRAGMENT_SHADER = "" +
14 | "precision mediump float;" +
15 | " varying vec2 vTextureCoord;\n" +
16 | " \n" +
17 | " uniform lowp sampler2D sTexture;\n" +
18 | " uniform highp float red;\n" +
19 | " uniform highp float green;\n" +
20 | " uniform highp float blue;\n" +
21 | " \n" +
22 | " void main()\n" +
23 | " {\n" +
24 | " highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
25 | " \n" +
26 | " gl_FragColor = vec4(textureColor.r * red, textureColor.g * green, textureColor.b * blue, 1.0);\n" +
27 | " }\n";
28 |
29 | public GlRGBFilter() {
30 | super(DEFAULT_VERTEX_SHADER, RGB_FRAGMENT_SHADER);
31 | }
32 |
33 | private float red = 1f;
34 | private float green = 1f;
35 | private float blue = 1f;
36 |
37 | public void setRed(float red) {
38 | this.red = red;
39 | }
40 |
41 | public void setGreen(float green) {
42 | this.green = green;
43 | }
44 |
45 | public void setBlue(float blue) {
46 | this.blue = blue;
47 | }
48 |
49 | @Override
50 | public void onDraw() {
51 | GLES20.glUniform1f(getHandle("red"), red);
52 | GLES20.glUniform1f(getHandle("green"), green);
53 | GLES20.glUniform1f(getHandle("blue"), blue);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlSaturationFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlSaturationFilter extends GlFilter {
6 | private static final String SATURATION_FRAGMENT_SHADER = "" +
7 | "precision mediump float;" +
8 | " varying vec2 vTextureCoord;\n" +
9 | " \n" +
10 | " uniform lowp sampler2D sTexture;\n" +
11 | " uniform lowp float saturation;\n" +
12 | " \n" +
13 | " const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n" +
14 | " \n" +
15 | " void main()\n" +
16 | " {\n" +
17 | " lowp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
18 | " lowp float luminance = dot(textureColor.rgb, luminanceWeighting);\n" +
19 | " lowp vec3 greyScaleColor = vec3(luminance);\n" +
20 | " \n" +
21 | " gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);\n" +
22 | " \n" +
23 | " }";
24 |
25 |
26 | public GlSaturationFilter() {
27 | super(DEFAULT_VERTEX_SHADER, SATURATION_FRAGMENT_SHADER);
28 | }
29 |
30 | private float saturation = 1f;
31 |
32 | public void setSaturation(float saturation) {
33 | this.saturation = saturation;
34 | }
35 |
36 | @Override
37 | public void onDraw() {
38 | GLES20.glUniform1f(getHandle("saturation"), saturation);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlSepiaFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | /**
4 | * Created by sudamasayuki on 2017/11/14.
5 | */
6 |
7 | public class GlSepiaFilter extends GlFilter {
8 | private static final String FRAGMENT_SHADER =
9 | "precision mediump float;" +
10 | "varying vec2 vTextureCoord;" +
11 | "uniform lowp sampler2D sTexture;" +
12 | "const highp vec3 weight = vec3(0.2125, 0.7154, 0.0721);" +
13 | "void main() {" +
14 | " vec4 FragColor = texture2D(sTexture, vTextureCoord);\n" +
15 | " gl_FragColor.r = dot(FragColor.rgb, vec3(.393, .769, .189));\n" +
16 | " gl_FragColor.g = dot(FragColor.rgb, vec3(.349, .686, .168));\n" +
17 | " gl_FragColor.b = dot(FragColor.rgb, vec3(.272, .534, .131));\n" +
18 | "}";
19 |
20 | public GlSepiaFilter() {
21 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlSolarizeFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlSolarizeFilter extends GlFilter {
6 |
7 | private static final String SOLATIZE_FRAGMENT_SHADER = "" +
8 | "precision mediump float;" +
9 | " varying vec2 vTextureCoord;\n" +
10 | "\n" +
11 | " uniform lowp sampler2D sTexture;\n" +
12 | " uniform highp float threshold;\n" +
13 | "\n" +
14 | " const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" +
15 | "\n" +
16 | "void main()\n" +
17 | "{\n" +
18 | " highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" +
19 | " highp float luminance = dot(textureColor.rgb, W);\n" +
20 | " highp float thresholdResult = step(luminance, threshold);\n" +
21 | " highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n" +
22 | " \n" +
23 | " gl_FragColor = vec4(finalColor, textureColor.w);\n" +
24 | "}";
25 |
26 | public GlSolarizeFilter() {
27 | super(DEFAULT_VERTEX_SHADER, SOLATIZE_FRAGMENT_SHADER);
28 | }
29 |
30 | private float threshold = 0.5f;
31 |
32 | public void setThreshold(float threshold) {
33 | this.threshold = threshold;
34 | }
35 |
36 | @Override
37 | public void onDraw() {
38 | GLES20.glUniform1f(getHandle("threshold"), threshold);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlSwirlFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.graphics.PointF;
4 | import android.opengl.GLES20;
5 |
6 | public class GlSwirlFilter extends GlFilter {
7 |
8 | private static final String SWIRL_FRAGMENT_SHADER = "" +
9 | "precision mediump float;" +
10 | " varying vec2 vTextureCoord;\n" +
11 | "\n" +
12 | " uniform lowp sampler2D sTexture;\n" +
13 | "\n" +
14 | "uniform highp vec2 center;\n" +
15 | "uniform highp float radius;\n" +
16 | "uniform highp float angle;\n" +
17 | "\n" +
18 | "void main()\n" +
19 | "{\n" +
20 | "highp vec2 textureCoordinateToUse = vTextureCoord;\n" +
21 | "highp float dist = distance(center, vTextureCoord);\n" +
22 | "if (dist < radius)\n" +
23 | "{\n" +
24 | "textureCoordinateToUse -= center;\n" +
25 | "highp float percent = (radius - dist) / radius;\n" +
26 | "highp float theta = percent * percent * angle * 8.0;\n" +
27 | "highp float s = sin(theta);\n" +
28 | "highp float c = cos(theta);\n" +
29 | "textureCoordinateToUse = vec2(dot(textureCoordinateToUse, vec2(c, -s)), dot(textureCoordinateToUse, vec2(s, c)));\n" +
30 | "textureCoordinateToUse += center;\n" +
31 | "}\n" +
32 | "\n" +
33 | "gl_FragColor = texture2D(sTexture, textureCoordinateToUse );\n" +
34 | "\n" +
35 | "}\n";
36 |
37 | public GlSwirlFilter() {
38 | super(DEFAULT_VERTEX_SHADER, SWIRL_FRAGMENT_SHADER);
39 | }
40 |
41 | private float angle = 1.0f;
42 | private float radius = 0.5f;
43 | private PointF center = new PointF(0.5f, 0.5f);
44 |
45 | public void setAngle(float angle) {
46 | this.angle = angle;
47 | }
48 |
49 | public void setRadius(float radius) {
50 | this.radius = radius;
51 | }
52 |
53 | public void setCenter(PointF center) {
54 | this.center = center;
55 | }
56 |
57 | @Override
58 | public void onDraw() {
59 | GLES20.glUniform2f(getHandle("center"), center.x, center.y);
60 | GLES20.glUniform1f(getHandle("radius"), radius);
61 | GLES20.glUniform1f(getHandle("angle"), angle);
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlVibranceFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlVibranceFilter extends GlFilter {
6 |
7 | private static final String VIBRANCE_FRAGMENT_SHADER = "" +
8 | "precision mediump float;" +
9 | " varying vec2 vTextureCoord;\n" +
10 | "\n" +
11 | " uniform lowp sampler2D sTexture;\n" +
12 | " uniform lowp float vibrance;\n" +
13 | "\n" +
14 | "void main() {\n" +
15 | " lowp vec4 color = texture2D(sTexture, vTextureCoord);\n" +
16 | " lowp float average = (color.r + color.g + color.b) / 3.0;\n" +
17 | " lowp float mx = max(color.r, max(color.g, color.b));\n" +
18 | " lowp float amt = (mx - average) * (-vibrance * 3.0);\n" +
19 | " color.rgb = mix(color.rgb, vec3(mx), amt);\n" +
20 | " gl_FragColor = color;\n" +
21 | "}";
22 |
23 | public GlVibranceFilter() {
24 | super(DEFAULT_VERTEX_SHADER, VIBRANCE_FRAGMENT_SHADER);
25 | }
26 |
27 | private float vibrance = 0f;
28 |
29 | public void setVibrance(float vibrance) {
30 | this.vibrance = vibrance;
31 | }
32 |
33 | @Override
34 | public void onDraw() {
35 | GLES20.glUniform1f(getHandle("vibrance"), vibrance);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlVignetteFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | /**
6 | * Created by sudamasayuki on 2018/01/07.
7 | */
8 |
9 | public class GlVignetteFilter extends GlFilter {
10 |
11 | private static final String FRAGMENT_SHADER =
12 | "precision mediump float;" +
13 |
14 | "varying vec2 vTextureCoord;" +
15 | "uniform lowp sampler2D sTexture;" +
16 |
17 | "uniform lowp vec2 vignetteCenter;" +
18 | "uniform highp float vignetteStart;" +
19 | "uniform highp float vignetteEnd;" +
20 |
21 | "void main() {" +
22 | "lowp vec3 rgb = texture2D(sTexture, vTextureCoord).rgb;" +
23 | "lowp float d = distance(vTextureCoord, vec2(vignetteCenter.x, vignetteCenter.y));" +
24 | "lowp float percent = smoothstep(vignetteStart, vignetteEnd, d);" +
25 | "gl_FragColor = vec4(mix(rgb.x, 0.0, percent), mix(rgb.y, 0.0, percent), mix(rgb.z, 0.0, percent), 1.0);" +
26 | "}";
27 |
28 | private float vignetteCenterX = 0.5f;
29 | private float vignetteCenterY = 0.5f;
30 | private float vignetteStart = 0.2f;
31 | private float vignetteEnd = 0.85f;
32 |
33 | public GlVignetteFilter() {
34 | super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
35 | }
36 |
37 |
38 | public float getVignetteStart() {
39 | return vignetteStart;
40 | }
41 |
42 | public void setVignetteStart(final float vignetteStart) {
43 | this.vignetteStart = vignetteStart;
44 | }
45 |
46 | public float getVignetteEnd() {
47 | return vignetteEnd;
48 | }
49 |
50 | public void setVignetteEnd(final float vignetteEnd) {
51 | this.vignetteEnd = vignetteEnd;
52 | }
53 |
54 | //////////////////////////////////////////////////////////////////////////
55 |
56 | @Override
57 | public void onDraw() {
58 | GLES20.glUniform2f(getHandle("vignetteCenter"), vignetteCenterX, vignetteCenterY);
59 | GLES20.glUniform1f(getHandle("vignetteStart"), vignetteStart);
60 | GLES20.glUniform1f(getHandle("vignetteEnd"), vignetteEnd);
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlWatermarkFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 |
6 | /**
7 | * Created by sudamasayuki2 on 2018/01/27.
8 | */
9 |
10 | public class GlWatermarkFilter extends GlOverlayFilter {
11 |
12 | private Bitmap bitmap;
13 | private Position position = Position.LEFT_TOP;
14 |
15 | public GlWatermarkFilter(Bitmap bitmap) {
16 | this.bitmap = bitmap;
17 | }
18 |
19 |
20 | public GlWatermarkFilter(Bitmap bitmap, Position position) {
21 | this.bitmap = bitmap;
22 | this.position = position;
23 | }
24 |
25 | @Override
26 | protected void drawCanvas(Canvas canvas) {
27 | if (bitmap != null && !bitmap.isRecycled()) {
28 | switch (position) {
29 | case LEFT_TOP:
30 | canvas.drawBitmap(bitmap, 0, 0, null);
31 | break;
32 | case LEFT_BOTTOM:
33 | canvas.drawBitmap(bitmap, 0, canvas.getHeight() - bitmap.getHeight(), null);
34 | break;
35 | case RIGHT_TOP:
36 | canvas.drawBitmap(bitmap, canvas.getWidth() - bitmap.getWidth(), 0, null);
37 | break;
38 | case RIGHT_BOTTOM:
39 | canvas.drawBitmap(bitmap, canvas.getWidth() - bitmap.getWidth(), canvas.getHeight() - bitmap.getHeight(), null);
40 | break;
41 | }
42 | }
43 | }
44 |
45 | public enum Position {
46 | LEFT_TOP,
47 | LEFT_BOTTOM,
48 | RIGHT_TOP,
49 | RIGHT_BOTTOM
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlWeakPixelInclusionFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | /**
4 | * Created by sudamasayuki on 2017/05/18.
5 | */
6 |
7 | public class GlWeakPixelInclusionFilter extends GlThreex3TextureSamplingFilter {
8 |
9 | private static final String FRAGMENT_SHADER =
10 | "precision lowp float;\n" +
11 |
12 | "uniform lowp sampler2D sTexture;\n" +
13 |
14 | "varying vec2 textureCoordinate;\n" +
15 | "varying vec2 leftTextureCoordinate;\n" +
16 | "varying vec2 rightTextureCoordinate;\n" +
17 |
18 | "varying vec2 topTextureCoordinate;\n" +
19 | "varying vec2 topLeftTextureCoordinate;\n" +
20 | "varying vec2 topRightTextureCoordinate;\n" +
21 |
22 | "varying vec2 bottomTextureCoordinate;\n" +
23 | "varying vec2 bottomLeftTextureCoordinate;\n" +
24 | "varying vec2 bottomRightTextureCoordinate;\n" +
25 |
26 | "void main() {\n" +
27 | "float bottomLeftIntensity = texture2D(sTexture, bottomLeftTextureCoordinate).r;" +
28 | "float topRightIntensity = texture2D(sTexture, topRightTextureCoordinate).r;" +
29 | "float topLeftIntensity = texture2D(sTexture, topLeftTextureCoordinate).r;" +
30 | "float bottomRightIntensity = texture2D(sTexture, bottomRightTextureCoordinate).r;" +
31 | "float leftIntensity = texture2D(sTexture, leftTextureCoordinate).r;" +
32 | "float rightIntensity = texture2D(sTexture, rightTextureCoordinate).r;" +
33 | "float bottomIntensity = texture2D(sTexture, bottomTextureCoordinate).r;" +
34 | "float topIntensity = texture2D(sTexture, topTextureCoordinate).r;" +
35 | "float centerIntensity = texture2D(sTexture, textureCoordinate).r;" +
36 |
37 | "float pixelIntensitySum = bottomLeftIntensity + topRightIntensity + topLeftIntensity + bottomRightIntensity + leftIntensity + rightIntensity + bottomIntensity + topIntensity + centerIntensity;" +
38 | "float sumTest = step(1.5, pixelIntensitySum);" +
39 | "float pixelTest = step(0.01, centerIntensity);" +
40 |
41 | "gl_FragColor = vec4(vec3(sumTest * pixelTest), 1.0);" +
42 | "}";
43 |
44 | public GlWeakPixelInclusionFilter() {
45 | super(FRAGMENT_SHADER);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlWhiteBalanceFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.opengl.GLES20;
4 |
5 | public class GlWhiteBalanceFilter extends GlFilter {
6 |
7 | private static final String WHITE_BALANCE_FRAGMENT_SHADER = "" +
8 | " uniform lowp sampler2D sTexture;\n" +
9 | " varying vec2 vTextureCoord;\n" +
10 |
11 | " \n" +
12 | "uniform lowp float temperature;\n" +
13 | "uniform lowp float tint;\n" +
14 | "\n" +
15 | "const lowp vec3 warmFilter = vec3(0.93, 0.54, 0.0);\n" +
16 | "\n" +
17 | "const mediump mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);\n" +
18 | "const mediump mat3 YIQtoRGB = mat3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);\n" +
19 | "\n" +
20 | "void main()\n" +
21 | "{\n" +
22 | " lowp vec4 source = texture2D(sTexture, vTextureCoord);\n" +
23 | " \n" +
24 | " mediump vec3 yiq = RGBtoYIQ * source.rgb; //adjusting tint\n" +
25 | " yiq.b = clamp(yiq.b + tint*0.5226*0.1, -0.5226, 0.5226);\n" +
26 | " lowp vec3 rgb = YIQtoRGB * yiq;\n" +
27 | "\n" +
28 | " lowp vec3 processed = vec3(\n" +
29 | " (rgb.r < 0.5 ? (2.0 * rgb.r * warmFilter.r) : (1.0 - 2.0 * (1.0 - rgb.r) * (1.0 - warmFilter.r))), //adjusting temperature\n" +
30 | " (rgb.g < 0.5 ? (2.0 * rgb.g * warmFilter.g) : (1.0 - 2.0 * (1.0 - rgb.g) * (1.0 - warmFilter.g))), \n" +
31 | " (rgb.b < 0.5 ? (2.0 * rgb.b * warmFilter.b) : (1.0 - 2.0 * (1.0 - rgb.b) * (1.0 - warmFilter.b))));\n" +
32 | "\n" +
33 | " gl_FragColor = vec4(mix(rgb, processed, temperature), source.a);\n" +
34 | "}";
35 |
36 | public GlWhiteBalanceFilter() {
37 | super(DEFAULT_VERTEX_SHADER, WHITE_BALANCE_FRAGMENT_SHADER);
38 | }
39 |
40 | private float temperature = 5000f;
41 | private float tint = 0f;
42 |
43 | public void setTemperature(final float temperature) {
44 | this.temperature = temperature < 5000 ? (float) (0.0004 * (temperature - 5000.0)) : (float) (0.00006 * (temperature - 5000.0));
45 | }
46 |
47 | public void setTint(final float tint) {
48 | this.tint = (float) (tint / 100.0);
49 | }
50 |
51 | @Override
52 | public void onDraw() {
53 | GLES20.glUniform1f(getHandle("temperature"), temperature);
54 | GLES20.glUniform1f(getHandle("tint"), tint);
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/filter/GlZoomBlurFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter;
2 |
3 | import android.graphics.PointF;
4 | import android.opengl.GLES20;
5 |
6 | public class GlZoomBlurFilter extends GlFilter {
7 |
8 | private static final String ZOOM_BLUR_FRAGMENT_SHADER = "" +
9 | "precision mediump float;" +
10 | " varying vec2 vTextureCoord;\n" +
11 | "\n" +
12 | "uniform lowp sampler2D sTexture;\n" +
13 | "\n" +
14 | "uniform highp vec2 blurCenter;\n" +
15 | "uniform highp float blurSize;\n" +
16 | "\n" +
17 | "void main()\n" +
18 | "{\n" +
19 | " // TODO: Do a more intelligent scaling based on resolution here\n" +
20 | " highp vec2 samplingOffset = 1.0/100.0 * (blurCenter - vTextureCoord) * blurSize;\n" +
21 | " \n" +
22 | " lowp vec4 fragmentColor = texture2D(sTexture, vTextureCoord) * 0.18;\n" +
23 | " fragmentColor += texture2D(sTexture, vTextureCoord + samplingOffset) * 0.15;\n" +
24 | " fragmentColor += texture2D(sTexture, vTextureCoord + (2.0 * samplingOffset)) * 0.12;\n" +
25 | " fragmentColor += texture2D(sTexture, vTextureCoord + (3.0 * samplingOffset)) * 0.09;\n" +
26 | " fragmentColor += texture2D(sTexture, vTextureCoord + (4.0 * samplingOffset)) * 0.05;\n" +
27 | " fragmentColor += texture2D(sTexture, vTextureCoord - samplingOffset) * 0.15;\n" +
28 | " fragmentColor += texture2D(sTexture, vTextureCoord - (2.0 * samplingOffset)) * 0.12;\n" +
29 | " fragmentColor += texture2D(sTexture, vTextureCoord - (3.0 * samplingOffset)) * 0.09;\n" +
30 | " fragmentColor += texture2D(sTexture, vTextureCoord - (4.0 * samplingOffset)) * 0.05;\n" +
31 | " \n" +
32 | " gl_FragColor = fragmentColor;\n" +
33 | "}\n";
34 |
35 | private PointF blurCenter = new PointF(0.5f, 0.5f);
36 | private float blurSize = 1f;
37 |
38 | public GlZoomBlurFilter() {
39 | super(DEFAULT_VERTEX_SHADER, ZOOM_BLUR_FRAGMENT_SHADER);
40 | }
41 |
42 | public void setBlurCenter(PointF blurCenter) {
43 | this.blurCenter = blurCenter;
44 | }
45 |
46 | public void setBlurSize(float blurSize) {
47 | this.blurSize = blurSize;
48 | }
49 |
50 | @Override
51 | public void onDraw() {
52 | GLES20.glUniform2f(getHandle("blurCenter"), blurCenter.x, blurCenter.y);
53 | GLES20.glUniform1f(getHandle("blurSize"), blurSize);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/DefaultContextFactory.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 | import android.opengl.GLSurfaceView;
4 | import android.util.Log;
5 |
6 | import javax.microedition.khronos.egl.EGL10;
7 | import javax.microedition.khronos.egl.EGLConfig;
8 | import javax.microedition.khronos.egl.EGLContext;
9 | import javax.microedition.khronos.egl.EGLDisplay;
10 |
11 | import static javax.microedition.khronos.egl.EGL10.EGL_NONE;
12 | import static javax.microedition.khronos.egl.EGL10.EGL_NO_CONTEXT;
13 |
14 |
15 | public class DefaultContextFactory implements GLSurfaceView.EGLContextFactory {
16 |
17 | private static final String TAG = "DefaultContextFactory";
18 |
19 | private int EGLContextClientVersion;
20 |
21 | public DefaultContextFactory(final int version) {
22 | EGLContextClientVersion = version;
23 | }
24 |
25 | private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
26 |
27 | @Override
28 | public EGLContext createContext(final EGL10 egl, final EGLDisplay display, final EGLConfig config) {
29 | final int[] attrib_list;
30 | if (EGLContextClientVersion != 0) {
31 | attrib_list = new int[]{EGL_CONTEXT_CLIENT_VERSION, EGLContextClientVersion, EGL_NONE};
32 | } else {
33 | attrib_list = null;
34 | }
35 | return egl.eglCreateContext(display, config, EGL_NO_CONTEXT, attrib_list);
36 | }
37 |
38 | @Override
39 | public void destroyContext(final EGL10 egl, final EGLDisplay display, final EGLContext context) {
40 | if (!egl.eglDestroyContext(display, context)) {
41 | Log.e(TAG, "display:" + display + " context: " + context);
42 | throw new RuntimeException("eglDestroyContext" + egl.eglGetError());
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/GlBitmapOverlaySample.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 |
6 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter.GlOverlayFilter;
7 |
8 | public class GlBitmapOverlaySample extends GlOverlayFilter {
9 |
10 | private Bitmap bitmap;
11 |
12 | public GlBitmapOverlaySample(Bitmap bitmap) {
13 | this.bitmap = bitmap;
14 | }
15 |
16 | @Override
17 | protected void drawCanvas(Canvas canvas) {
18 | if (bitmap != null && !bitmap.isRecycled()) {
19 | canvas.drawBitmap(bitmap, 0, 0, null);
20 | }
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/GlConfigChooser.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 |
4 |
5 | public class GlConfigChooser extends DefaultConfigChooser {
6 |
7 | private static final int EGL_CONTEXT_CLIENT_VERSION = 2;
8 |
9 | public GlConfigChooser(final boolean withDepthBuffer) {
10 | super(withDepthBuffer, EGL_CONTEXT_CLIENT_VERSION);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/GlContextFactory.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 |
4 |
5 | public class GlContextFactory extends DefaultContextFactory {
6 |
7 | private static final int EGL_CONTEXT_CLIENT_VERSION = 2;
8 |
9 | public GlContextFactory() {
10 | super(EGL_CONTEXT_CLIENT_VERSION);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/GlFrameBufferObjectRenderer.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 | import android.opengl.GLES20;
4 | import android.opengl.GLSurfaceView;
5 |
6 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter.GlFilter;
7 |
8 | import java.util.LinkedList;
9 | import java.util.Queue;
10 |
11 | import javax.microedition.khronos.egl.EGLConfig;
12 | import javax.microedition.khronos.opengles.GL10;
13 |
14 | import static android.opengl.GLES20.GL_COLOR_BUFFER_BIT;
15 | import static android.opengl.GLES20.GL_DEPTH_BUFFER_BIT;
16 | import static android.opengl.GLES20.GL_FRAMEBUFFER;
17 |
18 |
19 | public abstract class GlFrameBufferObjectRenderer implements GLSurfaceView.Renderer {
20 |
21 | private GlFramebufferObject framebufferObject;
22 | private GlFilter normalShader;
23 |
24 | private final Queue runOnDraw;
25 |
26 |
27 | protected GlFrameBufferObjectRenderer() {
28 | runOnDraw = new LinkedList();
29 | }
30 |
31 |
32 | @Override
33 | public final void onSurfaceCreated(final GL10 gl, final EGLConfig config) {
34 | framebufferObject = new GlFramebufferObject();
35 | normalShader = new GlFilter();
36 | normalShader.setup();
37 | onSurfaceCreated(config);
38 | }
39 |
40 | @Override
41 | public final void onSurfaceChanged(final GL10 gl, final int width, final int height) {
42 | framebufferObject.setup(width, height);
43 | normalShader.setFrameSize(width, height);
44 | onSurfaceChanged(width, height);
45 | GLES20.glViewport(0, 0, framebufferObject.getWidth(), framebufferObject.getHeight());
46 | }
47 |
48 | @Override
49 | public final void onDrawFrame(final GL10 gl) {
50 | synchronized (runOnDraw) {
51 | while (!runOnDraw.isEmpty()) {
52 | runOnDraw.poll().run();
53 | }
54 | }
55 | framebufferObject.enable();
56 |
57 | onDrawFrame(framebufferObject);
58 |
59 | GLES20.glBindFramebuffer(GL_FRAMEBUFFER, 0);
60 |
61 | GLES20.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
62 | normalShader.draw(framebufferObject.getTexName(), null);
63 |
64 | }
65 |
66 | @Override
67 | protected void finalize() throws Throwable {
68 |
69 | }
70 |
71 | public abstract void onSurfaceCreated(EGLConfig config);
72 |
73 | public abstract void onSurfaceChanged(int width, int height);
74 |
75 | public abstract void onDrawFrame(GlFramebufferObject fbo);
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/GlPixelationFilter.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter.GlFilter;
6 |
7 | public class GlPixelationFilter extends GlFilter {
8 |
9 | private static final String PIXELATION_FRAGMENT_SHADER = "" +
10 | "precision highp float;\n" +
11 |
12 | "varying highp vec2 vTextureCoord;\n" +
13 |
14 | "uniform float imageWidthFactor;\n" +
15 | "uniform float imageHeightFactor;\n" +
16 | "uniform lowp sampler2D sTexture;\n" +
17 | "uniform float pixel;\n" +
18 |
19 | "void main()\n" +
20 | "{\n" +
21 | " vec2 uv = vTextureCoord.xy;\n" +
22 | " float dx = pixel * imageWidthFactor;\n" +
23 | " float dy = pixel * imageHeightFactor;\n" +
24 | " vec2 coord = vec2(dx * floor(uv.x / dx), dy * floor(uv.y / dy));\n" +
25 | " vec3 tc = texture2D(sTexture, coord).xyz;\n" +
26 | " gl_FragColor = vec4(tc, 1.0);\n" +
27 | "}";
28 |
29 | public GlPixelationFilter() {
30 | super(DEFAULT_VERTEX_SHADER, PIXELATION_FRAGMENT_SHADER);
31 | }
32 |
33 | private float pixel = 1f;
34 | private float imageWidthFactor = 1f / 720;
35 | private float imageHeightFactor = 1f / 720;
36 |
37 | @Override
38 | public void setFrameSize(int width, int height) {
39 | super.setFrameSize(width, height);
40 | imageWidthFactor = 1f / width;
41 | imageHeightFactor = 1f / height;
42 | }
43 |
44 | @Override
45 | public void onDraw() {
46 | GLES20.glUniform1f(getHandle("pixel"), pixel);
47 | GLES20.glUniform1f(getHandle("imageWidthFactor"), imageWidthFactor);
48 | GLES20.glUniform1f(getHandle("imageHeightFactor"), imageHeightFactor);
49 | }
50 |
51 | public void setPixel(final float pixel) {
52 | this.pixel = pixel;
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/gl/GlSurfaceTexture.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.gl;
2 |
3 | import android.graphics.SurfaceTexture;
4 |
5 | public class GlSurfaceTexture implements SurfaceTexture.OnFrameAvailableListener {
6 |
7 | private SurfaceTexture surfaceTexture;
8 | private SurfaceTexture.OnFrameAvailableListener onFrameAvailableListener;
9 |
10 | public GlSurfaceTexture(final int texName) {
11 | surfaceTexture = new SurfaceTexture(texName);
12 | surfaceTexture.setOnFrameAvailableListener(this);
13 | }
14 |
15 |
16 | public void setOnFrameAvailableListener(final SurfaceTexture.OnFrameAvailableListener l) {
17 | onFrameAvailableListener = l;
18 | }
19 |
20 |
21 | public int getTextureTarget() {
22 | return GlPreview.GL_TEXTURE_EXTERNAL_OES;
23 | }
24 |
25 | public void updateTexImage() {
26 | surfaceTexture.updateTexImage();
27 | }
28 |
29 | public void getTransformMatrix(final float[] mtx) {
30 | surfaceTexture.getTransformMatrix(mtx);
31 | }
32 |
33 | public SurfaceTexture getSurfaceTexture() {
34 | return surfaceTexture;
35 | }
36 |
37 | public void onFrameAvailable(final SurfaceTexture surfaceTexture) {
38 | if (onFrameAvailableListener != null) {
39 | onFrameAvailableListener.onFrameAvailable(this.surfaceTexture);
40 | }
41 | }
42 |
43 | public void release() {
44 | surfaceTexture.release();
45 | }
46 | }
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/glplayer/GestureGpuPlayerView.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.glplayer;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 |
8 | import com.fahimfarhan.simplevideoeditor.mp4composer.guestures.AllGestureDetector;
9 |
10 | public class GestureGpuPlayerView extends GPUPlayerView implements View.OnTouchListener {
11 |
12 | private AllGestureDetector allGestureDetector;
13 | private float baseWidthSize = 0;
14 |
15 |
16 | public GestureGpuPlayerView(Context context) {
17 | super(context);
18 | init();
19 | }
20 |
21 | public GestureGpuPlayerView(Context context, AttributeSet attrs) {
22 | super(context, attrs);
23 | init();
24 | }
25 |
26 | private void init() {
27 | allGestureDetector = new AllGestureDetector(this);
28 | allGestureDetector.setLimitScaleMin(0.1f);
29 | allGestureDetector.noRotate();
30 | }
31 |
32 | public void setBaseWidthSize(float baseSize) {
33 | this.baseWidthSize = baseSize;
34 | requestLayout();
35 | }
36 |
37 | // View.OnTouchListener
38 | @Override
39 | public boolean onTouch(View v, MotionEvent event) {
40 | if(allGestureDetector!=null){
41 | allGestureDetector.onTouch(event);
42 | return true;
43 | }
44 | return false;
45 | }
46 |
47 | @Override
48 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
49 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
50 | if (videoAspect == DEFAULT_ASPECT || baseWidthSize == 0) return;
51 |
52 | if (videoAspect == 1.0f) {
53 | setMeasuredDimension((int) baseWidthSize, (int) baseWidthSize);
54 | return;
55 | }
56 | setMeasuredDimension((int) baseWidthSize, (int) (baseWidthSize / videoAspect));
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/glplayer/PlayerScaleType.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.glplayer;
2 |
3 | public enum PlayerScaleType {
4 | RESIZE_FIT_WIDTH, //
5 | RESIZE_FIT_HEIGHT, //
6 | RESIZE_NONE, // The specified aspect ratio is ignored.
7 | ;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/logger/AndroidLogger.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.logger;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * The default implementation of the {@link Logger} for Android.
7 | */
8 | public class AndroidLogger implements Logger{
9 |
10 | @Override
11 | public void debug(String tag, String message) {
12 | Log.d(tag, message);
13 | }
14 |
15 | @Override
16 | public void error(String tag, String message, Throwable error) {
17 | Log.e(tag, message, error);
18 | }
19 |
20 | @Override
21 | public void warning(String tag, String message) {
22 | Log.w(tag, message);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/logger/Logger.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.logger;
2 |
3 | /**
4 | * The logger interface used to log information to the console.
5 | */
6 | public interface Logger {
7 |
8 | /**
9 | * Logs a debug message.
10 | *
11 | * @param tag The tag of the message.
12 | * @param message The message body.
13 | */
14 | void debug(String tag, String message);
15 |
16 | /**
17 | * Logs an error message.
18 | *
19 | * @param tag The tag of the message.
20 | * @param message The message body.
21 | * @param error The cause of the error.
22 | */
23 | void error(String tag, String message, Throwable error);
24 |
25 | /**
26 | * Logs a warning message.
27 | *
28 | * @param tag The tag of the message.
29 | * @param message The message body.
30 | */
31 | void warning(String tag, String message);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/source/DataSource.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.source;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.io.FileDescriptor;
6 |
7 | public interface DataSource {
8 | @NonNull
9 | FileDescriptor getFileDescriptor();
10 |
11 | interface Listener {
12 | void onError(Exception e);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/source/FileDescriptorDataSource.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.source;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.io.FileDescriptor;
6 |
7 | public class FileDescriptorDataSource implements DataSource {
8 |
9 | private final FileDescriptor fileDescriptor;
10 |
11 | public FileDescriptorDataSource(FileDescriptor fileDescriptor) {
12 | this.fileDescriptor = fileDescriptor;
13 | }
14 |
15 | @NonNull
16 | @Override
17 | public FileDescriptor getFileDescriptor() {
18 | return fileDescriptor;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/source/FilePathDataSource.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.source;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.logger.Logger;
6 |
7 | import java.io.File;
8 | import java.io.FileDescriptor;
9 | import java.io.FileInputStream;
10 | import java.io.FileNotFoundException;
11 | import java.io.IOException;
12 |
13 | public class FilePathDataSource implements DataSource {
14 |
15 | private final static String TAG = FilePathDataSource.class.getSimpleName();
16 |
17 | private FileDescriptor fileDescriptor;
18 |
19 | public FilePathDataSource(@NonNull String filePath, @NonNull Logger logger, @NonNull Listener listener) {
20 |
21 | final File srcFile = new File(filePath);
22 | final FileInputStream fileInputStream;
23 | try {
24 | fileInputStream = new FileInputStream(srcFile);
25 | } catch (FileNotFoundException e) {
26 | logger.error(TAG, "Unable to find file", e);
27 | listener.onError(e);
28 | return;
29 | }
30 |
31 | try {
32 | fileDescriptor = fileInputStream.getFD();
33 | } catch (IOException e) {
34 | logger.error(TAG, "Unable to read input file", e);
35 | listener.onError(e);
36 | }
37 | }
38 |
39 | @NonNull
40 | @Override
41 | public FileDescriptor getFileDescriptor() {
42 | return fileDescriptor;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/mp4composer/mp4compose/source/UriDataSource.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.source;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.ParcelFileDescriptor;
6 |
7 | import androidx.annotation.NonNull;
8 |
9 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.logger.Logger;
10 |
11 | import java.io.FileDescriptor;
12 | import java.io.FileNotFoundException;
13 |
14 | public class UriDataSource implements DataSource {
15 |
16 | private final static String TAG = UriDataSource.class.getSimpleName();
17 |
18 | private FileDescriptor fileDescriptor;
19 |
20 | public UriDataSource(@NonNull Uri uri, @NonNull Context context, @NonNull Logger logger, @NonNull Listener listener) {
21 | ParcelFileDescriptor parcelFileDescriptor = null;
22 | try {
23 | parcelFileDescriptor = context.getContentResolver().openFileDescriptor(uri, "r");
24 | } catch (FileNotFoundException e) {
25 | logger.error(TAG, "Unable to find file", e);
26 | listener.onError(e);
27 | return;
28 | }
29 | fileDescriptor = parcelFileDescriptor.getFileDescriptor();
30 | }
31 |
32 | @NonNull
33 | @Override
34 | public FileDescriptor getFileDescriptor() {
35 | return fileDescriptor;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/videoeditor/VideoEditModel.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.videoeditor;
2 |
3 |
4 | import android.graphics.Bitmap;
5 | import android.net.Uri;
6 | import android.util.Log;
7 | import android.util.Size;
8 |
9 | import androidx.annotation.Nullable;
10 |
11 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.FilterType;
12 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.filter.GlFilter;
13 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.logger.Logger;
14 |
15 |
16 | /**
17 | * @brief: this model will hold the values of different edit parameters
18 | * eg, trimStart, trimEnd, currentFilter, etc...
19 | * */
20 | public class VideoEditModel {
21 | // todo: add variables accordingly. Nothing stays in the VideoEditFragment2
22 | public static float ratioX = 1;
23 | public static float ratioY = 1;
24 | public static float aspectRatio = ratioX/ratioY; // todo: maybe add getter, setter for aspect ratio to be used with onClick changeAspectRatio...
25 | // making them static for convenience/ testing. change if necessary
26 | public Size resolution = null;
27 | boolean playWhenReady = true;
28 | int currentWindow = 0;
29 | long playbackPosition = 0;
30 |
31 | Uri selectedVideoUri=null;
32 |
33 | long mStartTimeMs = 0;
34 | long mEndTimeMs = 0;
35 | long mDurationMs = 0;
36 | private float baseWidthSize = 0;
37 |
38 | private String destPath = null; // "// some path";
39 |
40 | FilterType currentFilterType = null; // = filters[0];
41 | GlFilter composerGlFilter = null; // <-- use with the mp4composer
42 | GlFilter previewGlFilter = null; // <-- use with glGestureView
43 | String sourcePath = null;
44 |
45 | int imageMaxHeight = 0;
46 | int imageMaxWidth = 0;
47 | public Bitmap thumbnail;
48 | final Logger mylogger = new Logger() {
49 | @Override
50 | public void debug(String tag, String message) {
51 | Log.d(tag, message);
52 | }
53 |
54 | @Override
55 | public void error(String tag, String message, Throwable error) {
56 | Log.e(tag, "Message: "+message + ". Error: "+error.getLocalizedMessage());
57 | }
58 |
59 | @Override
60 | public void warning(String tag, String message) {
61 | Log.w(tag, message);
62 | }
63 | };
64 |
65 | public enum AspectRatioType{
66 | SQUARE, PORTRAIT,LANDSCAPE
67 | };
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/videoeditor/VideoEditorContract.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.videoeditor;
2 |
3 | import android.graphics.Bitmap;
4 | import android.util.Size;
5 | import android.widget.SeekBar;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.constraintlayout.widget.ConstraintLayout;
9 |
10 | import com.fahimfarhan.simplevideoeditor.customview.AwesomeVideoView;
11 | import com.fahimfarhan.simplevideoeditor.mp4composer.mp4compose.FilterType;
12 |
13 | import idv.luchafang.videotrimmer.VideoTrimmerView;
14 |
15 |
16 | public interface VideoEditorContract {
17 | interface View {
18 | VideoTrimmerView getVideoTrimmerView();
19 | VideoTrimmerView.OnSelectedRangeChangedListener getOnSelectedRangeChangedListener();
20 | ConstraintLayout getFilterSeekBarLayout();
21 | AwesomeVideoView getAwesomeVideoView();
22 | VideoEditorFragment2.CallBack getOnCallBack();
23 | void startWaitingFragment();
24 | void stopWaitingFragment();
25 | }
26 |
27 | interface Presenter {
28 | void startConversion();
29 | void initializePlayer();
30 | void hideSystemUi();
31 | void releasePlayer();
32 | void displayTrimmerView();
33 | Bitmap getThumbnail();
34 | void changeFilter(FilterType type);
35 | SeekBar.OnSeekBarChangeListener getOnFilterSeekBarChangedListener();
36 | Size getResolution();
37 | void setAspectRatio(VideoEditModel.AspectRatioType type);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fahimfarhan/simplevideoeditor/videoeditor/WaitingFragment.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor.videoeditor;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.annotation.Nullable;
11 | import androidx.fragment.app.Fragment;
12 |
13 | import com.fahimfarhan.simplevideoeditor.R;
14 |
15 | public class WaitingFragment extends Fragment implements View.OnClickListener {
16 | public static final String TAG = WaitingFragment.class.getSimpleName();
17 |
18 | private View fragmentRootView;
19 |
20 | @Nullable
21 | @Override
22 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
23 | fragmentRootView = inflater.inflate(R.layout.fragment_video_waiting, container, false);
24 | fragmentRootView.setOnClickListener(this);
25 | initGui();
26 | return fragmentRootView;
27 | }
28 |
29 | private void initGui() { }
30 |
31 | @Override
32 | public void onClick(View v) {
33 | Log.e(TAG, "click detected!");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_fiber_circle_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_movie_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_smile_heart_eyes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/drawable/ic_smile_heart_eyes.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_video_effects.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_video_format.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_video_trim.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/lookup_sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/drawable/lookup_sample.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/mountain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/drawable/mountain.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/round_edit_option_notselected.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/round_edit_option_selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sample_bitmap.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/drawable/sample_bitmap.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/video_crop_btn.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/video_crop_notselected.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/video_crop_selected.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
23 |
24 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/awesome_video_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
11 |
12 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/filter_preview_video_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_start.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_video_waiting.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_videoeditor2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
24 |
25 |
33 |
34 |
35 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/video_edit_options_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/video_layout_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
27 |
28 |
36 |
37 |
38 |
39 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/video_layout_trim.xml:
--------------------------------------------------------------------------------
1 |
11 |
22 |
32 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/video_layout_waiting.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/raw/tone_cuver_sample.acv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/app/src/main/res/raw/tone_cuver_sample.acv
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #5DAC81
4 | #4F916D
5 | #5DAC81
6 | #1C1C1C
7 |
8 | #7f000000
9 | #ffffffff
10 | #00FFFFFF
11 | #FFFFFF
12 | #70000000
13 | #000000
14 | #F4F5F6
15 | #FFFFFF
16 | #E7ECF1
17 | #F4F5F6
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 32dp
4 | 2dp
5 | 4dp
6 | 8dp
7 | 64dp
8 | 60dp
9 | 16dp
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SImpleVideoEditor
3 | Continue
4 | Video trim duration
5 | toast_cannot_retrieve_selected_video
6 | label_select_video
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/fahimfarhan/simplevideoeditor/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.fahimfarhan.simplevideoeditor;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.72'
5 |
6 | repositories {
7 | google()
8 | jcenter()
9 |
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:4.0.1'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 |
15 |
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | google()
24 | jcenter()
25 | maven { url 'https://jitpack.io' }
26 |
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/docs/crop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/docs/crop.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 25 01:21:00 BDT 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':startjitpack'
2 | include ':start'
3 | include ':app'
4 | project(':app').projectDir = new File(settingsDir, './app')
5 | rootProject.name='SImpleVideoEditor'
--------------------------------------------------------------------------------
/start/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/start/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 30
7 | buildToolsVersion "30.0.2"
8 |
9 | compileOptions {
10 | sourceCompatibility JavaVersion.VERSION_1_8
11 | targetCompatibility JavaVersion.VERSION_1_8
12 | }
13 |
14 | kotlinOptions {
15 | jvmTarget = "1.8"
16 | }
17 |
18 | defaultConfig {
19 | applicationId "app.fahimfarhan.start"
20 | minSdkVersion 21
21 | targetSdkVersion 30
22 | versionCode 1
23 | versionName "1.0"
24 |
25 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
26 | }
27 |
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation project(":app"); // <-- this is the videoEditorLibrary
38 | implementation fileTree(dir: "libs", include: ["*.jar"])
39 | implementation 'androidx.appcompat:appcompat:1.2.0'
40 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
41 | testImplementation 'junit:junit:4.12'
42 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/start/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/start/src/androidTest/java/app/fahimfarhan/start/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package app.fahimfarhan.start;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("app.fahimfarhan.start", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/start/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/start/src/main/java/app/fahimfarhan/start/StartActivity.java:
--------------------------------------------------------------------------------
1 | package app.fahimfarhan.start;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import com.fahimfarhan.simplevideoeditor.MainActivity;
11 |
12 | public class StartActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_start);
18 |
19 | final Intent intent = new Intent(StartActivity.this, MainActivity.class);
20 |
21 | TextView openVideoEditor = findViewById(R.id.openVideoEditor);
22 | openVideoEditor.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View view) {
25 | startActivity(intent);
26 | }
27 | });
28 |
29 | startActivity(intent);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/start/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/start/src/main/res/layout/activity_start.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/start/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/start/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/start/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #5DAC81
4 | #4F916D
5 | #5DAC81
6 | #1C1C1C
7 |
--------------------------------------------------------------------------------
/start/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Simple Video Editor Demo
3 |
--------------------------------------------------------------------------------
/start/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/start/src/test/java/app/fahimfarhan/start/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package app.fahimfarhan.start;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/startjitpack/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/startjitpack/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 30
7 | buildToolsVersion "30.0.2"
8 |
9 | compileOptions {
10 | sourceCompatibility JavaVersion.VERSION_1_8
11 | targetCompatibility JavaVersion.VERSION_1_8
12 | }
13 |
14 | kotlinOptions {
15 | jvmTarget = "1.8"
16 | }
17 |
18 | defaultConfig {
19 | applicationId "app.fahimfarhan.startjitpack"
20 | minSdkVersion 21
21 | targetSdkVersion 30
22 | versionCode 1
23 | versionName "1.0"
24 |
25 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
26 | }
27 |
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation fileTree(dir: "libs", include: ["*.jar"])
38 | implementation 'androidx.appcompat:appcompat:1.2.0'
39 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
40 | testImplementation 'junit:junit:4.12'
41 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
42 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
43 | implementation 'com.github.fahimfarhan:SimpleVideoEditor:v1.0'
44 | }
45 |
--------------------------------------------------------------------------------
/startjitpack/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/startjitpack/src/androidTest/java/app/fahimfarhan/startjitpack/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package app.fahimfarhan.startjitpack;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("app.fahimfarhan.startjitpack", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/startjitpack/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/startjitpack/src/main/java/app/fahimfarhan/startjitpack/MainActivity.java:
--------------------------------------------------------------------------------
1 | package app.fahimfarhan.startjitpack;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main2);
14 |
15 | startActivity(new Intent(this, com.fahimfarhan.simplevideoeditor.MainActivity.class));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahimfarhan/SimpleVideoEditor/acd1b4c20b3c2be1b672c8a539c81bad933fbdf0/startjitpack/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/startjitpack/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StartJitpack
3 |
--------------------------------------------------------------------------------
/startjitpack/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/startjitpack/src/test/java/app/fahimfarhan/startjitpack/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package app.fahimfarhan.startjitpack;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------