├── .gitignore
├── .idea
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── createchance
│ │ └── demo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── template_list.json
│ ├── java
│ │ └── com
│ │ │ └── createchance
│ │ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ ├── MusicPlayerMgr.java
│ │ │ ├── model
│ │ │ ├── Scene.java
│ │ │ ├── SimpleModelManager.java
│ │ │ ├── Template.java
│ │ │ └── Work.java
│ │ │ ├── presenters
│ │ │ ├── IMain.java
│ │ │ ├── ITemplateList.java
│ │ │ ├── MainPresenter.java
│ │ │ └── TemplateListPresenter.java
│ │ │ ├── utils
│ │ │ └── DensityUtil.java
│ │ │ └── views
│ │ │ ├── MainActivity.java
│ │ │ ├── RoundProgressbar.java
│ │ │ ├── SceneListAdapter.java
│ │ │ ├── ScenesActivity.java
│ │ │ ├── SimpleDialog.java
│ │ │ ├── TemplateListActivity.java
│ │ │ ├── TemplateListAdapter.java
│ │ │ ├── VideoCheckFragment.java
│ │ │ ├── VideoEditActivity.java
│ │ │ ├── VideoTakeAndCheckActivity.java
│ │ │ ├── VideoTakeFragment.java
│ │ │ └── WorksListAdapter.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xhdpi
│ │ ├── arraw_left.png
│ │ ├── arrow_left.png
│ │ ├── done.png
│ │ ├── redo.png
│ │ ├── setting.png
│ │ ├── switch_camera.png
│ │ ├── take_one_work.png
│ │ ├── video_play_normal.png
│ │ └── video_play_pressed.png
│ │ ├── drawable-xxhdpi
│ │ ├── scene_delete.png
│ │ └── scene_plus.png
│ │ ├── drawable
│ │ ├── common_btn_bg.xml
│ │ ├── filter1.png
│ │ ├── filter10.png
│ │ ├── filter11.png
│ │ ├── filter2.png
│ │ ├── filter3.png
│ │ ├── filter4.png
│ │ ├── filter5.png
│ │ ├── filter6.png
│ │ ├── filter7.png
│ │ ├── filter8.png
│ │ ├── filter9.png
│ │ ├── ic_launcher_background.xml
│ │ ├── video_play.xml
│ │ └── watermark.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_scenes.xml
│ │ ├── activity_template_list.xml
│ │ ├── activity_video_edit.xml
│ │ ├── activity_video_take_and_check.xml
│ │ ├── dialog_simple.xml
│ │ ├── edit_panel_add_bgm.xml
│ │ ├── edit_panel_add_filter_and_watermark.xml
│ │ ├── edit_panel_cut.xml
│ │ ├── edit_panel_remove_bgm.xml
│ │ ├── fragment_video_check.xml
│ │ ├── fragment_video_take.xml
│ │ ├── list_item_scene.xml
│ │ ├── list_item_template.xml
│ │ └── list_item_works.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-en
│ │ ├── strings_main.xml
│ │ ├── strings_scenes.xml
│ │ ├── strings_template_list.xml
│ │ └── strings_video_edit.xml
│ │ ├── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings_main.xml
│ │ ├── strings_scenes.xml
│ │ ├── strings_template_list.xml
│ │ ├── strings_video_edit.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── file_paths.xml
│ └── test
│ └── java
│ └── com
│ └── createchance
│ └── demo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── logo
├── 1.png
├── 2.png
├── 3.png
├── PNG 1.png
├── PNG 2.png
└── PNG 3-01.png
├── settings.gradle
├── simplecameraview
├── build.gradle
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── libcameraview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── api14
│ │ └── com
│ │ │ └── createchance
│ │ │ └── simplecameraview
│ │ │ ├── Camera1.java
│ │ │ └── TextureViewPreview.java
│ ├── api21
│ │ └── com
│ │ │ └── createchance
│ │ │ └── simplecameraview
│ │ │ ├── Camera2.java
│ │ │ └── Camera2DeviceInfo.java
│ ├── java
│ │ └── com
│ │ │ └── createchance
│ │ │ └── simplecameraview
│ │ │ ├── AspectRatio.java
│ │ │ ├── CameraConfig.java
│ │ │ ├── CameraImpl.java
│ │ │ ├── CameraView.java
│ │ │ ├── Constants.java
│ │ │ ├── DisplayOrientationDetector.java
│ │ │ ├── ICameraCallback.java
│ │ │ ├── Logger.java
│ │ │ ├── PreviewImpl.java
│ │ │ ├── Size.java
│ │ │ └── SizeMap.java
│ └── res
│ │ ├── layout-v14
│ │ └── texture_view.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── libcameraview
│ └── ExampleUnitTest.java
├── simplevideoeditor
├── .gitignore
├── CMakeLists.txt
├── build.gradle
├── jni
│ ├── audio-mix.cpp
│ └── yuv-decoder.c
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── createchance
│ │ └── simplevideoeditor
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── createchance
│ │ └── simplevideoeditor
│ │ ├── Config.java
│ │ ├── Constants.java
│ │ ├── EditListener.java
│ │ ├── Logger.java
│ │ ├── VideoEditorManager.java
│ │ ├── VideoUtil.java
│ │ ├── WorkRunner.java
│ │ ├── actions
│ │ ├── AbstractAction.java
│ │ ├── AudioTransCoder.java
│ │ ├── VideoBgmAddAction.java
│ │ ├── VideoBgmRemoveAction.java
│ │ ├── VideoCutAction.java
│ │ ├── VideoFilterAddAction.java
│ │ └── VideoMergeAction.java
│ │ ├── gles
│ │ ├── AbstractFilter.java
│ │ ├── EglUtil.java
│ │ ├── InputSurface.java
│ │ ├── NoFilter.java
│ │ ├── OesFilter.java
│ │ ├── OpenGlUtil.java
│ │ ├── OutputSurface.java
│ │ ├── Shaders.java
│ │ ├── VideoFrameDrawer.java
│ │ ├── VideoFrameLookupFilter.java
│ │ └── WaterMarkFilter.java
│ │ └── gpuimage
│ │ ├── GPUImage.java
│ │ ├── GPUImage3x3ConvolutionFilter.java
│ │ ├── GPUImage3x3TextureSamplingFilter.java
│ │ ├── GPUImageAddBlendFilter.java
│ │ ├── GPUImageAlphaBlendFilter.java
│ │ ├── GPUImageBilateralFilter.java
│ │ ├── GPUImageBoxBlurFilter.java
│ │ ├── GPUImageBrightnessFilter.java
│ │ ├── GPUImageBulgeDistortionFilter.java
│ │ ├── GPUImageCGAColorspaceFilter.java
│ │ ├── GPUImageChromaKeyBlendFilter.java
│ │ ├── GPUImageColorBalanceFilter.java
│ │ ├── GPUImageColorBlendFilter.java
│ │ ├── GPUImageColorBurnBlendFilter.java
│ │ ├── GPUImageColorDodgeBlendFilter.java
│ │ ├── GPUImageColorInvertFilter.java
│ │ ├── GPUImageColorMatrixFilter.java
│ │ ├── GPUImageContrastFilter.java
│ │ ├── GPUImageCrosshatchFilter.java
│ │ ├── GPUImageDarkenBlendFilter.java
│ │ ├── GPUImageDifferenceBlendFilter.java
│ │ ├── GPUImageDilationFilter.java
│ │ ├── GPUImageDirectionalSobelEdgeDetectionFilter.java
│ │ ├── GPUImageDissolveBlendFilter.java
│ │ ├── GPUImageDivideBlendFilter.java
│ │ ├── GPUImageEmbossFilter.java
│ │ ├── GPUImageExclusionBlendFilter.java
│ │ ├── GPUImageExposureFilter.java
│ │ ├── GPUImageFalseColorFilter.java
│ │ ├── GPUImageFilter.java
│ │ ├── GPUImageFilterGroup.java
│ │ ├── GPUImageGammaFilter.java
│ │ ├── GPUImageGaussianBlurFilter.java
│ │ ├── GPUImageGlassSphereFilter.java
│ │ ├── GPUImageGrayscaleFilter.java
│ │ ├── GPUImageHalftoneFilter.java
│ │ ├── GPUImageHardLightBlendFilter.java
│ │ ├── GPUImageHazeFilter.java
│ │ ├── GPUImageHighlightShadowFilter.java
│ │ ├── GPUImageHueBlendFilter.java
│ │ ├── GPUImageHueFilter.java
│ │ ├── GPUImageKuwaharaFilter.java
│ │ ├── GPUImageLaplacianFilter.java
│ │ ├── GPUImageLevelsFilter.java
│ │ ├── GPUImageLightenBlendFilter.java
│ │ ├── GPUImageLinearBurnBlendFilter.java
│ │ ├── GPUImageLookupFilter.java
│ │ ├── GPUImageLuminosityBlendFilter.java
│ │ ├── GPUImageMixBlendFilter.java
│ │ ├── GPUImageMonochromeFilter.java
│ │ ├── GPUImageMultiplyBlendFilter.java
│ │ ├── GPUImageNativeLibrary.java
│ │ ├── GPUImageNonMaximumSuppressionFilter.java
│ │ ├── GPUImageNormalBlendFilter.java
│ │ ├── GPUImageOpacityFilter.java
│ │ ├── GPUImageOverlayBlendFilter.java
│ │ ├── GPUImagePixelationFilter.java
│ │ ├── GPUImagePosterizeFilter.java
│ │ ├── GPUImageRGBDilationFilter.java
│ │ ├── GPUImageRGBFilter.java
│ │ ├── GPUImageRenderer.java
│ │ ├── GPUImageSaturationBlendFilter.java
│ │ ├── GPUImageSaturationFilter.java
│ │ ├── GPUImageScreenBlendFilter.java
│ │ ├── GPUImageSepiaFilter.java
│ │ ├── GPUImageSharpenFilter.java
│ │ ├── GPUImageSketchFilter.java
│ │ ├── GPUImageSmoothToonFilter.java
│ │ ├── GPUImageSobelEdgeDetection.java
│ │ ├── GPUImageSobelThresholdFilter.java
│ │ ├── GPUImageSoftLightBlendFilter.java
│ │ ├── GPUImageSourceOverBlendFilter.java
│ │ ├── GPUImageSphereRefractionFilter.java
│ │ ├── GPUImageSubtractBlendFilter.java
│ │ ├── GPUImageSwirlFilter.java
│ │ ├── GPUImageThresholdEdgeDetection.java
│ │ ├── GPUImageToneCurveFilter.java
│ │ ├── GPUImageToonFilter.java
│ │ ├── GPUImageTransformFilter.java
│ │ ├── GPUImageTwoInputFilter.java
│ │ ├── GPUImageTwoPassFilter.java
│ │ ├── GPUImageTwoPassTextureSamplingFilter.java
│ │ ├── GPUImageView.java
│ │ ├── GPUImageVignetteFilter.java
│ │ ├── GPUImageWeakPixelInclusionFilter.java
│ │ ├── GPUImageWhiteBalanceFilter.java
│ │ ├── OpenGlUtils.java
│ │ ├── PixelBuffer.java
│ │ ├── Rotation.java
│ │ └── util
│ │ └── TextureRotationUtil.java
│ └── test
│ └── java
│ └── com
│ └── createchance
│ └── simplevideoeditor
│ └── ExampleUnitTest.java
└── simplevideoplayer
├── build.gradle
├── build
├── generated
│ └── source
│ │ ├── buildConfig
│ │ └── debug
│ │ │ └── com
│ │ │ └── qihoo360
│ │ │ └── mobilesafe
│ │ │ └── myvideo
│ │ │ └── simplevideoplayer
│ │ │ └── BuildConfig.java
│ │ └── r
│ │ └── debug
│ │ └── com
│ │ └── qihoo360
│ │ └── mobilesafe
│ │ └── myvideo
│ │ └── simplevideoplayer
│ │ └── R.java
├── intermediates
│ ├── attr
│ │ └── R.txt
│ ├── bundles
│ │ └── debug
│ │ │ ├── R.txt
│ │ │ └── res
│ │ │ └── values
│ │ │ └── values.xml
│ ├── incremental
│ │ ├── compileDebugAidl
│ │ │ └── dependency.store
│ │ ├── debug-mergeJniLibs
│ │ │ └── merge-state
│ │ ├── mergeDebugAssets
│ │ │ └── merger.xml
│ │ ├── mergeDebugJniLibFolders
│ │ │ └── merger.xml
│ │ ├── mergeDebugShaders
│ │ │ └── merger.xml
│ │ └── packageDebugResources
│ │ │ ├── compile-file-map.properties
│ │ │ ├── merged.dir
│ │ │ └── values
│ │ │ │ └── values.xml
│ │ │ └── merger.xml
│ ├── intermediate-jars
│ │ └── debug
│ │ │ ├── classes.jar
│ │ │ └── res.jar
│ ├── javaPrecompile
│ │ └── debug
│ │ │ └── annotationProcessors.json
│ ├── manifests
│ │ ├── aapt
│ │ │ └── debug
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ └── output.json
│ │ └── full
│ │ │ └── debug
│ │ │ ├── AndroidManifest.xml
│ │ │ └── output.json
│ ├── res
│ │ ├── debug
│ │ │ └── output.json
│ │ └── symbol-table-with-package
│ │ │ └── debug
│ │ │ └── package-aware-r.txt
│ └── transforms
│ │ └── mergeJniLibs
│ │ └── debug
│ │ └── __content__.json
└── outputs
│ └── logs
│ └── manifest-merger-debug-report.txt
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── qihoo360
│ └── mobilesafe
│ └── myvideo
│ └── simplevideoplayer
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── createchance
│ │ ├── IGestureListener.java
│ │ ├── PlayRequest.java
│ │ ├── SimpleVideoPlayer.java
│ │ ├── Utils.java
│ │ └── VideoPlayerCallback.java
└── res
│ └── values
│ ├── attrs.xml
│ └── strings.xml
└── test
└── java
└── com
└── qihoo360
└── mobilesafe
└── myvideo
└── simplevideoplayer
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.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 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.createchance.simplevideoeditordemo"
7 | minSdkVersion 18
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled true
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | debug {
19 | minifyEnabled false
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation fileTree(include: ['*.jar'], dir: 'libs')
26 | implementation 'com.android.support:appcompat-v7:26.1.0'
27 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
28 | testImplementation 'junit:junit:4.12'
29 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
31 | implementation project(':simplevideoeditor')
32 | implementation 'com.android.support:recyclerview-v7:26.1.0'
33 | implementation 'com.android.support:cardview-v7:26.1.0'
34 | implementation 'com.github.bumptech.glide:glide:4.8.0'
35 | implementation 'com.google.code.gson:gson:2.2.4'
36 | implementation project(':simplevideoplayer')
37 | implementation project(':simplecameraview')
38 | }
39 |
--------------------------------------------------------------------------------
/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/createchance/demo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.createchance.demo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
32 |
35 |
36 |
37 |
38 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/assets/template_list.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "scripts": [
4 | "想你深情的眼",
5 | "是如何越过沧桑的墙",
6 | "穿透我",
7 | "红尘过往",
8 | "望断夜雨西窗"
9 | ]
10 | },
11 | {
12 | "scripts": [
13 | "人生路途走走停停",
14 | "身边风景虚虚实实",
15 | "时刻保持好奇心",
16 | "提醒自己",
17 | "做个有趣的人",
18 | "便是旅行的意义"
19 | ]
20 | },
21 | {
22 | "scripts": [
23 | "跟你在一起的时光",
24 | "全都很耀眼",
25 | "因为天气好",
26 | "因为天气不好",
27 | "因为天气刚刚好",
28 | "每一天,都很美好"
29 | ]
30 | },
31 | {
32 | "scripts": [
33 | "希望有天",
34 | "不用大笑,也会快乐",
35 | "不用说谎,也深信不疑"
36 | ]
37 | }
38 | ]
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import com.createchance.simplevideoeditor.VideoEditorManager;
7 |
8 | /**
9 | * ${DESC}
10 | *
11 | * @author createchance
12 | * @date 03/05/2018
13 | */
14 | public class DemoApplication extends Application {
15 |
16 | private static Context mContext;
17 |
18 | @Override
19 | public void onCreate() {
20 | super.onCreate();
21 |
22 | mContext = this;
23 |
24 | VideoEditorManager.getManager().init(this);
25 | }
26 |
27 | public static Context getContext() {
28 | return mContext;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/model/Scene.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.model;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * ${DESC}
9 | *
10 | * @author createchance
11 | * @date 2018/8/19
12 | */
13 | public class Scene {
14 | public String script;
15 | public Bitmap thumbnail;
16 | public File video;
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/model/SimpleModelManager.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.model;
2 |
3 | import com.createchance.demo.DemoApplication;
4 | import com.createchance.simplevideoeditor.actions.AbstractAction;
5 |
6 | import org.json.JSONArray;
7 | import org.json.JSONException;
8 |
9 | import java.io.BufferedReader;
10 | import java.io.IOException;
11 | import java.io.InputStream;
12 | import java.io.InputStreamReader;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * ${DESC}
18 | *
19 | * @author createchance
20 | * @date 2018/8/19
21 | */
22 | public class SimpleModelManager {
23 |
24 | private static SimpleModelManager sInstance;
25 |
26 | private List mActionList;
27 |
28 | private Template mCurrentTemplate;
29 |
30 | private List mSceneList;
31 |
32 | private SimpleModelManager() {
33 |
34 | }
35 |
36 | public synchronized static SimpleModelManager getInstance() {
37 | if (sInstance == null) {
38 | sInstance = new SimpleModelManager();
39 | }
40 |
41 | return sInstance;
42 | }
43 |
44 | public List getWorksList() {
45 | List workList = new ArrayList<>();
46 |
47 | return workList;
48 | }
49 |
50 | public List getTemplateList() {
51 | List templateList = new ArrayList<>();
52 | try {
53 | InputStream inputStream = DemoApplication.getContext().getAssets().open("template_list.json");
54 | InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
55 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
56 | StringBuilder stringBuilder = new StringBuilder();
57 | String line;
58 | while ((line = bufferedReader.readLine()) != null) {
59 | stringBuilder.append(line);
60 | }
61 | JSONArray jsonArray = new JSONArray(stringBuilder.toString());
62 | for (int i = 0; i < jsonArray.length(); i++) {
63 | Template template = Template.fromJson(jsonArray.getString(i));
64 | templateList.add(template);
65 | }
66 | } catch (IOException e) {
67 | e.printStackTrace();
68 | } catch (JSONException e) {
69 | e.printStackTrace();
70 | }
71 | return templateList;
72 | }
73 |
74 | public Template getCurrentTemplate() {
75 | return mCurrentTemplate;
76 | }
77 |
78 | public void setCurrentTemplate(Template mCurrentTemplate) {
79 | this.mCurrentTemplate = mCurrentTemplate;
80 | }
81 |
82 | public List getSceneList() {
83 | return mSceneList;
84 | }
85 |
86 | public void setSceneList(List mSceneList) {
87 | this.mSceneList = mSceneList;
88 | }
89 |
90 | public void setEditActionList(List actionList) {
91 | this.mActionList = actionList;
92 | }
93 |
94 | public List getEditActionList() {
95 | return mActionList;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/model/Template.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.model;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.annotations.SerializedName;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * ${DESC}
10 | *
11 | * @author createchance
12 | * @date 2018/8/19
13 | */
14 | public class Template {
15 | @SerializedName("scripts")
16 | public List scriptList;
17 |
18 | public static Template fromJson(String json) {
19 | return new Gson().fromJson(json, Template.class);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/model/Work.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.model;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * ${DESC}
7 | *
8 | * @author createchance
9 | * @date 2018/8/18
10 | */
11 | public class Work {
12 | public File video;
13 | public long duration;
14 | public String title;
15 | public long createTime;
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/presenters/IMain.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.presenters;
2 |
3 | import com.createchance.demo.model.Work;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * ${DESC}
9 | *
10 | * @author createchance
11 | * @date 2018/8/19
12 | */
13 | public interface IMain {
14 | interface View {
15 | void showWorksList(List workList);
16 | }
17 |
18 | interface Presenter {
19 | void getWorksList();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/presenters/ITemplateList.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.presenters;
2 |
3 | import com.createchance.demo.model.Template;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * ${DESC}
9 | *
10 | * @author createchance
11 | * @date 2018/8/19
12 | */
13 | public interface ITemplateList {
14 | interface View {
15 | void showTemplateList(List templateList);
16 | }
17 | interface Presenter {
18 | void getTemplateList();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/presenters/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.presenters;
2 |
3 | import com.createchance.demo.model.SimpleModelManager;
4 |
5 | /**
6 | * ${DESC}
7 | *
8 | * @author createchance
9 | * @date 2018/8/19
10 | */
11 | public class MainPresenter implements IMain.Presenter {
12 |
13 | private final IMain.View mView;
14 |
15 | public MainPresenter(IMain.View view) {
16 | this.mView = view;
17 | }
18 |
19 | @Override
20 | public void getWorksList() {
21 | mView.showWorksList(SimpleModelManager.getInstance().getWorksList());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/presenters/TemplateListPresenter.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.presenters;
2 |
3 | import com.createchance.demo.model.SimpleModelManager;
4 |
5 | /**
6 | * ${DESC}
7 | *
8 | * @author createchance
9 | * @date 2018/8/19
10 | */
11 | public class TemplateListPresenter implements ITemplateList.Presenter {
12 | private final ITemplateList.View mView;
13 |
14 | public TemplateListPresenter(ITemplateList.View view) {
15 | this.mView = view;
16 | }
17 |
18 | @Override
19 | public void getTemplateList() {
20 | mView.showTemplateList(SimpleModelManager.getInstance().getTemplateList());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/utils/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.utils;
2 |
3 | import android.content.Context;
4 |
5 |
6 | public class DensityUtil {
7 |
8 |
9 | private DensityUtil() {
10 | }
11 |
12 | /**
13 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
14 | */
15 | public static int dpToPx(Context context, float dpValue) {
16 | final float scale = context.getResources().getDisplayMetrics().density;
17 | return (int) (dpValue * scale + 0.5f);
18 | }
19 |
20 | /**
21 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
22 | */
23 | public static int pxToDp(Context context, float pxValue) {
24 | final float scale = context.getResources().getDisplayMetrics().density;
25 | return (int) (pxValue / scale + 0.5f);
26 | }
27 |
28 | /**
29 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
30 | */
31 | public static float dpToPxDob(Context context, float dpValue) {
32 | final float scale = context.getResources().getDisplayMetrics().density;
33 | return (dpValue * scale + 0.5f);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/views/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.views;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.View;
8 |
9 | import com.createchance.demo.R;
10 | import com.createchance.demo.model.Work;
11 | import com.createchance.demo.presenters.IMain;
12 | import com.createchance.demo.presenters.MainPresenter;
13 |
14 | import java.util.List;
15 |
16 |
17 | /**
18 | * Main ui
19 | *
20 | * @author createchance
21 | * @date 2018-03-13
22 | */
23 | public class MainActivity extends Activity implements IMain.View, View.OnClickListener {
24 | private static final String TAG = "MainActivity";
25 |
26 | private View mNoWorksTipView;
27 | private RecyclerView mWorksListView;
28 | private WorksListAdapter mWorksListAdapter;
29 |
30 | private IMain.Presenter mMainPresenter;
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_main);
36 |
37 | mNoWorksTipView = findViewById(R.id.tv_no_works_tip);
38 | mWorksListView = findViewById(R.id.rcv_works_list);
39 | findViewById(R.id.iv_take_one_work).setOnClickListener(this);
40 |
41 | mMainPresenter = new MainPresenter(this);
42 | }
43 |
44 | @Override
45 | protected void onStart() {
46 | super.onStart();
47 | mMainPresenter.getWorksList();
48 | }
49 |
50 | @Override
51 | public void showWorksList(List workList) {
52 | if (workList.size() == 0) {
53 | mWorksListView.setVisibility(View.GONE);
54 | mNoWorksTipView.setVisibility(View.VISIBLE);
55 | } else {
56 | mWorksListView.setVisibility(View.VISIBLE);
57 | mNoWorksTipView.setVisibility(View.GONE);
58 | mWorksListAdapter = new WorksListAdapter(this, workList);
59 | mWorksListView.setLayoutManager(new LinearLayoutManager(this));
60 | mWorksListView.setAdapter(mWorksListAdapter);
61 | }
62 | }
63 |
64 | @Override
65 | public void onClick(View v) {
66 | switch (v.getId()) {
67 | case R.id.iv_take_one_work:
68 | TemplateListActivity.start(this);
69 | break;
70 | default:
71 | break;
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/views/TemplateListActivity.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.views;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 |
11 | import com.createchance.demo.R;
12 | import com.createchance.demo.model.Template;
13 | import com.createchance.demo.presenters.ITemplateList;
14 | import com.createchance.demo.presenters.TemplateListPresenter;
15 |
16 | import java.util.List;
17 |
18 | public class TemplateListActivity extends Activity implements View.OnClickListener,
19 | ITemplateList.View {
20 | private static final String TAG = "TemplateListActivity";
21 |
22 | private RecyclerView mTemplateListView;
23 | private TemplateListAdapter mTemplateListAdapter;
24 |
25 | private ITemplateList.Presenter mPresenter;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_template_list);
31 |
32 | // init views
33 | findViewById(R.id.iv_back).setOnClickListener(this);
34 | findViewById(R.id.tv_custom_scene).setOnClickListener(this);
35 | mTemplateListView = findViewById(R.id.rcv_template_list);
36 |
37 | mPresenter = new TemplateListPresenter(this);
38 | mPresenter.getTemplateList();
39 | }
40 |
41 | public static void start(Context context) {
42 | Intent intent = new Intent(context, TemplateListActivity.class);
43 | context.startActivity(intent);
44 | }
45 |
46 | @Override
47 | public void onClick(View v) {
48 | switch (v.getId()) {
49 | case R.id.iv_back:
50 | finish();
51 | break;
52 | case R.id.tv_custom_scene:
53 | ScenesActivity.start(this, null, true);
54 | break;
55 | default:
56 | break;
57 | }
58 | }
59 |
60 | @Override
61 | public void showTemplateList(List templateList) {
62 | mTemplateListAdapter = new TemplateListAdapter(this, templateList);
63 | mTemplateListView.setLayoutManager(new LinearLayoutManager(this));
64 | mTemplateListView.setAdapter(mTemplateListAdapter);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/views/TemplateListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.views;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.createchance.demo.R;
11 | import com.createchance.demo.model.Template;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * ${DESC}
17 | *
18 | * @author createchance
19 | * @date 2018/8/19
20 | */
21 | public class TemplateListAdapter extends RecyclerView.Adapter {
22 |
23 | private Context mContext;
24 |
25 | private List mTemplateList;
26 |
27 | public TemplateListAdapter(Context context, List templateList) {
28 | this.mContext = context;
29 | this.mTemplateList = templateList;
30 | }
31 |
32 | @Override
33 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
34 | View itemView = LayoutInflater.from(mContext).inflate(R.layout.list_item_template, parent, false);
35 | return new ViewHolder(itemView);
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(ViewHolder holder, int position) {
40 | Template template = mTemplateList.get(position);
41 | StringBuilder stringBuilder = new StringBuilder();
42 | for (String script : template.scriptList) {
43 | stringBuilder.append(script);
44 | stringBuilder.append("\n");
45 | }
46 | holder.scripts.setText(stringBuilder.toString());
47 | }
48 |
49 | @Override
50 | public int getItemCount() {
51 | return mTemplateList.size();
52 | }
53 |
54 | class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
55 |
56 | TextView scripts;
57 |
58 | ViewHolder(View itemView) {
59 | super(itemView);
60 |
61 | itemView.findViewById(R.id.btn_apply).setOnClickListener(this);
62 | scripts = itemView.findViewById(R.id.tv_template_scripts);
63 | }
64 |
65 | @Override
66 | public void onClick(View v) {
67 | switch (v.getId()) {
68 | case R.id.btn_apply:
69 | ScenesActivity.start(
70 | v.getContext(),
71 | mTemplateList.get(getAdapterPosition()),
72 | false);
73 | break;
74 | default:
75 | break;
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/createchance/demo/views/VideoCheckFragment.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo.views;
2 |
3 | import android.app.Fragment;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.os.Environment;
7 | import android.support.annotation.Nullable;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.VideoView;
12 |
13 | import com.createchance.PlayRequest;
14 | import com.createchance.SimpleVideoPlayer;
15 | import com.createchance.demo.R;
16 | import com.createchance.demo.model.Scene;
17 |
18 | import java.io.File;
19 |
20 | public class VideoCheckFragment extends Fragment implements View.OnClickListener {
21 |
22 | private static final String TAG = "VideoCheckFragment";
23 |
24 | private Scene mScene;
25 |
26 | private Callback mCallback;
27 |
28 | private VideoView mVideoPlayer;
29 |
30 | public void setScene(Scene scene) {
31 | this.mScene = scene;
32 | }
33 |
34 | public void setCallback(Callback callback) {
35 | this.mCallback = callback;
36 | }
37 |
38 | @Nullable
39 | @Override
40 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
41 | View root = inflater.inflate(R.layout.fragment_video_check, container, false);
42 |
43 | root.findViewById(R.id.iv_redo).setOnClickListener(this);
44 | root.findViewById(R.id.iv_done).setOnClickListener(this);
45 | mVideoPlayer = root.findViewById(R.id.vw_video_player);
46 |
47 | return super.onCreateView(inflater, container, savedInstanceState);
48 | }
49 |
50 | @Override
51 | public void onStart() {
52 | super.onStart();
53 |
54 | // PlayRequest request = new PlayRequest.Builder()
55 | // .loop(true)
56 | // .source(Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "videoeditor/input.mp4")))
57 | // .build();
58 | // mVideoPlayer.start(request);
59 | mVideoPlayer.setVideoURI(Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "videoeditor/input.mp4")));
60 | mVideoPlayer.start();
61 | }
62 |
63 | @Override
64 | public void onStop() {
65 | super.onStop();
66 |
67 | mVideoPlayer.stopPlayback();
68 | }
69 |
70 | @Override
71 | public void onClick(View v) {
72 | switch (v.getId()) {
73 | case R.id.iv_redo:
74 | if (mCallback != null) {
75 | mCallback.onRedo();
76 | }
77 | break;
78 | case R.id.iv_done:
79 | if (mCallback != null) {
80 | mCallback.onDone();
81 | }
82 | break;
83 | default:
84 | break;
85 | }
86 | }
87 |
88 | interface Callback {
89 | void onRedo();
90 |
91 | void onDone();
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/arraw_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/arraw_left.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/arrow_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/arrow_left.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/redo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/redo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/setting.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/switch_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/switch_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/take_one_work.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/take_one_work.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/video_play_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/video_play_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/video_play_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xhdpi/video_play_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/scene_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xxhdpi/scene_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/scene_plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable-xxhdpi/scene_plus.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/common_btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter10.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter11.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter5.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter6.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter7.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter8.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filter9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/filter9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/video_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/watermark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/drawable/watermark.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
33 |
34 |
35 |
36 |
42 |
43 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scenes.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
33 |
34 |
35 |
36 |
46 |
47 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_template_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
32 |
33 |
43 |
44 |
45 |
46 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_video_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
27 |
28 |
38 |
39 |
47 |
48 |
49 |
50 |
56 |
57 |
66 |
67 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_video_take_and_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
20 |
27 |
28 |
33 |
34 |
43 |
44 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/edit_panel_cut.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
34 |
35 |
36 |
37 |
41 |
42 |
46 |
47 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/edit_panel_remove_bgm.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
34 |
35 |
36 |
37 |
41 |
42 |
46 |
47 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_video_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
19 |
20 |
26 |
27 |
28 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_video_take.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
20 |
21 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_scene.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
23 |
24 |
28 |
29 |
36 |
37 |
46 |
47 |
58 |
59 |
60 |
61 |
62 |
63 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_template.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
23 |
24 |
29 |
30 |
31 |
32 |
42 |
43 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_works.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
17 |
22 |
23 |
29 |
30 |
39 |
40 |
41 |
42 |
49 |
50 |
55 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-en/strings_main.xml:
--------------------------------------------------------------------------------
1 |
2 | SVEDemo
3 |
4 | No works for now.
5 | All Works
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-en/strings_scenes.xml:
--------------------------------------------------------------------------------
1 |
2 | Template Scene
3 | Custom Scene
4 | Next
5 |
6 | Delete this scene, are you sure?
7 | Delete this video, are you sure?
8 | Delete all video, are you sure?
9 | Yes
10 | Cancel
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values-en/strings_template_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Template List
4 | Apply
5 | Custom
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-en/strings_video_edit.xml:
--------------------------------------------------------------------------------
1 |
2 | Video Edit
3 |
4 | add bgm
5 | remove bgm
6 | cut video
7 | add filter and watermark
8 | merge videos
9 |
10 | Bgm start
11 | Bgm duration
12 | Video start
13 | Video duration
14 | Choose Bgm
15 | Choose watermark
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_main.xml:
--------------------------------------------------------------------------------
1 |
2 | SVEDemo
3 |
4 | 当前没有作品
5 | 我的作品
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_scenes.xml:
--------------------------------------------------------------------------------
1 |
2 | 模版镜头
3 | 自定义镜头
4 | 下一步
5 |
6 | 删除此镜头,确定吗?
7 | 删除视频,确定吗?
8 | 放弃全部视频,确定吗?
9 | 确定
10 | 取消
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_template_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 模版列表
4 | 应用
5 | 自定义
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_video_edit.xml:
--------------------------------------------------------------------------------
1 |
2 | 视频编辑
3 |
4 | 添加背景音
5 | 移除背景音
6 | 视频剪切
7 | 添加滤镜和水印
8 | 合并视频
9 |
10 | 背景开始
11 | 背景长度
12 | 视频开始
13 | 视频长度
14 | 选取背景音
15 | 选取水印图片
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
12 |
15 |
18 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/createchance/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.createchance.demo;
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() throws Exception {
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 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | mavenCentral()
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
30 | gradle.ext.compileSdkVersion = 26
31 | gradle.ext.targetSdkVersion = 26
32 | gradle.ext.buildToolsVersion = '26.0.2'
33 | gradle.ext.supportVersion = '26.0.2'
34 | gradle.ext.minSdkVersion = 18
35 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Mar 18 14:56:46 CST 2018
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-4.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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/logo/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/logo/1.png
--------------------------------------------------------------------------------
/logo/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/logo/2.png
--------------------------------------------------------------------------------
/logo/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/logo/3.png
--------------------------------------------------------------------------------
/logo/PNG 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/logo/PNG 1.png
--------------------------------------------------------------------------------
/logo/PNG 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/logo/PNG 2.png
--------------------------------------------------------------------------------
/logo/PNG 3-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/logo/PNG 3-01.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':simplevideoeditor'
2 | include ':simplevideoplayer'
3 | include ':simplecameraview'
4 |
--------------------------------------------------------------------------------
/simplecameraview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion gradle.ext.compileSdkVersion
5 | buildToolsVersion gradle.ext.buildToolsVersion
6 |
7 | defaultConfig {
8 | minSdkVersion gradle.ext.minSdkVersion
9 | targetSdkVersion gradle.ext.targetSdkVersion
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | sourceSets {
24 | main.java.srcDirs += 'src/main/api9'
25 | main.java.srcDirs += 'src/main/api14'
26 | main.java.srcDirs += 'src/main/api21'
27 | }
28 | }
29 |
30 | dependencies {
31 | compile fileTree(dir: 'libs', include: ['*.jar'])
32 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
33 | exclude group: 'com.android.support', module: 'support-annotations'
34 | })
35 | testCompile 'junit:junit:4.12'
36 |
37 | compile "com.android.support:support-annotations:25.3.1"
38 | compile "com.android.support:support-v4:25.3.1"
39 | }
40 |
--------------------------------------------------------------------------------
/simplecameraview/src/androidTest/java/com/example/libcameraview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.libcameraview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.libcameraview.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/api21/com/createchance/simplecameraview/Camera2DeviceInfo.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * Camera v2设备信息
8 | */
9 |
10 | class Camera2DeviceInfo {
11 |
12 | private List cameraList = new ArrayList<>();
13 |
14 | void addInfo(Device device) {
15 | if (device != null) {
16 | cameraList.add(device);
17 | }
18 | }
19 |
20 | Device getDeviceById(String id) {
21 | for (Device device : cameraList) {
22 | if (device.cameraId.equals(id)) {
23 | return device;
24 | }
25 | }
26 |
27 | return null;
28 | }
29 |
30 | Device getDeviceByFacing(int facing) {
31 | for (Device device : cameraList) {
32 | if (device.facing == facing) {
33 | return device;
34 | }
35 | }
36 |
37 | return null;
38 | }
39 |
40 | static class Device {
41 | private String cameraId;
42 |
43 | private int facing;
44 |
45 | private boolean isAFSupported = false;
46 |
47 | private boolean isAWBSupported = false;
48 |
49 | public Device(String id, int facing) {
50 | this.cameraId = id;
51 | this.facing = facing;
52 | }
53 |
54 | public String getCameraId() {
55 | return cameraId;
56 | }
57 |
58 | public void setCameraId(String cameraId) {
59 | this.cameraId = cameraId;
60 | }
61 |
62 | public int getFacing() {
63 | return facing;
64 | }
65 |
66 | public void setFacing(int facing) {
67 | this.facing = facing;
68 | }
69 |
70 | public boolean isAFSupported() {
71 | return isAFSupported;
72 | }
73 |
74 | public void setAFSupported(boolean AFSupported) {
75 | isAFSupported = AFSupported;
76 | }
77 |
78 | public boolean isAWBSupported() {
79 | return isAWBSupported;
80 | }
81 |
82 | public void setAWBSupported(boolean AWBSupported) {
83 | isAWBSupported = AWBSupported;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/CameraImpl.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.HandlerThread;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 |
9 | import java.io.File;
10 | import java.util.List;
11 |
12 | /**
13 | * 相机抽象类,需要不同版本的相机去实现
14 | * 统一接口,屏蔽底层细节。
15 | *
16 | * @author gaochao1-iri
17 | */
18 |
19 | abstract class CameraImpl {
20 |
21 | protected final ICameraCallback mCallback;
22 |
23 | protected final PreviewImpl mPreview;
24 |
25 | protected Handler mBackgroundHandler;
26 |
27 | protected CameraConfig mConfig;
28 |
29 | protected Context mContext;
30 |
31 | CameraImpl(ICameraCallback cameraCallback, PreviewImpl preview,
32 | CameraConfig config, Context context) {
33 | this.mCallback = cameraCallback;
34 | this.mPreview = preview;
35 | this.mConfig = config;
36 | this.mContext = context;
37 |
38 | if (mBackgroundHandler == null) {
39 | HandlerThread thread = new HandlerThread("background");
40 | thread.start();
41 | mBackgroundHandler = new Handler(thread.getLooper());
42 | }
43 | }
44 |
45 | View getView() {
46 | return mPreview.getView();
47 | }
48 |
49 | abstract void start(CameraView.MODE mode);
50 |
51 | abstract void stop(CameraView.MODE mode);
52 |
53 | abstract int getFlashLightState();
54 |
55 | abstract void setFlashLightState(int state);
56 |
57 | abstract boolean setAspectRatio(AspectRatio ratio);
58 |
59 | abstract AspectRatio getAspectRatio();
60 |
61 | abstract void setAutoFocus(boolean autoFocus);
62 |
63 | abstract boolean getAutoFocus();
64 |
65 | abstract void triggerFocus(MotionEvent event);
66 |
67 | abstract void zoom(boolean isZoomIn);
68 |
69 | abstract int getZoom();
70 |
71 | abstract int getMaxZoom();
72 |
73 | abstract boolean isCameraOpened();
74 |
75 | abstract void setFacing(int cameraId);
76 |
77 | abstract int getFacing();
78 |
79 | abstract void setWhiteBalance(int value);
80 |
81 | abstract int getWhiteBalance();
82 |
83 | abstract List getSupportedWhiteBalance();
84 |
85 | abstract void setExposureCompensation(int value);
86 |
87 | abstract int getExposureCompensation();
88 |
89 | abstract List getExposureCompensationRange();
90 |
91 | abstract float getExposureCompensationStep();
92 |
93 | abstract void startTakingVideo(File videoFile);
94 |
95 | abstract void stopTakingVideo();
96 |
97 | abstract void cancelTakingVideo();
98 |
99 | abstract void startTakingPicture(File pictureFile);
100 |
101 | abstract void setDisplayOrientation(int displayOrientation);
102 | }
103 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/Constants.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | /**
4 | * 常量定义类
5 | */
6 |
7 | public class Constants {
8 |
9 | // 这代表前置摄像头
10 | public static final int CAMERA_FACING_FRONT = 0;
11 | // 这代表后置摄像头
12 | public static final int CAMERA_FACING_BACK = 1;
13 |
14 | // 开启闪光灯
15 | public static final int FLASH_LIGHT_ON = 100;
16 | // 关闭闪光灯
17 | public static final int FLASH_LIGHT_OFF = 101;
18 | // 自动闪光灯
19 | public static final int FLASH_LIGHT_AUTO = 102;
20 | // 闪光灯常亮,手电筒模式
21 | public static final int FLASH_LIGHT_TORCH = 103;
22 | // 防止红眼模式
23 | public static final int FLASH_LIGHT_RED_EYE = 104;
24 | // 这表示当前闪光灯不可用,可能是没有闪光灯设备
25 | public static final int FLASH_LIGHT_NOT_AVALIABLE = 199;
26 |
27 | // 白平衡模式定义
28 | public static final int AWB_MODE_OFF = 200;
29 | public static final int AWB_MODE_CLOUDY_DAYLIGHT = 201;
30 | public static final int AWB_MODE_DAYLIGHT = 202;
31 | public static final int AWB_MODE_FLUORESCENT = 203;
32 | public static final int AWB_MODE_INCANDESCENT = 204;
33 | public static final int AWB_MODE_SHADE = 205;
34 | public static final int AWB_MODE_TWILIGHT = 206;
35 | public static final int AWB_MODE_WARM_FLUORESCENT = 207;
36 | public static final int AWB_MODE_AUTO = 208;
37 |
38 | // 默认纵横比为16:9,宽屏
39 | public static AspectRatio DEFAULT_ASPECT_RATIO = AspectRatio.of(16, 9);
40 |
41 | // 角度定义
42 | public static final int LANDSCAPE_90 = 90;
43 | public static final int LANDSCAPE_270 = 270;
44 |
45 | // 错误代码
46 | public static final int FATAL_ERROR = 0xffffffff;
47 | }
48 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/DisplayOrientationDetector.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import android.content.Context;
4 | import android.util.SparseIntArray;
5 | import android.view.Display;
6 | import android.view.OrientationEventListener;
7 | import android.view.Surface;
8 |
9 |
10 | /**
11 | * Monitors the value returned from {@link Display#getRotation()}.
12 | */
13 | abstract class DisplayOrientationDetector {
14 |
15 | private final OrientationEventListener mOrientationEventListener;
16 |
17 | /** Mapping from Surface.Rotation_n to degrees. */
18 | static final SparseIntArray DISPLAY_ORIENTATIONS = new SparseIntArray();
19 |
20 | static {
21 | DISPLAY_ORIENTATIONS.put(Surface.ROTATION_0, 0);
22 | DISPLAY_ORIENTATIONS.put(Surface.ROTATION_90, 90);
23 | DISPLAY_ORIENTATIONS.put(Surface.ROTATION_180, 180);
24 | DISPLAY_ORIENTATIONS.put(Surface.ROTATION_270, 270);
25 | }
26 |
27 | Display mDisplay;
28 |
29 | private int mLastKnownDisplayOrientation = 0;
30 |
31 | public DisplayOrientationDetector(Context context) {
32 | mOrientationEventListener = new OrientationEventListener(context) {
33 |
34 | /** This is either Surface.Rotation_0, _90, _180, _270, or -1 (invalid). */
35 | private int mLastKnownRotation = -1;
36 |
37 | @Override
38 | public void onOrientationChanged(int orientation) {
39 | if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN ||
40 | mDisplay == null) {
41 | return;
42 | }
43 | final int rotation = mDisplay.getRotation();
44 | if (mLastKnownRotation != rotation) {
45 | mLastKnownRotation = rotation;
46 | dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(rotation));
47 | }
48 | }
49 | };
50 | }
51 |
52 | public void enable(Display display) {
53 | mDisplay = display;
54 | mOrientationEventListener.enable();
55 | // Immediately dispatch the first callback
56 | dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(display.getRotation()));
57 | }
58 |
59 | public void disable() {
60 | mOrientationEventListener.disable();
61 | mDisplay = null;
62 | }
63 |
64 | public int getLastKnownDisplayOrientation() {
65 | return mLastKnownDisplayOrientation;
66 | }
67 |
68 | void dispatchOnDisplayOrientationChanged(int displayOrientation) {
69 | mLastKnownDisplayOrientation = displayOrientation;
70 | onDisplayOrientationChanged(displayOrientation);
71 | }
72 |
73 | /**
74 | * Called when display orientation is changed.
75 | *
76 | * @param displayOrientation One of 0, 90, 180, and 270.
77 | */
78 | public abstract void onDisplayOrientationChanged(int displayOrientation);
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/ICameraCallback.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * 相机回调接口,需要app实现来监听信息
7 | */
8 |
9 | public interface ICameraCallback {
10 |
11 | /**
12 | * 摄像头操作错误码
13 | */
14 | // 没有摄像头设备
15 | int ERROR_CODE_NO_CAMERA_DEVICES = 100;
16 | // 没有闪光灯设备
17 | int ERROR_CODE_NO_FLASH_LIGTH = 101;
18 | // 没有权限
19 | int ERROR_CODE_NO_PERMISSION = 102;
20 | // 照片或者视频保存失败
21 | int ERROR_CODE_SAVED_FAILED = 103;
22 | // 不支持的操作
23 | int ERROR_CODE_OPERATION_NOT_SUPPORTED = 198;
24 | // 未知错误
25 | int ERROR_CODE_UNKNOWN = 199;
26 |
27 | void onCameraOpened();
28 | void onCameraClosed();
29 | void onVideoTakeStarted();
30 | void onVideoTakeCanceled();
31 | void onVideoTaken(File videoFile);
32 | void onPictureTaken(File pictureFile);
33 | void onError(int code);
34 | }
35 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/Logger.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Util to print logs.
7 | *
8 | * @author createchance
9 | * @date 17/04/2018
10 | */
11 |
12 | public class Logger {
13 | public static final int VERBOSE = 1;
14 | public static final int DEBUG = 2;
15 | public static final int INFO = 3;
16 | public static final int WARN = 4;
17 | public static final int ERROR = 5;
18 | public static final int NOTHING = 6;
19 |
20 | static int level = VERBOSE;
21 |
22 | static String availableLevel() {
23 | return "VERBOSE, DEBUG, INFO, WARN, ERROR, NOTHING";
24 | }
25 |
26 | public static void v(String tag, String msg) {
27 | if (level <= VERBOSE) {
28 | Log.v(tag, msg);
29 | }
30 | }
31 |
32 | public static void d(String tag, String msg) {
33 | if (level <= DEBUG) {
34 | Log.d(tag, msg);
35 | }
36 | }
37 |
38 | public static void i(String tag, String msg) {
39 | if (level <= INFO) {
40 | Log.i(tag, msg);
41 | }
42 | }
43 |
44 | public static void w(String tag, String msg) {
45 | if (level <= WARN) {
46 | Log.w(tag, msg);
47 | }
48 | }
49 |
50 | public static void e(String tag, String msg) {
51 | if (level <= ERROR) {
52 | Log.e(tag, msg);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/PreviewImpl.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import android.view.Surface;
4 | import android.view.SurfaceHolder;
5 | import android.view.View;
6 |
7 | /**
8 | * preview实现抽象类
9 | */
10 |
11 | public abstract class PreviewImpl {
12 | interface Callback {
13 | void onSurfaceChanged();
14 | }
15 |
16 | private Callback mCallback;
17 |
18 | private int mWidth;
19 |
20 | private int mHeight;
21 |
22 | void setCallback(Callback callback) {
23 | mCallback = callback;
24 | }
25 |
26 | abstract Surface getSurface();
27 |
28 | public abstract View getView();
29 |
30 | abstract Class getOutputClass();
31 |
32 | abstract void setDisplayOrientation(int displayOrientation);
33 |
34 | abstract boolean isReady();
35 |
36 | protected void dispatchSurfaceChanged() {
37 | mCallback.onSurfaceChanged();
38 | }
39 |
40 | SurfaceHolder getSurfaceHolder() {
41 | return null;
42 | }
43 |
44 | Object getSurfaceTexture() {
45 | return null;
46 | }
47 |
48 | void setBufferSize(int width, int height) {
49 | }
50 |
51 | void setSize(int width, int height) {
52 | mWidth = width;
53 | mHeight = height;
54 | }
55 |
56 | int getWidth() {
57 | return mWidth;
58 | }
59 |
60 | int getHeight() {
61 | return mHeight;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/Size.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | /**
6 | * 尺寸封装类
7 | */
8 |
9 | public class Size implements Comparable {
10 |
11 | private final int mWidth;
12 | private final int mHeight;
13 |
14 | /**
15 | * Create a new immutable Size instance.
16 | *
17 | * @param width The width of the size, in pixels
18 | * @param height The height of the size, in pixels
19 | */
20 | public Size(int width, int height) {
21 | mWidth = width;
22 | mHeight = height;
23 | }
24 |
25 | public int getWidth() {
26 | return mWidth;
27 | }
28 |
29 | public int getHeight() {
30 | return mHeight;
31 | }
32 |
33 | @Override
34 | public boolean equals(Object o) {
35 | if (o == null) {
36 | return false;
37 | }
38 | if (this == o) {
39 | return true;
40 | }
41 | if (o instanceof Size) {
42 | Size size = (Size) o;
43 | return mWidth == size.mWidth && mHeight == size.mHeight;
44 | }
45 | return false;
46 | }
47 |
48 | @Override
49 | public String toString() {
50 | return mWidth + "x" + mHeight;
51 | }
52 |
53 | @Override
54 | public int hashCode() {
55 | // assuming most sizes are <2^16, doing a rotate will give us perfect hashing
56 | return mHeight ^ ((mWidth << (Integer.SIZE / 2)) | (mWidth >>> (Integer.SIZE / 2)));
57 | }
58 |
59 | @Override
60 | public int compareTo(@NonNull Size another) {
61 | return mWidth * mHeight - another.mWidth * another.mHeight;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/java/com/createchance/simplecameraview/SizeMap.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplecameraview;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 | import java.util.Set;
6 | import java.util.SortedSet;
7 | import java.util.TreeSet;
8 |
9 | /**
10 | * 纵横比和支持的尺寸map
11 | */
12 |
13 | class SizeMap {
14 | private final Map> mRatios = new HashMap<>();
15 |
16 | /**
17 | * Add a new {@link Size} to this collection.
18 | *
19 | * @param size The size to add.
20 | * @return {@code true} if it is added, {@code false} if it already exists and is not added.
21 | */
22 | public boolean add(Size size) {
23 | for (AspectRatio ratio : mRatios.keySet()) {
24 | if (ratio.matches(size)) {
25 | final SortedSet sizes = mRatios.get(ratio);
26 | if (sizes.contains(size)) {
27 | return false;
28 | } else {
29 | sizes.add(size);
30 | return true;
31 | }
32 | }
33 | }
34 | // None of the existing ratio matches the provided size; add a new key
35 | SortedSet sizes = new TreeSet<>();
36 | sizes.add(size);
37 | mRatios.put(AspectRatio.of(size.getWidth(), size.getHeight()), sizes);
38 | return true;
39 | }
40 |
41 | /**
42 | * Removes the specified aspect ratio and all sizes associated with it.
43 | *
44 | * @param ratio The aspect ratio to be removed.
45 | */
46 | public void remove(AspectRatio ratio) {
47 | mRatios.remove(ratio);
48 | }
49 |
50 | Set ratios() {
51 | return mRatios.keySet();
52 | }
53 |
54 | SortedSet sizes(AspectRatio ratio) {
55 | return mRatios.get(ratio);
56 | }
57 |
58 | void clear() {
59 | mRatios.clear();
60 | }
61 |
62 | boolean isEmpty() {
63 | return mRatios.isEmpty();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/res/layout-v14/texture_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/simplecameraview/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 |
22 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | libcameraview
3 |
4 |
--------------------------------------------------------------------------------
/simplecameraview/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/simplecameraview/src/test/java/com/example/libcameraview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.libcameraview;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/simplevideoeditor/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/simplevideoeditor/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Sets the minimum version of CMake required to build your native library.
2 | # This ensures that a certain set of CMake features is available to
3 | # your build.
4 |
5 | cmake_minimum_required(VERSION 3.4.1)
6 |
7 | # Specifies a library name, specifies whether the library is STATIC or
8 | # SHARED, and provides relative paths to the source code. You can
9 | # define multiple libraries by adding multiple add_library() commands,
10 | # and CMake builds them for you. When you build your app, Gradle
11 | # automatically packages shared libraries with your APK.
12 |
13 | add_library( # Specifies the name of the library.
14 | simplevideoeditor
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | jni/yuv-decoder.c
21 | jni/audio-mix.cpp )
--------------------------------------------------------------------------------
/simplevideoeditor/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion gradle.ext.compileSdkVersion
5 |
6 | defaultConfig {
7 | minSdkVersion gradle.ext.minSdkVersion
8 | targetSdkVersion gradle.ext.targetSdkVersion
9 | versionCode 1
10 | versionName "1.0"
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | externalNativeBuild {
24 | cmake {
25 | path 'CMakeLists.txt'
26 | }
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 |
33 | implementation 'com.android.support:appcompat-v7:26.1.0'
34 | testImplementation 'junit:junit:4.12'
35 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/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 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/androidTest/java/com/createchance/simplevideoeditor/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.createchance.simplevideoeditor.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/Config.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | /**
4 | * ${DESC}
5 | *
6 | * @author createchance
7 | * @date 2018/5/19
8 | */
9 | public class Config {
10 | public static boolean DEBUG = true;
11 | }
12 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/Constants.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | /**
4 | * ${DESC}
5 | *
6 | * @author createchance
7 | * @date 24/04/2018
8 | */
9 | public class Constants {
10 | public class Log {
11 | public static final int VERBOSE = 1;
12 | public static final int DEBUG = 2;
13 | public static final int INFO = 3;
14 | public static final int WARN = 4;
15 | public static final int ERROR = 5;
16 | public static final int NOTHING = 6;
17 | }
18 |
19 | public static final String ACTION_REMOVE_BGM = "ActionRemoveVideoBgm";
20 | public static final String ACTION_ADD_BGM = "ActionAddVideoBgm";
21 | public static final String ACTION_CUT_VIDEO = "ActionCutVideo";
22 | public static final String ACTION_MERGE_VIDEOS = "ActionMergeVideos";
23 | public static final String ACTION_ADD_FILTER = "ActionAddVideoFilter";
24 | public static final String ACTION_VIDEO_TO_GIF = "ActionVideoToGif";
25 |
26 | public static final int INVALID_TOKEN = -1;
27 | }
28 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/EditListener.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * ${DESC}
7 | *
8 | * @author createchance
9 | * @date 03/05/2018
10 | */
11 | public class EditListener {
12 | private static final String TAG = EditListener.class.getSimpleName();
13 |
14 | public void onStart(long token) {
15 | }
16 |
17 | public void onStageStart(long token, String stage) {
18 | }
19 |
20 | public void onProgress(long token, float progress) {
21 | }
22 |
23 | public void onStageProgress(long token, String stage, float progress) {
24 | }
25 |
26 | public void onSucceeded(long token) {
27 | }
28 |
29 | public void onStageSucceeded(long token, String stage, File outputFile) {
30 | }
31 |
32 | public void onFailed(long token) {
33 | }
34 |
35 | public void onStageFailed(long token, String stage) {
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/Logger.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | import android.util.Log;
4 |
5 | import static com.createchance.simplevideoeditor.Constants.Log.DEBUG;
6 | import static com.createchance.simplevideoeditor.Constants.Log.ERROR;
7 | import static com.createchance.simplevideoeditor.Constants.Log.INFO;
8 | import static com.createchance.simplevideoeditor.Constants.Log.VERBOSE;
9 | import static com.createchance.simplevideoeditor.Constants.Log.WARN;
10 |
11 | /**
12 | * Util to print logs.
13 | *
14 | * @author createchance
15 | * @date 17/04/2018
16 | */
17 |
18 | public class Logger {
19 | static int level = VERBOSE;
20 |
21 | static String availableLevel() {
22 | return "VERBOSE, DEBUG, INFO, WARN, ERROR, NOTHING";
23 | }
24 |
25 | public static void v(String tag, String msg) {
26 | if (level <= VERBOSE) {
27 | Log.v(tag, msg);
28 | }
29 | }
30 |
31 | public static void d(String tag, String msg) {
32 | if (level <= DEBUG) {
33 | Log.d(tag, msg);
34 | }
35 | }
36 |
37 | public static void i(String tag, String msg) {
38 | if (level <= INFO) {
39 | Log.i(tag, msg);
40 | }
41 | }
42 |
43 | public static void w(String tag, String msg) {
44 | if (level <= WARN) {
45 | Log.w(tag, msg);
46 | }
47 | }
48 |
49 | public static void e(String tag, String msg) {
50 | if (level <= ERROR) {
51 | Log.e(tag, msg);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/VideoUtil.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | import android.media.MediaMetadataRetriever;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * Video util
9 | *
10 | * @author createchance
11 | * @date 2018-04-15
12 | */
13 | public class VideoUtil {
14 | public static int getVideoRotation(File video) {
15 | MediaMetadataRetriever retriever = new MediaMetadataRetriever();
16 | retriever.setDataSource(video.getAbsolutePath());
17 | int rotation = Integer.valueOf(
18 | retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION));
19 | retriever.release();
20 | return rotation;
21 | }
22 |
23 | public static long getVideoDuration(File video) {
24 | MediaMetadataRetriever retriever = new MediaMetadataRetriever();
25 | retriever.setDataSource(video.getAbsolutePath());
26 | long duration = Long.valueOf(
27 | retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
28 | retriever.release();
29 | return duration;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/WorkRunner.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 |
6 | /**
7 | * Action运行器
8 | *
9 | * @author createchance
10 | * @date 21/11/2017
11 | */
12 |
13 | public final class WorkRunner {
14 | /**
15 | * 自定义的带有优先级的后台线程池
16 | * 核心线程数为:cpu核心数 + 1
17 | * 最大线程数为:cpu核心数 x 2 + 1
18 | * 线程空闲保活时间为:60s
19 | */
20 | private static ExecutorService mThreadPool = Executors.newFixedThreadPool(
21 | Runtime.getRuntime().availableProcessors() * 2);
22 |
23 | /**
24 | * 添加一个任务到后台线程队列中运行
25 | *
26 | * @param task 需要执行的任务
27 | */
28 | public static void addTaskToBackground(Runnable task) {
29 | if (task == null) {
30 | throw new NullPointerException();
31 | }
32 |
33 | mThreadPool.execute(task);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/actions/AbstractAction.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor.actions;
2 |
3 | import com.createchance.simplevideoeditor.VideoEditorManager;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * 音视频编辑抽象类,所有的编辑操作都是这个类的子类
9 | *
10 | * @author createchance
11 | * @date 25/03/2018
12 | */
13 |
14 | public abstract class AbstractAction {
15 | public final String mActionName;
16 |
17 | protected File mInputFile;
18 | protected File mOutputFile;
19 |
20 | public long mToken;
21 |
22 | AbstractAction(String actionName) {
23 | this.mActionName = actionName;
24 | }
25 |
26 | /**
27 | * start this action.
28 | */
29 | public abstract void start();
30 |
31 | public void release() {
32 | if (mOutputFile != null && mOutputFile.exists()) {
33 | // mOutputFile.delete();
34 | }
35 | }
36 |
37 | protected final void onStarted() {
38 | VideoEditorManager.getManager().onStart(mToken, this);
39 | }
40 |
41 | protected final void onProgress(float progress) {
42 | VideoEditorManager.getManager().onProgress(mToken, this, progress);
43 | }
44 |
45 | protected final void onSucceeded() {
46 | VideoEditorManager.getManager().onSucceed(mToken, this);
47 | }
48 |
49 | protected final void onFailed() {
50 | VideoEditorManager.getManager().onFailed(mToken, this);
51 | }
52 |
53 | public File getInputFile() {
54 | return mInputFile;
55 | }
56 |
57 | public File getOutputFile() {
58 | return mOutputFile;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gles/AbstractFilter.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor.gles;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import com.createchance.simplevideoeditor.Config;
6 |
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | import static android.opengl.GLES20.glUseProgram;
11 |
12 | /**
13 | * ${DESC}
14 | *
15 | * @author createchance
16 | * @date 2018/5/19
17 | */
18 | public abstract class AbstractFilter {
19 | private static final String TAG = "AbstractFilter";
20 |
21 | protected final int BYTES_PER_FLOAT = 4;
22 |
23 | protected int programId;
24 |
25 | protected Map shaderParamMap = new HashMap<>();
26 |
27 | protected int surfaceWidth, surfaceHeight;
28 |
29 | protected int inputTextureId;
30 |
31 | private final String vertexSource, fragmentSource;
32 |
33 | AbstractFilter(String vertexSource, String fragmentSource) {
34 | this.vertexSource = vertexSource;
35 | this.fragmentSource = fragmentSource;
36 | }
37 |
38 | protected abstract void initParamMap();
39 |
40 | protected abstract void onDraw();
41 |
42 | public abstract boolean shouldDraw(long presentationTime);
43 |
44 | protected void onInitDone() {
45 |
46 | }
47 |
48 | protected void onPreDraw() {
49 |
50 | }
51 |
52 | protected void onPostDraw() {
53 |
54 | }
55 |
56 | protected void onViewSizeChanged() {
57 |
58 | }
59 |
60 | protected void onSetInputTextureId() {
61 |
62 | }
63 |
64 | final void init() {
65 | programId = OpenGlUtil.buildProgram(
66 | OpenGlUtil.loadShader(GLES20.GL_VERTEX_SHADER, vertexSource),
67 | OpenGlUtil.loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource)
68 | );
69 | if (Config.DEBUG && !OpenGlUtil.validateProgram(programId)) {
70 | throw new IllegalStateException("Program id: " + programId + " invalid!");
71 | }
72 | initParamMap();
73 | OpenGlUtil.getShaderParams(programId, shaderParamMap);
74 | glUseProgram(programId);
75 | onInitDone();
76 | }
77 |
78 | public final void draw() {
79 | glUseProgram(programId);
80 | onPreDraw();
81 | onDraw();
82 | onPostDraw();
83 | }
84 |
85 | public final void setViewSize(int viewWidth, int viewHeight) {
86 | this.surfaceWidth = viewWidth;
87 | this.surfaceHeight = viewHeight;
88 | onViewSizeChanged();
89 | }
90 |
91 | public final void setInputTextureId(int textureId) {
92 | this.inputTextureId = textureId;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageAddBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageAddBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String ADD_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " lowp vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | "\n" +
31 | " mediump float r;\n" +
32 | " if (overlay.r * base.a + base.r * overlay.a >= overlay.a * base.a) {\n" +
33 | " r = overlay.a * base.a + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n" +
34 | " } else {\n" +
35 | " r = overlay.r + base.r;\n" +
36 | " }\n" +
37 | "\n" +
38 | " mediump float g;\n" +
39 | " if (overlay.g * base.a + base.g * overlay.a >= overlay.a * base.a) {\n" +
40 | " g = overlay.a * base.a + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n" +
41 | " } else {\n" +
42 | " g = overlay.g + base.g;\n" +
43 | " }\n" +
44 | "\n" +
45 | " mediump float b;\n" +
46 | " if (overlay.b * base.a + base.b * overlay.a >= overlay.a * base.a) {\n" +
47 | " b = overlay.a * base.a + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n" +
48 | " } else {\n" +
49 | " b = overlay.b + base.b;\n" +
50 | " }\n" +
51 | "\n" +
52 | " mediump float a = overlay.a + base.a - overlay.a * base.a;\n" +
53 | " \n" +
54 | " gl_FragColor = vec4(r, g, b, a);\n" +
55 | " }";
56 |
57 | public GPUImageAddBlendFilter() {
58 | super(ADD_BLEND_FRAGMENT_SHADER);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageAlphaBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | /**
20 | * Mix ranges from 0.0 (only image 1) to 1.0 (only image 2), with 0.5 (half of either) as the normal level
21 | */
22 | public class GPUImageAlphaBlendFilter extends GPUImageMixBlendFilter{
23 | public static final String ALPHA_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
24 | " varying highp vec2 textureCoordinate2;\n" +
25 | "\n" +
26 | " uniform sampler2D inputImageTexture;\n" +
27 | " uniform sampler2D inputImageTexture2;\n" +
28 | " \n" +
29 | " uniform lowp float mixturePercent;\n" +
30 | "\n" +
31 | " void main()\n" +
32 | " {\n" +
33 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
34 | " lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
35 | "\n" +
36 | " gl_FragColor = vec4(mix(textureColor.rgb, textureColor2.rgb, textureColor2.a * mixturePercent), textureColor.a);\n" +
37 | " }";
38 |
39 | public GPUImageAlphaBlendFilter() {
40 | super(ALPHA_BLEND_FRAGMENT_SHADER);
41 | }
42 |
43 | public GPUImageAlphaBlendFilter(float mix) {
44 | super(ALPHA_BLEND_FRAGMENT_SHADER, mix);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageBrightnessFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mBrightnessLocation;
39 | private float mBrightness;
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 | mBrightness = brightness;
48 | }
49 |
50 | @Override
51 | public void onInit() {
52 | super.onInit();
53 | mBrightnessLocation = GLES20.glGetUniformLocation(getProgram(), "brightness");
54 | }
55 |
56 | @Override
57 | public void onInitialized() {
58 | super.onInitialized();
59 | setBrightness(mBrightness);
60 | }
61 |
62 | public void setBrightness(final float brightness) {
63 | mBrightness = brightness;
64 | setFloat(mBrightnessLocation, mBrightness);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageColorBurnBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageColorBurnBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String COLOR_BURN_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " mediump vec4 whiteColor = vec4(1.0);\n" +
31 | " gl_FragColor = whiteColor - (whiteColor - textureColor) / textureColor2;\n" +
32 | " }";
33 |
34 | public GPUImageColorBurnBlendFilter() {
35 | super(COLOR_BURN_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageColorDodgeBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageColorDodgeBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String COLOR_DODGE_BLEND_FRAGMENT_SHADER = "precision mediump float;\n" +
21 | " \n" +
22 | " varying highp vec2 textureCoordinate;\n" +
23 | " varying highp vec2 textureCoordinate2;\n" +
24 | " \n" +
25 | " uniform sampler2D inputImageTexture;\n" +
26 | " uniform sampler2D inputImageTexture2;\n" +
27 | " \n" +
28 | " void main()\n" +
29 | " {\n" +
30 | " vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
31 | " vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n" +
32 | " \n" +
33 | " vec3 baseOverlayAlphaProduct = vec3(overlay.a * base.a);\n" +
34 | " vec3 rightHandProduct = overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a);\n" +
35 | " \n" +
36 | " vec3 firstBlendColor = baseOverlayAlphaProduct + rightHandProduct;\n" +
37 | " vec3 overlayRGB = clamp((overlay.rgb / clamp(overlay.a, 0.01, 1.0)) * step(0.0, overlay.a), 0.0, 0.99);\n" +
38 | " \n" +
39 | " vec3 secondBlendColor = (base.rgb * overlay.a) / (1.0 - overlayRGB) + rightHandProduct;\n" +
40 | " \n" +
41 | " vec3 colorChoice = step((overlay.rgb * base.a + base.rgb * overlay.a), baseOverlayAlphaProduct);\n" +
42 | " \n" +
43 | " gl_FragColor = vec4(mix(firstBlendColor, secondBlendColor, colorChoice), 1.0);\n" +
44 | " }";
45 |
46 | public GPUImageColorDodgeBlendFilter() {
47 | super(COLOR_DODGE_BLEND_FRAGMENT_SHADER);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageColorInvertFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageContrastFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mContrastLocation;
41 | private float mContrast;
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 | mContrast = contrast;
50 | }
51 |
52 | @Override
53 | public void onInit() {
54 | super.onInit();
55 | mContrastLocation = GLES20.glGetUniformLocation(getProgram(), "contrast");
56 | }
57 |
58 | @Override
59 | public void onInitialized() {
60 | super.onInitialized();
61 | setContrast(mContrast);
62 | }
63 |
64 | public void setContrast(final float contrast) {
65 | mContrast = contrast;
66 | setFloat(mContrastLocation, mContrast);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageDarkenBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageDarkenBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String DARKEN_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " gl_FragColor = vec4(min(overlayer.rgb * base.a, base.rgb * overlayer.a) + overlayer.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlayer.a), 1.0);\n" +
32 | " }";
33 |
34 | public GPUImageDarkenBlendFilter() {
35 | super(DARKEN_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageDifferenceBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageDifferenceBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String DIFFERENCE_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " gl_FragColor = vec4(abs(textureColor2.rgb - textureColor.rgb), textureColor.a);\n" +
31 | " }";
32 |
33 | public GPUImageDifferenceBlendFilter() {
34 | super(DIFFERENCE_BLEND_FRAGMENT_SHADER);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageDissolveBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | /**
20 | * Mix ranges from 0.0 (only image 1) to 1.0 (only image 2), with 0.5 (half of either) as the normal level
21 | */
22 | public class GPUImageDissolveBlendFilter extends GPUImageMixBlendFilter{
23 | public static final String DISSOLVE_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
24 | " varying highp vec2 textureCoordinate2;\n" +
25 | "\n" +
26 | " uniform sampler2D inputImageTexture;\n" +
27 | " uniform sampler2D inputImageTexture2;\n" +
28 | " uniform lowp float mixturePercent;\n" +
29 | " \n" +
30 | " void main()\n" +
31 | " {\n" +
32 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
33 | " lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
34 | " \n" +
35 | " gl_FragColor = mix(textureColor, textureColor2, mixturePercent);\n" +
36 | " }";
37 |
38 | public GPUImageDissolveBlendFilter() {
39 | super(DISSOLVE_BLEND_FRAGMENT_SHADER);
40 | }
41 |
42 | public GPUImageDissolveBlendFilter(float mix) {
43 | super(DISSOLVE_BLEND_FRAGMENT_SHADER, mix);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageEmbossFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | /**
20 | * Applies an emboss effect to the image.
21 | *
22 | * Intensity ranges from 0.0 to 4.0, with 1.0 as the normal level
23 | */
24 | public class GPUImageEmbossFilter extends GPUImage3x3ConvolutionFilter {
25 | private float mIntensity;
26 |
27 | public GPUImageEmbossFilter() {
28 | this(1.0f);
29 | }
30 |
31 | public GPUImageEmbossFilter(final float intensity) {
32 | super();
33 | mIntensity = intensity;
34 | }
35 |
36 | @Override
37 | public void onInit() {
38 | super.onInit();
39 | setIntensity(mIntensity);
40 | }
41 |
42 | public void setIntensity(final float intensity) {
43 | mIntensity = intensity;
44 | setConvolutionKernel(new float[] {
45 | intensity * (-2.0f), -intensity, 0.0f,
46 | -intensity, 1.0f, intensity,
47 | 0.0f, intensity, intensity * 2.0f,
48 | });
49 | }
50 |
51 | public float getIntensity() {
52 | return mIntensity;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageExclusionBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageExclusionBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String EXCLUSION_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " // Dca = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)\n" +
32 | " \n" +
33 | " gl_FragColor = vec4((overlay.rgb * base.a + base.rgb * overlay.a - 2.0 * overlay.rgb * base.rgb) + overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a), base.a);\n" +
34 | " }";
35 |
36 | public GPUImageExclusionBlendFilter() {
37 | super(EXCLUSION_BLEND_FRAGMENT_SHADER);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageExposureFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mExposureLocation;
39 | private float mExposure;
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 | mExposure = exposure;
48 | }
49 |
50 | @Override
51 | public void onInit() {
52 | super.onInit();
53 | mExposureLocation = GLES20.glGetUniformLocation(getProgram(), "exposure");
54 | }
55 |
56 | @Override
57 | public void onInitialized() {
58 | super.onInitialized();
59 | setExposure(mExposure);
60 | }
61 |
62 | public void setExposure(final float exposure) {
63 | mExposure = exposure;
64 | setFloat(mExposureLocation, mExposure);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageGammaFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mGammaLocation;
39 | private float mGamma;
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 | mGamma = gamma;
48 | }
49 |
50 | @Override
51 | public void onInit() {
52 | super.onInit();
53 | mGammaLocation = GLES20.glGetUniformLocation(getProgram(), "gamma");
54 | }
55 |
56 | @Override
57 | public void onInitialized() {
58 | super.onInitialized();
59 | setGamma(mGamma);
60 | }
61 |
62 | public void setGamma(final float gamma) {
63 | mGamma = gamma;
64 | setFloat(mGammaLocation, mGamma);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageGrayscaleFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageLightenBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageLightenBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String LIGHTEN_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " gl_FragColor = max(textureColor, textureColor2);\n" +
32 | " }";
33 |
34 | public GPUImageLightenBlendFilter() {
35 | super(LIGHTEN_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageLinearBurnBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageLinearBurnBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String LINEAR_BURN_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | " \n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " gl_FragColor = vec4(clamp(textureColor.rgb + textureColor2.rgb - vec3(1.0), vec3(0.0), vec3(1.0)), textureColor.a);\n" +
32 | " }";
33 |
34 | public GPUImageLinearBurnBlendFilter() {
35 | super(LINEAR_BURN_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageMixBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | import android.opengl.GLES20;
20 |
21 | public class GPUImageMixBlendFilter extends GPUImageTwoInputFilter {
22 |
23 | private int mMixLocation;
24 | private float mMix;
25 |
26 | public GPUImageMixBlendFilter(String fragmentShader) {
27 | this(fragmentShader, 0.5f);
28 | }
29 |
30 | public GPUImageMixBlendFilter(String fragmentShader, float mix) {
31 | super(fragmentShader);
32 | mMix = mix;
33 | }
34 |
35 | @Override
36 | public void onInit() {
37 | super.onInit();
38 | mMixLocation = GLES20.glGetUniformLocation(getProgram(), "mixturePercent");
39 | }
40 |
41 | @Override
42 | public void onInitialized() {
43 | super.onInitialized();
44 | setMix(mMix);
45 | }
46 |
47 | /**
48 | * @param mix ranges from 0.0 (only image 1) to 1.0 (only image 2), with 0.5 (half of either) as the normal level
49 | */
50 | public void setMix(final float mix) {
51 | mMix = mix;
52 | setFloat(mMixLocation, mMix);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageMultiplyBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageMultiplyBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String MULTIPLY_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " gl_FragColor = overlayer * base + overlayer * (1.0 - base.a) + base * (1.0 - overlayer.a);\n" +
32 | " }";
33 |
34 | public GPUImageMultiplyBlendFilter() {
35 | super(MULTIPLY_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageNativeLibrary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageNativeLibrary {
20 | static {
21 | System.loadLibrary("simplevideoeditor");
22 | }
23 |
24 | public static native void YUVtoRBGA(byte[] yuv, int width, int height, int[] out);
25 |
26 | public static native void YUVtoARBG(byte[] yuv, int width, int height, int[] out);
27 | }
28 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageNormalBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | /**
20 | * This equation is a simplification of the general blending equation. It assumes the destination color is opaque, and therefore drops the destination color's alpha term.
21 | *
22 | * D = C1 * C1a + C2 * C2a * (1 - C1a)
23 | * where D is the resultant color, C1 is the color of the first element, C1a is the alpha of the first element, C2 is the second element color, C2a is the alpha of the second element. The destination alpha is calculated with:
24 | *
25 | * Da = C1a + C2a * (1 - C1a)
26 | * The resultant color is premultiplied with the alpha. To restore the color to the unmultiplied values, just divide by Da, the resultant alpha.
27 | *
28 | * http://stackoverflow.com/questions/1724946/blend-mode-on-a-transparent-and-semi-transparent-background
29 | *
30 | * For some reason Photoshop behaves
31 | * D = C1 + C2 * C2a * (1 - C1a)
32 | */
33 | public class GPUImageNormalBlendFilter extends GPUImageTwoInputFilter {
34 | public static final String NORMAL_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
35 | " varying highp vec2 textureCoordinate2;\n" +
36 | " \n" +
37 | " uniform sampler2D inputImageTexture;\n" +
38 | " uniform sampler2D inputImageTexture2;\n" +
39 | " \n" +
40 | " void main()\n" +
41 | " {\n" +
42 | " lowp vec4 c2 = texture2D(inputImageTexture, textureCoordinate);\n" +
43 | "\t lowp vec4 c1 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
44 | " \n" +
45 | " lowp vec4 outputColor;\n" +
46 | " \n" +
47 | " outputColor.r = c1.r + c2.r * c2.a * (1.0 - c1.a);\n" +
48 | "\n" +
49 | " outputColor.g = c1.g + c2.g * c2.a * (1.0 - c1.a);\n" +
50 | " \n" +
51 | " outputColor.b = c1.b + c2.b * c2.a * (1.0 - c1.a);\n" +
52 | " \n" +
53 | " outputColor.a = c1.a + c2.a * (1.0 - c1.a);\n" +
54 | " \n" +
55 | " gl_FragColor = outputColor;\n" +
56 | " }";
57 |
58 | public GPUImageNormalBlendFilter() {
59 | super(NORMAL_BLEND_FRAGMENT_SHADER);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageOpacityFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mOpacityLocation;
40 | private float mOpacity;
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 | mOpacity = opacity;
49 | }
50 |
51 | @Override
52 | public void onInit() {
53 | super.onInit();
54 | mOpacityLocation = GLES20.glGetUniformLocation(getProgram(), "opacity");
55 | }
56 |
57 | @Override
58 | public void onInitialized() {
59 | super.onInitialized();
60 | setOpacity(mOpacity);
61 | }
62 |
63 | public void setOpacity(final float opacity) {
64 | mOpacity = opacity;
65 | setFloat(mOpacityLocation, mOpacity);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImagePixelationFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | import android.opengl.GLES20;
20 |
21 | /**
22 | * Applies a grayscale effect to the image.
23 | */
24 | public class GPUImagePixelationFilter extends GPUImageFilter {
25 | public static final String PIXELATION_FRAGMENT_SHADER = "" +
26 | "precision highp float;\n" +
27 |
28 | "varying vec2 textureCoordinate;\n" +
29 |
30 | "uniform float imageWidthFactor;\n" +
31 | "uniform float imageHeightFactor;\n" +
32 | "uniform sampler2D inputImageTexture;\n" +
33 | "uniform float pixel;\n" +
34 |
35 | "void main()\n" +
36 | "{\n" +
37 | " vec2 uv = textureCoordinate.xy;\n" +
38 | " float dx = pixel * imageWidthFactor;\n" +
39 | " float dy = pixel * imageHeightFactor;\n" +
40 | " vec2 coord = vec2(dx * floor(uv.x / dx), dy * floor(uv.y / dy));\n" +
41 | " vec3 tc = texture2D(inputImageTexture, coord).xyz;\n" +
42 | " gl_FragColor = vec4(tc, 1.0);\n" +
43 | "}";
44 |
45 | private int mImageWidthFactorLocation;
46 | private int mImageHeightFactorLocation;
47 | private float mPixel;
48 | private int mPixelLocation;
49 |
50 | public GPUImagePixelationFilter() {
51 | super(NO_FILTER_VERTEX_SHADER, PIXELATION_FRAGMENT_SHADER);
52 | mPixel = 1.0f;
53 | }
54 |
55 | @Override
56 | public void onInit() {
57 | super.onInit();
58 | mImageWidthFactorLocation = GLES20.glGetUniformLocation(getProgram(), "imageWidthFactor");
59 | mImageHeightFactorLocation = GLES20.glGetUniformLocation(getProgram(), "imageHeightFactor");
60 | mPixelLocation = GLES20.glGetUniformLocation(getProgram(), "pixel");
61 | setPixel(mPixel);
62 | }
63 |
64 | @Override
65 | public void onOutputSizeChanged(final int width, final int height) {
66 | super.onOutputSizeChanged(width, height);
67 | setFloat(mImageWidthFactorLocation, 1.0f / width);
68 | setFloat(mImageHeightFactorLocation, 1.0f / height);
69 | }
70 |
71 | public void setPixel(final float pixel) {
72 | mPixel = pixel;
73 | setFloat(mPixelLocation, mPixel);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImagePosterizeFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mGLUniformColorLevels;
41 | private int mColorLevels;
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 | mColorLevels = colorLevels;
50 | }
51 |
52 | @Override
53 | public void onInit() {
54 | super.onInit();
55 | mGLUniformColorLevels = GLES20.glGetUniformLocation(getProgram(), "colorLevels");
56 | setColorLevels(mColorLevels);
57 | }
58 |
59 | public void setColorLevels(final int colorLevels) {
60 | mColorLevels = colorLevels;
61 | setFloat(mGLUniformColorLevels, colorLevels);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageSaturationFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 mSaturationLocation;
45 | private float mSaturation;
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 | mSaturation = saturation;
54 | }
55 |
56 | @Override
57 | public void onInit() {
58 | super.onInit();
59 | mSaturationLocation = GLES20.glGetUniformLocation(getProgram(), "saturation");
60 | }
61 |
62 | @Override
63 | public void onInitialized() {
64 | super.onInitialized();
65 | setSaturation(mSaturation);
66 | }
67 |
68 | public void setSaturation(final float saturation) {
69 | mSaturation = saturation;
70 | setFloat(mSaturationLocation, mSaturation);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageScreenBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageScreenBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String SCREEN_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " mediump vec4 whiteColor = vec4(1.0);\n" +
31 | " gl_FragColor = whiteColor - ((whiteColor - textureColor2) * (whiteColor - textureColor));\n" +
32 | " }";
33 |
34 | public GPUImageScreenBlendFilter() {
35 | super(SCREEN_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageSepiaFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | /**
20 | * Applies a simple sepia effect.
21 | */
22 | public class GPUImageSepiaFilter extends GPUImageColorMatrixFilter {
23 |
24 | public GPUImageSepiaFilter() {
25 | this(1.0f);
26 | }
27 |
28 | public GPUImageSepiaFilter(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 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageSmoothToonFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | /**
20 | * This uses a similar process as the GPUImageToonFilter, only it precedes the toon effect
21 | * with a Gaussian blur to smooth out noise.
22 | */
23 | public class GPUImageSmoothToonFilter extends GPUImageFilterGroup {
24 | GPUImageGaussianBlurFilter blurFilter;
25 | GPUImageToonFilter toonFilter;
26 |
27 | /**
28 | * Setup and Tear down
29 | */
30 | public GPUImageSmoothToonFilter() {
31 | // First pass: apply a variable Gaussian blur
32 | blurFilter = new GPUImageGaussianBlurFilter();
33 | addFilter(blurFilter);
34 |
35 | // Second pass: run the Sobel edge detection on this blurred image, along with a posterization effect
36 | toonFilter = new GPUImageToonFilter();
37 | addFilter(toonFilter);
38 |
39 | getFilters().add(blurFilter);
40 |
41 | setBlurSize(0.5f);
42 | setThreshold(0.2f);
43 | setQuantizationLevels(10.0f);
44 | }
45 |
46 | /**
47 | * Accessors
48 | */
49 | public void setTexelWidth(float value) {
50 | toonFilter.setTexelWidth(value);
51 | }
52 |
53 | public void setTexelHeight(float value) {
54 | toonFilter.setTexelHeight(value);
55 | }
56 |
57 | public void setBlurSize(float value) {
58 | blurFilter.setBlurSize(value);
59 | }
60 |
61 | public void setThreshold(float value) {
62 | toonFilter.setThreshold(value);
63 | }
64 |
65 | public void setQuantizationLevels(float value) {
66 | toonFilter.setQuantizationLevels(value);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageSoftLightBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageSoftLightBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String SOFT_LIGHT_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " gl_FragColor = base * (overlay.a * (base / base.a) + (2.0 * overlay * (1.0 - (base / base.a)))) + overlay * (1.0 - base.a) + base * (1.0 - overlay.a);\n" +
32 | " }";
33 |
34 | public GPUImageSoftLightBlendFilter() {
35 | super(SOFT_LIGHT_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageSourceOverBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageSourceOverBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String SOURCE_OVER_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | " \n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | " \n" +
31 | " gl_FragColor = mix(textureColor, textureColor2, textureColor2.a);\n" +
32 | " }";
33 |
34 | public GPUImageSourceOverBlendFilter() {
35 | super(SOURCE_OVER_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageSubtractBlendFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
18 |
19 | public class GPUImageSubtractBlendFilter extends GPUImageTwoInputFilter {
20 | public static final String SUBTRACT_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
21 | " varying highp vec2 textureCoordinate2;\n" +
22 | "\n" +
23 | " uniform sampler2D inputImageTexture;\n" +
24 | " uniform sampler2D inputImageTexture2;\n" +
25 | " \n" +
26 | " void main()\n" +
27 | " {\n" +
28 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
29 | " lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
30 | "\n" +
31 | " gl_FragColor = vec4(textureColor.rgb - textureColor2.rgb, textureColor.a);\n" +
32 | " }";
33 |
34 | public GPUImageSubtractBlendFilter() {
35 | super(SUBTRACT_BLEND_FRAGMENT_SHADER);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageThresholdEdgeDetection.java:
--------------------------------------------------------------------------------
1 | package com.createchance.simplevideoeditor.gpuimage;
2 |
3 | /**
4 | * Applies sobel edge detection on the image.
5 | */
6 | public class GPUImageThresholdEdgeDetection extends GPUImageFilterGroup {
7 | public GPUImageThresholdEdgeDetection() {
8 | super();
9 | addFilter(new GPUImageGrayscaleFilter());
10 | addFilter(new GPUImageSobelThresholdFilter());
11 | }
12 |
13 | public void setLineSize(final float size) {
14 | ((GPUImage3x3TextureSamplingFilter) getFilters().get(1)).setLineSize(size);
15 | }
16 |
17 | public void setThreshold(final float threshold) {
18 | ((GPUImageSobelThresholdFilter) getFilters().get(1)).setThreshold(threshold);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageTwoPassFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/GPUImageTwoPassTextureSamplingFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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 = mFilters.get(0);
37 | int texelWidthOffsetLocation = GLES20.glGetUniformLocation(filter.getProgram(), "texelWidthOffset");
38 | int texelHeightOffsetLocation = GLES20.glGetUniformLocation(filter.getProgram(), "texelHeightOffset");
39 | filter.setFloat(texelWidthOffsetLocation, ratio / mOutputWidth);
40 | filter.setFloat(texelHeightOffsetLocation, 0);
41 |
42 | ratio = getVerticalTexelOffsetRatio();
43 | filter = mFilters.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 / mOutputHeight);
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 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/main/java/com/createchance/simplevideoeditor/gpuimage/Rotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 CyberAgent
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.createchance.simplevideoeditor.gpuimage;
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: return 0;
30 | case ROTATION_90: return 90;
31 | case ROTATION_180: return 180;
32 | case ROTATION_270: return 270;
33 | default: throw new IllegalStateException("Unknown Rotation!");
34 | }
35 | }
36 |
37 | /**
38 | * Create a Rotation from an integer. Needs to be either 0, 90, 180 or 270.
39 | *
40 | * @param rotation 0, 90, 180 or 270
41 | * @return Rotation object
42 | */
43 | public static Rotation fromInt(int rotation) {
44 | switch (rotation) {
45 | case 0: return NORMAL;
46 | case 90: return ROTATION_90;
47 | case 180: return ROTATION_180;
48 | case 270: return ROTATION_270;
49 | case 360: return NORMAL;
50 | default: throw new IllegalStateException(
51 | rotation + " is an unknown rotation. Needs to be either 0, 90, 180 or 270!");
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/simplevideoeditor/src/test/java/com/createchance/simplevideoeditor/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.createchance.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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/simplevideoplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 |
6 | defaultConfig {
7 | minSdkVersion 15
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | lintOptions {
23 | abortOnError false
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(include: ['*.jar'], dir: 'libs')
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | testCompile 'junit:junit:4.12'
33 | }
34 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/generated/source/buildConfig/debug/com/qihoo360/mobilesafe/myvideo/simplevideoplayer/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package com.qihoo360.mobilesafe.myvideo.simplevideoplayer;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = Boolean.parseBoolean("true");
8 | public static final String APPLICATION_ID = "com.qihoo360.mobilesafe.myvideo.simplevideoplayer";
9 | public static final String BUILD_TYPE = "debug";
10 | public static final String FLAVOR = "";
11 | public static final int VERSION_CODE = 1;
12 | public static final String VERSION_NAME = "1.0";
13 | }
14 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/generated/source/r/debug/com/qihoo360/mobilesafe/myvideo/simplevideoplayer/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * gradle plugin from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 | package com.qihoo360.mobilesafe.myvideo.simplevideoplayer;
8 |
9 | public final class R {
10 | public static final class attr {
11 | public static int debug = 0x7f040001;
12 | public static int video_loop = 0x7f040002;
13 | public static int video_source = 0x7f040003;
14 | }
15 | public static final class string {
16 | public static int app_name = 0x7f150001;
17 | }
18 | public static final class styleable {
19 | public static int[] SimpleVideoPlayer = { 0x7f040001, 0x7f040002, 0x7f040003 };
20 | public static int SimpleVideoPlayer_debug = 0;
21 | public static int SimpleVideoPlayer_video_loop = 1;
22 | public static int SimpleVideoPlayer_video_source = 2;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/bundles/debug/R.txt:
--------------------------------------------------------------------------------
1 | int attr debug 0x7f040001
2 | int attr video_loop 0x7f040002
3 | int attr video_source 0x7f040003
4 | int string app_name 0x7f150001
5 | int[] styleable SimpleVideoPlayer { 0x7f040001, 0x7f040002, 0x7f040003 }
6 | int styleable SimpleVideoPlayer_debug 0
7 | int styleable SimpleVideoPlayer_video_loop 1
8 | int styleable SimpleVideoPlayer_video_source 2
9 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/bundles/debug/res/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | lib_video_player
5 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/compileDebugAidl/dependency.store:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/debug-mergeJniLibs/merge-state:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/simplevideoplayer/build/intermediates/incremental/debug-mergeJniLibs/merge-state
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/mergeDebugAssets/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/mergeDebugShaders/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/packageDebugResources/compile-file-map.properties:
--------------------------------------------------------------------------------
1 | #Sun Aug 19 15:54:21 CST 2018
2 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/packageDebugResources/merged.dir/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | lib_video_player
5 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/incremental/packageDebugResources/merger.xml:
--------------------------------------------------------------------------------
1 |
2 | lib_video_player
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/intermediate-jars/debug/classes.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CreateChance/SimpleVideoEditor/f02326e35812de71b5a5b7a13d1a1ae27da4fbdd/simplevideoplayer/build/intermediates/intermediate-jars/debug/classes.jar
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/intermediate-jars/debug/res.jar:
--------------------------------------------------------------------------------
1 | PK
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/javaPrecompile/debug/annotationProcessors.json:
--------------------------------------------------------------------------------
1 | []
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/manifests/aapt/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/manifests/aapt/debug/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"AAPT_FRIENDLY_MERGED_MANIFESTS"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"AndroidManifest.xml","properties":{"packageId":"com.qihoo360.mobilesafe.myvideo.simplevideoplayer","split":""}}]
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/manifests/full/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/manifests/full/debug/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"MERGED_MANIFESTS"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"AndroidManifest.xml","properties":{"packageId":"com.qihoo360.mobilesafe.myvideo.simplevideoplayer","split":""}}]
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/res/debug/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"PROCESSED_RES"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"resources-debug.ap_","properties":{"packageId":"com.qihoo360.mobilesafe.myvideo.simplevideoplayer","split":""}}]
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt:
--------------------------------------------------------------------------------
1 | com.qihoo360.mobilesafe.myvideo.simplevideoplayer
2 | int attr debug 0x7f040001
3 | int attr video_loop 0x7f040002
4 | int attr video_source 0x7f040003
5 | int string app_name 0x7f150001
6 | int[] styleable SimpleVideoPlayer { 0x7f040001, 0x7f040002, 0x7f040003 }
7 | int styleable SimpleVideoPlayer_debug 0
8 | int styleable SimpleVideoPlayer_video_loop 1
9 | int styleable SimpleVideoPlayer_video_source 2
10 |
--------------------------------------------------------------------------------
/simplevideoplayer/build/intermediates/transforms/mergeJniLibs/debug/__content__.json:
--------------------------------------------------------------------------------
1 | [{"name":"resources","index":0,"scopes":["PROJECT"],"types":["NATIVE_LIBS"],"format":"DIRECTORY","present":false}]
--------------------------------------------------------------------------------
/simplevideoplayer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/gaochao/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/androidTest/java/com/qihoo360/mobilesafe/myvideo/simplevideoplayer/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.qihoo360.mobilesafe.myvideo.simplevideoplayer;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.qihoo360.mobilesafe.myvideo.lib_video_player.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/java/com/createchance/IGestureListener.java:
--------------------------------------------------------------------------------
1 | package com.createchance;
2 |
3 | import android.view.MotionEvent;
4 |
5 | /**
6 | * 视频播放view手势监听器
7 | *
8 | * @author createchance
9 | * @date 18/09/2017
10 | */
11 |
12 | public interface IGestureListener {
13 | void onClick(MotionEvent event);
14 |
15 | void onMoving(MotionEvent from, MotionEvent to);
16 |
17 | void onMoveDone(MotionEvent from, MotionEvent to);
18 | }
19 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/java/com/createchance/PlayRequest.java:
--------------------------------------------------------------------------------
1 | package com.createchance;
2 |
3 | import android.net.Uri;
4 |
5 | /**
6 | * ${DESC}
7 | *
8 | * @author createchance
9 | * @date 13/04/2018
10 | */
11 | public class PlayRequest {
12 | public Uri videoSource;
13 |
14 | public int startPos;
15 |
16 | public boolean loop;
17 |
18 | public int leftVolume = -1;
19 | public int rightVolume = -1;
20 |
21 | private PlayRequest() {
22 |
23 | }
24 |
25 | public static class Builder {
26 | private PlayRequest request = new PlayRequest();
27 |
28 | public Builder source(Uri source) {
29 | request.videoSource = source;
30 |
31 | return this;
32 | }
33 |
34 | public Builder startFrom(int from) {
35 | request.startPos = from;
36 |
37 | return this;
38 | }
39 |
40 | public Builder loop(boolean loop) {
41 | request.loop = loop;
42 |
43 | return this;
44 | }
45 |
46 | public Builder leftVolume(int vol) {
47 | request.leftVolume = vol;
48 |
49 | return this;
50 | }
51 |
52 | public Builder rightVolume(int vol) {
53 | request.rightVolume = vol;
54 |
55 | return this;
56 | }
57 |
58 | public PlayRequest build() {
59 | return request;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/java/com/createchance/Utils.java:
--------------------------------------------------------------------------------
1 | package com.createchance;
2 |
3 | import android.graphics.Matrix;
4 | import android.util.Log;
5 | import android.view.TextureView;
6 |
7 | /**
8 | * 视频播放工具类
9 | *
10 | * @author createchance
11 | * @date 15/09/2017
12 | */
13 |
14 | class Utils {
15 |
16 | static boolean DEBUG = true;
17 |
18 | static void log(String msg) {
19 | if (DEBUG) {
20 | Log.d(SimpleVideoPlayer.class.getSimpleName(), msg);
21 | }
22 | }
23 |
24 | static void adjustAspectRatio(TextureView textureView, int viewWidth, int viewHeight, int videoWidth, int videoHeight) {
25 | final double aspectRatio = (double) videoHeight / videoWidth;
26 | int newWidth, newHeight;
27 |
28 | if (viewHeight > (int) (viewWidth * aspectRatio)) {
29 | // limited by narrow width; restrict height
30 | newWidth = viewWidth;
31 | newHeight = (int) (viewWidth * aspectRatio);
32 | } else {
33 | // limited by short height; restrict width
34 | newWidth = (int) (viewHeight / aspectRatio);
35 | newHeight = viewHeight;
36 | }
37 |
38 | final int xoff = (viewWidth - newWidth) / 2;
39 | final int yoff = (viewHeight - newHeight) / 2;
40 |
41 | final Matrix txform = new Matrix();
42 | textureView.getTransform(txform);
43 | txform.setScale((float) newWidth / viewWidth, (float) newHeight / viewHeight);
44 | txform.postTranslate(xoff, yoff);
45 | textureView.setTransform(txform);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/java/com/createchance/VideoPlayerCallback.java:
--------------------------------------------------------------------------------
1 | package com.createchance;
2 |
3 | import android.net.Uri;
4 |
5 | /**
6 | * 视频播放回调
7 | *
8 | * @author createchance
9 | * @date 18/09/2017
10 | */
11 | public abstract class VideoPlayerCallback {
12 |
13 | public void onStarted(Uri uri) {
14 | }
15 |
16 | public void onPaused(Uri uri) {
17 | }
18 |
19 | public void onResumed(Uri uri) {
20 | }
21 |
22 | public void onStopped(Uri uri) {
23 | }
24 |
25 | public void onCompletion(Uri uri) {
26 | }
27 |
28 | public void onError(Exception e) {
29 | }
30 |
31 | public void onVideoProgressUpdate(int position, int duration) {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | lib_video_player
3 |
4 |
--------------------------------------------------------------------------------
/simplevideoplayer/src/test/java/com/qihoo360/mobilesafe/myvideo/simplevideoplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.qihoo360.mobilesafe.myvideo.simplevideoplayer;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------