├── .gitignore
├── .idea
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── videocompress
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── videocompress
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── videocompress
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── silicompressor
├── .gitignore
├── build.gradle
├── libs
├── aspectjrt-1.7.3.jar
└── isoparser-1.0.6.jar
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── iceteck
│ └── silicompressorr
│ └── ApplicationTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── iceteck
│ │ └── silicompressorr
│ │ ├── FileUtils.java
│ │ ├── SiliCompressor.java
│ │ ├── Util.java
│ │ ├── VideoCompress.java
│ │ └── videocompression
│ │ ├── Config.java
│ │ ├── InputSurface.java
│ │ ├── MP4Builder.java
│ │ ├── MediaController.java
│ │ ├── Mp4Movie.java
│ │ ├── OutputSurface.java
│ │ ├── Sample.java
│ │ ├── TextureRenderer.java
│ │ ├── Track.java
│ │ └── VideoController.java
└── res
│ └── values
│ └── strings.xml
└── test
└── java
└── com
└── iceteck
└── silicompressorr
└── 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/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VideoCompress
2 | Android视频压缩
3 |
4 | 博客地址:http://blog.csdn.net/qq_36421691/article/details/79113392
5 |
6 | 首先: 视频压缩是硬解的压缩,我最开始接触压缩是FFMpeg压缩,使用的是 https://github.com/chenzhihui28/VideoRecorderAndCompressor ,想尝试的人也可以去看下,但是当我压缩的时候发现,压缩时间很慢,比如压缩1分46秒(253M,ViVO x7 plus)的视频花了2分多钟,具体时间自己可以去测,因为项目需要上传本地视频,本地视频一般很大。。假如是5分钟的视频那么用FFMpeg压缩时间就大于5分钟。。。,而且FFMpeg的命令我真的来不及去玩。。。里面涉及到东西有点多。。
7 |
8 | 然后: 项目又要很快要把这个压缩功能做完。。。我又没做过这个。。简直是一窍不通。。。 然后实在没法只有github上来找。。。。 之后了解到了硬解,十分感谢这篇文章,大家都可以去看下 https://github.com/Tourenathan-G5organisation/SiliCompressor 这篇文章看了之后,经测试 1分46秒的视频压缩只要1分10几秒左右,如果手机好点,还可以更快。。。。 但是这个文章没有progress,这让我很不方便查看,然后我就去浏览Issuses发现了有个人对这个progress进行了修改 https://github.com/fishwjy/VideoCompressor 我就把两篇文章合在一起使用了。。。。。
9 |
10 | 最后: 选择本地视频通过 https://github.com/LuckSiege/PictureSelector 来选择的,大家都可以去看下。。。。。
11 |
12 | 结语: github上的这个Wiki没怎么玩过不知道咋写。。。。。连传图和传gif都不知道咋玩。。。所以效果只有自己去测了, 而且这个项目只是做压缩的一个记录。。。。。如果有其他建议麻烦大家指正。
13 |
14 | # 错误
15 | Error:(56, 1) A problem occurred evaluating project ':silicompressor'.
16 | > Could not read script 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'.
17 | > Connection timed out: connect
18 | # 解决方法
19 | 在silicompressor/build.gradle删除以下两句话,然后rebulid(原因是没有梯子)
20 | // Place it at the end of the file
21 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
22 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
23 |
--------------------------------------------------------------------------------
/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.videocompress"
7 | minSdkVersion 15
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation 'com.android.support:appcompat-v7:26.1.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
28 | compile 'com.github.LuckSiege.PictureSelector:picture_library:v2.1.7'
29 | implementation project(':silicompressor')
30 | }
31 |
--------------------------------------------------------------------------------
/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/videocompress/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.videocompress;
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.videocompress", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/videocompress/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.videocompress;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.content.res.Configuration;
7 | import android.net.Uri;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 | import android.os.Environment;
11 | import android.util.Log;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 |
17 | import com.iceteck.silicompressorr.VideoCompress;
18 | import com.luck.picture.lib.PictureSelector;
19 | import com.luck.picture.lib.config.PictureConfig;
20 | import com.luck.picture.lib.config.PictureMimeType;
21 | import com.luck.picture.lib.entity.LocalMedia;
22 |
23 | import java.io.File;
24 | import java.text.SimpleDateFormat;
25 | import java.util.Date;
26 | import java.util.List;
27 | import java.util.Locale;
28 |
29 | public class MainActivity extends Activity implements View.OnClickListener {
30 | private static final String TAG = "MainActivity";
31 | private Button localButton;
32 | private Button compressButton;
33 | private long startTime, endTime;
34 | private String outputDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
35 | private String inputDir="";
36 | private TextView inputText;
37 | private TextView outPutText;
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_main);
42 | initView();
43 | }
44 |
45 | private void initView(){
46 | localButton=findViewById(R.id.localButton);
47 | compressButton=findViewById(R.id.compressButton);
48 | localButton.setOnClickListener(this);
49 | compressButton.setOnClickListener(this);
50 | inputText=findViewById(R.id.inputText);
51 | outPutText=findViewById(R.id.outPutText);
52 | }
53 |
54 | @Override
55 | public void onClick(View view) {
56 | switch (view.getId()){
57 | case R.id.localButton:
58 | setPicture();
59 | break;
60 | case R.id.compressButton:
61 | final String destPath = outputDir + File.separator + "VID_" + new SimpleDateFormat("yyyyMMdd_HHmmss", getLocale()).format(new Date()) + ".mp4";
62 | outPutText.setText(destPath);
63 | VideoCompress.compressVideoLow(inputDir, destPath, new VideoCompress.CompressListener() {
64 | @Override
65 | public void onStart() {
66 | startTime = System.currentTimeMillis();
67 | setTime(startTime,"开始时间");
68 |
69 | }
70 |
71 | @Override
72 | public void onSuccess() {
73 | endTime = System.currentTimeMillis();
74 | setTime(endTime,"结束时间");
75 | Log.i(TAG,"压缩后大小 = "+getFileSize(destPath));
76 | openFile(new File(destPath));
77 | }
78 |
79 | @Override
80 | public void onFail() {
81 | endTime = System.currentTimeMillis();
82 | setTime(endTime,"失败时间");
83 | }
84 |
85 | @Override
86 | public void onProgress(float percent) {
87 | Log.i(TAG,String.valueOf(percent) + "%");
88 | }
89 | });
90 | break;
91 | }
92 | }
93 |
94 | private void setPicture(){
95 | // 进入相册 以下是例子:用不到的api可以不写
96 | PictureSelector.create(MainActivity.this)
97 | .openGallery(PictureMimeType.ofVideo())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
98 | .imageSpanCount(4)// 每行显示个数 int
99 | .selectionMode(PictureConfig.SINGLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
100 | .previewVideo(true)// 是否可预览视频 true or false
101 | .enablePreviewAudio(true) // 是否可播放音频 true or false
102 | .isCamera(false)// 是否显示拍照按钮 true or false
103 | .openClickSound(false)// 是否开启点击声音 true or false
104 | .videoQuality(1)// 视频录制质量 0 or 1 int
105 | .videoMaxSecond(60)// 显示多少秒以内的视频or音频也可适用 int
106 | .videoMinSecond(10)// 显示多少秒以内的视频or音频也可适用 int
107 | .recordVideoSecond(60)//视频秒数录制 默认60s int
108 | .forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code
109 | }
110 |
111 |
112 | @Override
113 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
114 | super.onActivityResult(requestCode, resultCode, data);
115 | if (resultCode==RESULT_OK){
116 | switch (requestCode){
117 | case PictureConfig.CHOOSE_REQUEST:
118 | List selectList = PictureSelector.obtainMultipleResult(data);
119 | for (int i = 0; i = Build.VERSION_CODES.N) {
134 | sysLocale = getSystemLocale(config);
135 | } else {
136 | sysLocale = getSystemLocaleLegacy(config);
137 | }
138 |
139 | return sysLocale;
140 | }
141 |
142 | @SuppressWarnings("deprecation")
143 | public static Locale getSystemLocaleLegacy(Configuration config){
144 | return config.locale;
145 | }
146 |
147 | @TargetApi(Build.VERSION_CODES.N)
148 | public static Locale getSystemLocale(Configuration config){
149 | return config.getLocales().get(0);
150 | }
151 |
152 | private void setTime(Long time,String type){
153 | SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
154 | Date date=new Date(time);
155 | Log.i(TAG,type+" = "+dateFormat.format(date));
156 | }
157 |
158 |
159 | private void openFile(File file) {
160 | try {
161 | Intent intent = new Intent();
162 | //设置intent的Action属性
163 | intent.setAction(Intent.ACTION_VIEW);
164 | if (Build.VERSION.SDK_INT>=24){
165 | intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
166 | Uri contentUri=FileProvider.getUriForFile(this,"com.babyinhand.fileprovider",file);
167 | String type = getMIMEType(file);
168 | intent.setDataAndType(contentUri,type);
169 | }else {
170 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
171 | //获取文件file的MIME类型
172 | String type = getMIMEType(file);
173 | //设置intent的data和Type属性。
174 | intent.setDataAndType(/*uri*/Uri.fromFile(file), type);
175 | }
176 | //跳转
177 | startActivity(intent);
178 | } catch (Exception e) {
179 | Toast.makeText(ActivityLocalVideoActivity.this, "不能打开视频文件", Toast.LENGTH_SHORT).show();
180 | }
181 |
182 | }
183 |
184 |
185 | /**
186 | * 根据文件后缀名获得对应的MIME类型。
187 | *
188 | * @param file
189 | */
190 | private String getMIMEType(File file) {
191 |
192 | String type = "*/*";
193 | String fName = file.getName();
194 | //获取后缀名前的分隔符"."在fName中的位置。
195 | int dotIndex = fName.lastIndexOf(".");
196 | if (dotIndex < 0) {
197 | return type;
198 | }
199 | /* 获取文件的后缀名*/
200 | String end = fName.substring(dotIndex, fName.length()).toLowerCase();
201 | if (end == "") return type;
202 | //在MIME和文件类型的匹配表中找到对应的MIME类型。
203 | for (int i = 0; i < MIME_MapTable.length; i++) {
204 | if (end.equals(MIME_MapTable[i][0]))
205 | type = MIME_MapTable[i][1];
206 | }
207 | return type;
208 | }
209 |
210 | private final String[][] MIME_MapTable = {
211 | //{后缀名,MIME类型}
212 | {".3gp", "video/3gpp"},
213 | {".apk", "application/vnd.android.package-archive"},
214 | {".asf", "video/x-ms-asf"},
215 | {".avi", "video/x-msvideo"},
216 | {".bin", "application/octet-stream"},
217 | {".bmp", "image/bmp"},
218 | {".c", "text/plain"},
219 | {".class", "application/octet-stream"},
220 | {".conf", "text/plain"},
221 | {".cpp", "text/plain"},
222 | {".doc", "application/msword"},
223 | {".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
224 | {".xls", "application/vnd.ms-excel"},
225 | {".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
226 | {".exe", "application/octet-stream"},
227 | {".gif", "image/gif"},
228 | {".gtar", "application/x-gtar"},
229 | {".gz", "application/x-gzip"},
230 | {".h", "text/plain"},
231 | {".htm", "text/html"},
232 | {".html", "text/html"},
233 | {".jar", "application/java-archive"},
234 | {".java", "text/plain"},
235 | {".jpeg", "image/jpeg"},
236 | {".jpg", "image/jpeg"},
237 | {".js", "application/x-javascript"},
238 | {".log", "text/plain"},
239 | {".m3u", "audio/x-mpegurl"},
240 | {".m4a", "audio/mp4a-latm"},
241 | {".m4b", "audio/mp4a-latm"},
242 | {".m4p", "audio/mp4a-latm"},
243 | {".m4u", "video/vnd.mpegurl"},
244 | {".m4v", "video/x-m4v"},
245 | {".mov", "video/quicktime"},
246 | {".mp2", "audio/x-mpeg"},
247 | {".mp3", "audio/x-mpeg"},
248 | {".mp4", "video/mp4"},
249 | {".mpc", "application/vnd.mpohun.certificate"},
250 | {".mpe", "video/mpeg"},
251 | {".mpeg", "video/mpeg"},
252 | {".mpg", "video/mpeg"},
253 | {".mpg4", "video/mp4"},
254 | {".mpga", "audio/mpeg"},
255 | {".msg", "application/vnd.ms-outlook"},
256 | {".ogg", "audio/ogg"},
257 | {".pdf", "application/pdf"},
258 | {".png", "image/png"},
259 | {".pps", "application/vnd.ms-powerpoint"},
260 | {".ppt", "application/vnd.ms-powerpoint"},
261 | {".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"},
262 | {".prop", "text/plain"},
263 | {".rc", "text/plain"},
264 | {".rmvb", "audio/x-pn-realaudio"},
265 | {".rtf", "application/rtf"},
266 | {".sh", "text/plain"},
267 | {".tar", "application/x-tar"},
268 | {".tgz", "application/x-compressed"},
269 | {".txt", "text/plain"},
270 | {".wav", "audio/x-wav"},
271 | {".wma", "audio/x-ms-wma"},
272 | {".wmv", "audio/x-ms-wmv"},
273 | {".wps", "application/vnd.ms-works"},
274 | {".xml", "text/plain"},
275 | {".z", "application/x-compress"},
276 | {".zip", "application/x-zip-compressed"},
277 | {"", "*/*"}
278 | };
279 |
280 |
281 |
282 | private String getFileSize(String path) {
283 | File f = new File(path);
284 | if (!f.exists()) {
285 | return "0 MB";
286 | } else {
287 | long size = f.length();
288 | return (size / 1024f) / 1024f + "MB";
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/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/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
17 |
23 |
24 |
33 |
34 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/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/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #000000
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | VideoCompress
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/videocompress/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.videocompress;
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 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | maven { url 'https://jitpack.io' }
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/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/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 19 22:20:11 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:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':silicompressor'
2 |
--------------------------------------------------------------------------------
/silicompressor/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.iml
3 | .gradle
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /captures
9 |
--------------------------------------------------------------------------------
/silicompressor/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 |
5 |
6 |
7 | android {
8 | compileSdkVersion 26
9 | buildToolsVersion '26.0.2'
10 |
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion 26
14 | versionCode 4
15 | versionName "2.1"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | testCompile 'junit:junit:4.12'
28 | compile 'com.android.support:appcompat-v7:26.1.0'
29 | }
30 |
31 | ext {
32 | bintrayRepo = 'maven'
33 | bintrayName = 'silicompressor'
34 |
35 | publishedGroupId = 'com.iceteck.silicompressorr'
36 | libraryName = 'SiliCompressor'
37 | artifact = 'silicompressor'
38 |
39 | libraryDescription = 'This is a powerful image compression library for android.'
40 |
41 | siteUrl = 'https://github.com/Tourenathan-G5organisation/SiliCompressor'
42 | gitUrl = 'https://github.com/Tourenathan-G5organisation/SiliCompressor.git'
43 |
44 | libraryVersion = '2.1'
45 |
46 | developerId = 'tourenathan'
47 | developerName = 'TEYOU TOURE NATHAN'
48 | developerEmail = 'teyou21@gmail.com'
49 |
50 | licenseName = 'The Apache Software License, Version 2.0'
51 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
52 | allLicenses = ["Apache-2.0"]
53 | }
54 |
55 | // Place it at the end of the file
56 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
57 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
--------------------------------------------------------------------------------
/silicompressor/libs/aspectjrt-1.7.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/silicompressor/libs/aspectjrt-1.7.3.jar
--------------------------------------------------------------------------------
/silicompressor/libs/isoparser-1.0.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuxiaoqiang625/VideoCompress/4b5e00a43dea85c0a79eae9d5e0059f252f8c300/silicompressor/libs/isoparser-1.0.6.jar
--------------------------------------------------------------------------------
/silicompressor/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 C:\Users\Toure\AppData\Local\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 |
--------------------------------------------------------------------------------
/silicompressor/src/androidTest/java/com/iceteck/silicompressorr/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.iceteck.silicompressorr;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/silicompressor/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.iceteck.silicompressorr;
2 |
3 |
4 | /* Copyright (C) 2007-2008 OpenIntents.org
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 |
20 | import android.content.ContentResolver;
21 | import android.content.ContentUris;
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.database.Cursor;
25 | import android.database.DatabaseUtils;
26 | import android.graphics.Bitmap;
27 | import android.net.Uri;
28 | import android.os.Build;
29 | import android.os.Environment;
30 | import android.provider.DocumentsContract;
31 | import android.provider.MediaStore;
32 | import android.util.Log;
33 | import android.webkit.MimeTypeMap;
34 |
35 | import java.io.File;
36 | import java.io.FileFilter;
37 | import java.text.DecimalFormat;
38 | import java.util.Comparator;
39 |
40 | /**
41 | * @version 2009-07-03
42 | * @author Peli
43 | * @version 2013-12-11
44 | * @author paulburke (ipaulpro)
45 | */
46 | public class FileUtils {
47 | private FileUtils() {} //private constructor to enforce Singleton pattern
48 |
49 | /** TAG for log messages. */
50 | static final String TAG = "FileUtils";
51 | private static final boolean DEBUG = false; // Set to true to enable logging
52 |
53 | public static final String MIME_TYPE_AUDIO = "audio/*";
54 | public static final String MIME_TYPE_TEXT = "text/*";
55 | public static final String MIME_TYPE_IMAGE = "image/*";
56 | public static final String MIME_TYPE_VIDEO = "video/*";
57 | public static final String MIME_TYPE_APP = "application/*";
58 |
59 | public static final String HIDDEN_PREFIX = ".";
60 |
61 | /**
62 | * Gets the extension of a file name, like ".png" or ".jpg".
63 | *
64 | * @param uri
65 | * @return Extension including the dot("."); "" if there is no extension;
66 | * null if uri was null.
67 | */
68 | public static String getExtension(String uri) {
69 | if (uri == null) {
70 | return null;
71 | }
72 |
73 | int dot = uri.lastIndexOf(".");
74 | if (dot >= 0) {
75 | return uri.substring(dot);
76 | } else {
77 | // No extension.
78 | return "";
79 | }
80 | }
81 |
82 | /**
83 | * @return Whether the URI is a local one.
84 | */
85 | public static boolean isLocal(String url) {
86 | if (url != null && !url.startsWith("http://") && !url.startsWith("https://")) {
87 | return true;
88 | }
89 | return false;
90 | }
91 |
92 | /**
93 | * @return True if Uri is a MediaStore Uri.
94 | * @author paulburke
95 | */
96 | public static boolean isMediaUri(Uri uri) {
97 | return "media".equalsIgnoreCase(uri.getAuthority());
98 | }
99 |
100 | /**
101 | * Convert File into Uri.
102 | *
103 | * @param file
104 | * @return uri
105 | */
106 | public static Uri getUri(File file) {
107 | if (file != null) {
108 | return Uri.fromFile(file);
109 | }
110 | return null;
111 | }
112 |
113 | /**
114 | * Returns the path only (without file name).
115 | *
116 | * @param file
117 | * @return
118 | */
119 | public static File getPathWithoutFilename(File file) {
120 | if (file != null) {
121 | if (file.isDirectory()) {
122 | // no file to be split off. Return everything
123 | return file;
124 | } else {
125 | String filename = file.getName();
126 | String filepath = file.getAbsolutePath();
127 |
128 | // Construct path without file name.
129 | String pathwithoutname = filepath.substring(0,
130 | filepath.length() - filename.length());
131 | if (pathwithoutname.endsWith("/")) {
132 | pathwithoutname = pathwithoutname.substring(0, pathwithoutname.length() - 1);
133 | }
134 | return new File(pathwithoutname);
135 | }
136 | }
137 | return null;
138 | }
139 |
140 | /**
141 | * @return The MIME type for the given file.
142 | */
143 | public static String getMimeType(File file) {
144 |
145 | String extension = getExtension(file.getName());
146 |
147 | if (extension.length() > 0)
148 | return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.substring(1));
149 |
150 | return "application/octet-stream";
151 | }
152 |
153 | /**
154 | * @return The MIME type for the give Uri.
155 | */
156 | public static String getMimeType(Context context, Uri uri) {
157 | File file = new File(getPath(context, uri));
158 | return getMimeType(file);
159 | }
160 |
161 |
162 |
163 | /**
164 | * @param uri The Uri to check.
165 | * @return Whether the Uri authority is ExternalStorageProvider.
166 | * @author paulburke
167 | */
168 | public static boolean isExternalStorageDocument(Uri uri) {
169 | return "com.android.externalstorage.documents".equals(uri.getAuthority());
170 | }
171 |
172 | /**
173 | * @param uri The Uri to check.
174 | * @return Whether the Uri authority is DownloadsProvider.
175 | * @author paulburke
176 | */
177 | public static boolean isDownloadsDocument(Uri uri) {
178 | return "com.android.providers.downloads.documents".equals(uri.getAuthority());
179 | }
180 |
181 | /**
182 | * @param uri The Uri to check.
183 | * @return Whether the Uri authority is MediaProvider.
184 | * @author paulburke
185 | */
186 | public static boolean isMediaDocument(Uri uri) {
187 | return "com.android.providers.media.documents".equals(uri.getAuthority());
188 | }
189 |
190 | /**
191 | * @param uri The Uri to check.
192 | * @return Whether the Uri authority is Google Photos.
193 | */
194 | public static boolean isGooglePhotosUri(Uri uri) {
195 | return "com.google.android.apps.photos.content".equals(uri.getAuthority());
196 | }
197 |
198 | /**
199 | * Get the value of the data column for this Uri. This is useful for
200 | * MediaStore Uris, and other file-based ContentProviders.
201 | *
202 | * @param context The context.
203 | * @param uri The Uri to query.
204 | * @param selection (Optional) Filter used in the query.
205 | * @param selectionArgs (Optional) Selection arguments used in the query.
206 | * @return The value of the _data column, which is typically a file path.
207 | * @author paulburke
208 | */
209 | public static String getDataColumn(Context context, Uri uri, String selection,
210 | String[] selectionArgs) {
211 |
212 | Cursor cursor = null;
213 | final String column = "_data";
214 | final String[] projection = {
215 | column
216 | };
217 |
218 | try {
219 | cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
220 | null);
221 | if (cursor != null && cursor.moveToFirst()) {
222 | if (DEBUG)
223 | DatabaseUtils.dumpCursor(cursor);
224 |
225 | final int column_index = cursor.getColumnIndexOrThrow(column);
226 | return cursor.getString(column_index);
227 | }
228 | } finally {
229 | if (cursor != null)
230 | cursor.close();
231 | }
232 | return null;
233 | }
234 |
235 | /**
236 | * Get a file path from a Uri. This will get the the path for Storage Access
237 | * Framework Documents, as well as the _data field for the MediaStore and
238 | * other file-based ContentProviders.
239 | *
240 | * Callers should check whether the path is local before assuming it
241 | * represents a local file.
242 | *
243 | * @param context The context.
244 | * @param uri The Uri to query.
245 | * @see #isLocal(String)
246 | * @see #getFile(Context, Uri)
247 | * @author paulburke
248 | */
249 | public static String getPath(final Context context, final Uri uri) {
250 |
251 | if (DEBUG)
252 | Log.d(TAG + " File -",
253 | "Authority: " + uri.getAuthority() +
254 | ", Fragment: " + uri.getFragment() +
255 | ", Port: " + uri.getPort() +
256 | ", Query: " + uri.getQuery() +
257 | ", Scheme: " + uri.getScheme() +
258 | ", Host: " + uri.getHost() +
259 | ", Segments: " + uri.getPathSegments().toString()
260 | );
261 |
262 | final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
263 |
264 | // DocumentProvider
265 |
266 | if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) {
267 |
268 | // ExternalStorageProvider
269 | if (isExternalStorageDocument(uri)) {
270 | final String docId = DocumentsContract.getDocumentId(uri);
271 | final String[] split = docId.split(":");
272 | final String type = split[0];
273 |
274 | if ("primary".equalsIgnoreCase(type)) {
275 | return Environment.getExternalStorageDirectory() + "/" + split[1];
276 | }
277 |
278 |
279 | }
280 | // DownloadsProvider
281 | else if (isDownloadsDocument(uri)) {
282 |
283 | final String id = DocumentsContract.getDocumentId(uri);
284 | final Uri contentUri = ContentUris.withAppendedId(
285 | Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
286 |
287 | return getDataColumn(context, contentUri, null, null);
288 | }
289 | // MediaProvider
290 | else if (isMediaDocument(uri)) {
291 | final String docId = DocumentsContract.getDocumentId(uri);
292 | final String[] split = docId.split(":");
293 | final String type = split[0];
294 |
295 | Uri contentUri = null;
296 | if ("image".equals(type)) {
297 | contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
298 | } else if ("video".equals(type)) {
299 | contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
300 | } else if ("audio".equals(type)) {
301 | contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
302 | }
303 |
304 | final String selection = "_id=?";
305 | final String[] selectionArgs = new String[] {
306 | split[1]
307 | };
308 |
309 | return getDataColumn(context, contentUri, selection, selectionArgs);
310 | }
311 | }
312 | // MediaStore (and general)
313 | else if ("content".equalsIgnoreCase(uri.getScheme())) {
314 |
315 | // Return the remote address
316 | if (isGooglePhotosUri(uri))
317 | return uri.getLastPathSegment();
318 |
319 | return getDataColumn(context, uri, null, null);
320 | }
321 | // File
322 | else if ("file".equalsIgnoreCase(uri.getScheme())) {
323 | return uri.getPath();
324 | }
325 |
326 |
327 | return null;
328 | }
329 |
330 | /**
331 | * Convert Uri into File, if possible.
332 | *
333 | * @return file A local file that the Uri was pointing to, or null if the
334 | * Uri is unsupported or pointed to a remote resource.
335 | * @see #getPath(Context, Uri)
336 | * @author paulburke
337 | */
338 | public static File getFile(Context context, Uri uri) {
339 | if (uri != null) {
340 | String path = getPath(context, uri);
341 | if (path != null && isLocal(path)) {
342 | return new File(path);
343 | }
344 | }
345 | return null;
346 | }
347 |
348 | /**
349 | * Get the file size in a human-readable string.
350 | *
351 | * @param size
352 | * @return
353 | * @author paulburke
354 | */
355 | public static String getReadableFileSize(int size) {
356 | final int BYTES_IN_KILOBYTES = 1024;
357 | final DecimalFormat dec = new DecimalFormat("###.#");
358 | final String KILOBYTES = " KB";
359 | final String MEGABYTES = " MB";
360 | final String GIGABYTES = " GB";
361 | float fileSize = 0;
362 | String suffix = KILOBYTES;
363 |
364 | if (size > BYTES_IN_KILOBYTES) {
365 | fileSize = size / BYTES_IN_KILOBYTES;
366 | if (fileSize > BYTES_IN_KILOBYTES) {
367 | fileSize = fileSize / BYTES_IN_KILOBYTES;
368 | if (fileSize > BYTES_IN_KILOBYTES) {
369 | fileSize = fileSize / BYTES_IN_KILOBYTES;
370 | suffix = GIGABYTES;
371 | } else {
372 | suffix = MEGABYTES;
373 | }
374 | }
375 | }
376 | return String.valueOf(dec.format(fileSize) + suffix);
377 | }
378 |
379 | /**
380 | * Attempt to retrieve the thumbnail of given File from the MediaStore. This
381 | * should not be called on the UI thread.
382 | *
383 | * @param context
384 | * @param file
385 | * @return
386 | * @author paulburke
387 | */
388 | public static Bitmap getThumbnail(Context context, File file) {
389 | return getThumbnail(context, getUri(file), getMimeType(file));
390 | }
391 |
392 | /**
393 | * Attempt to retrieve the thumbnail of given Uri from the MediaStore. This
394 | * should not be called on the UI thread.
395 | *
396 | * @param context
397 | * @param uri
398 | * @return
399 | * @author paulburke
400 | */
401 | public static Bitmap getThumbnail(Context context, Uri uri) {
402 | return getThumbnail(context, uri, getMimeType(context, uri));
403 | }
404 |
405 | /**
406 | * Attempt to retrieve the thumbnail of given Uri from the MediaStore. This
407 | * should not be called on the UI thread.
408 | *
409 | * @param context
410 | * @param uri
411 | * @param mimeType
412 | * @return
413 | * @author paulburke
414 | */
415 | public static Bitmap getThumbnail(Context context, Uri uri, String mimeType) {
416 | if (DEBUG)
417 | Log.d(TAG, "Attempting to get thumbnail");
418 |
419 | if (!isMediaUri(uri)) {
420 | Log.e(TAG, "You can only retrieve thumbnails for images and videos.");
421 | return null;
422 | }
423 |
424 | Bitmap bm = null;
425 | if (uri != null) {
426 | final ContentResolver resolver = context.getContentResolver();
427 | Cursor cursor = null;
428 | try {
429 | cursor = resolver.query(uri, null, null, null, null);
430 | if (cursor.moveToFirst()) {
431 | final int id = cursor.getInt(0);
432 | if (DEBUG)
433 | Log.d(TAG, "Got thumb ID: " + id);
434 |
435 | if (mimeType.contains("video")) {
436 | bm = MediaStore.Video.Thumbnails.getThumbnail(
437 | resolver,
438 | id,
439 | MediaStore.Video.Thumbnails.MINI_KIND,
440 | null);
441 | }
442 | else if (mimeType.contains(FileUtils.MIME_TYPE_IMAGE)) {
443 | bm = MediaStore.Images.Thumbnails.getThumbnail(
444 | resolver,
445 | id,
446 | MediaStore.Images.Thumbnails.MINI_KIND,
447 | null);
448 | }
449 | }
450 | } catch (Exception e) {
451 | if (DEBUG)
452 | Log.e(TAG, "getThumbnail", e);
453 | } finally {
454 | if (cursor != null)
455 | cursor.close();
456 | }
457 | }
458 | return bm;
459 | }
460 |
461 | /**
462 | * File and folder comparator. TODO Expose sorting option method
463 | *
464 | * @author paulburke
465 | */
466 | public static Comparator sComparator = new Comparator() {
467 | @Override
468 | public int compare(File f1, File f2) {
469 | // Sort alphabetically by lower case, which is much cleaner
470 | return f1.getName().toLowerCase().compareTo(
471 | f2.getName().toLowerCase());
472 | }
473 | };
474 |
475 | /**
476 | * File (not directories) filter.
477 | *
478 | * @author paulburke
479 | */
480 | public static FileFilter sFileFilter = new FileFilter() {
481 | @Override
482 | public boolean accept(File file) {
483 | final String fileName = file.getName();
484 | // Return files only (not directories) and skip hidden files
485 | return file.isFile() && !fileName.startsWith(HIDDEN_PREFIX);
486 | }
487 | };
488 |
489 | /**
490 | * Folder (directories) filter.
491 | *
492 | * @author paulburke
493 | */
494 | public static FileFilter sDirFilter = new FileFilter() {
495 | @Override
496 | public boolean accept(File file) {
497 | final String fileName = file.getName();
498 | // Return directories only and skip hidden directories
499 | return file.isDirectory() && !fileName.startsWith(HIDDEN_PREFIX);
500 | }
501 | };
502 |
503 | /**
504 | * Get the Intent for selecting content to be used in an Intent Chooser.
505 | *
506 | * @return The intent for opening a file with Intent.createChooser()
507 | * @author paulburke
508 | */
509 | public static Intent createGetContentIntent() {
510 | // Implicitly allow the user to select a particular kind of data
511 | final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
512 | // The MIME data type filter
513 | intent.setType("*/*");
514 | // Only return URIs that can be opened with ContentResolver
515 | intent.addCategory(Intent.CATEGORY_OPENABLE);
516 | return intent;
517 | }
518 | }
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/SiliCompressor.java:
--------------------------------------------------------------------------------
1 | package com.iceteck.silicompressorr;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.database.Cursor;
6 | import android.graphics.Bitmap;
7 | import android.graphics.BitmapFactory;
8 | import android.graphics.Canvas;
9 | import android.graphics.Matrix;
10 | import android.graphics.Paint;
11 | import android.media.ExifInterface;
12 | import android.net.Uri;
13 | import android.os.Environment;
14 | import android.provider.DocumentsContract;
15 | import android.provider.MediaStore;
16 | import android.util.Log;
17 |
18 | import com.iceteck.silicompressorr.videocompression.MediaController;
19 |
20 | import java.io.File;
21 | import java.io.FileNotFoundException;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 | import java.net.URISyntaxException;
25 | import java.text.SimpleDateFormat;
26 | import java.util.Date;
27 | import java.util.Locale;
28 |
29 | /**
30 | * @author Toure, Akah L
31 | * @version 1.1.1
32 | * Created by Toure on 28/03/2016.
33 | */
34 | public class SiliCompressor {
35 |
36 | private static final String LOG_TAG = SiliCompressor.class.getSimpleName();
37 | public static String videoCompressionPath ;
38 |
39 | static volatile SiliCompressor singleton = null;
40 | private static Context mContext;
41 |
42 | public SiliCompressor(Context context){
43 | mContext = context;
44 | }
45 |
46 | // initialise the class and set the context
47 | public static SiliCompressor with(Context context){
48 | if (singleton == null) {
49 | synchronized (SiliCompressor.class) {
50 | if (singleton == null) {
51 | singleton = new Builder(context).build();
52 | }
53 | }
54 | }
55 | return singleton;
56 |
57 | }
58 |
59 | /**
60 | * Compresses the image at the specified Uri String and and return the filepath of the compressed image.
61 | * @param imageUri imageUri Uri (String) of the source image you wish to compress
62 | * @return filepath
63 | */
64 | public String compress(String imageUri, File destination){
65 | return compressImage(imageUri, destination);
66 | }
67 |
68 | /**
69 | * Compresses the image at the specified Uri String and and return the filepath of the compressed image.
70 | * @param imageUri imageUri Uri (String) of the source image you wish to compress
71 | * @return filepath
72 | */
73 | public String compress(String imageUri, File destination, boolean deleteSourceImage){
74 |
75 | String compressUri = compressImage(imageUri, destination);
76 |
77 | if (deleteSourceImage)
78 | {
79 | File source = new File(getRealPathFromURI(imageUri));
80 | if (source.exists()) {
81 | boolean isdeleted = source.delete();
82 | Log.d(LOG_TAG, (isdeleted) ? "SourceImage File deleted" : "SourceImage File not deleted");
83 | }
84 | }
85 |
86 | return compressUri;
87 | }
88 |
89 |
90 | public String compress(int drawableID) throws IOException {
91 |
92 | // Create a bitmap from this drawable
93 | Bitmap bitmap = BitmapFactory.decodeResource(mContext.getApplicationContext().getResources(), drawableID);
94 | if (null != bitmap){
95 | // Create a file from the bitmap
96 |
97 | // Create an image file name
98 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ENGLISH).format(new Date());
99 | String imageFileName = "JPEG_" + timeStamp + "_";
100 | File storageDir = Environment.getExternalStoragePublicDirectory(
101 | Environment.DIRECTORY_PICTURES);
102 | File image = File.createTempFile(
103 | imageFileName, /* prefix */
104 | ".jpg", /* suffix */
105 | storageDir /* directory */
106 | );
107 | FileOutputStream out = new FileOutputStream(image);
108 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
109 |
110 | // Compress the new file
111 | Uri copyImageUri = Uri.fromFile(image);
112 |
113 | String compressImagePath = compressImage(copyImageUri.toString(),new File(Environment.getExternalStorageDirectory(), "Silicompressor/images"));
114 |
115 | // Delete the file create from the drawable Id
116 | if (image.exists()) {
117 | boolean isdeleted = image.delete();
118 | Log.d(LOG_TAG, (isdeleted) ? "SourceImage File deleted" : "SourceImage File not deleted");
119 | }
120 |
121 | // return the path to the compress image
122 | return compressImagePath;
123 | }
124 |
125 | return null;
126 | }
127 |
128 |
129 | /**
130 | * Compresses the image at the specified Uri String and and return the bitmap data of the compressed image.
131 | *
132 | * @param imageUri imageUri Uri (String) of the source image you wish to compress
133 | * @return Bitmap format of the new image file (compressed)
134 | * @throws IOException
135 | */
136 | public Bitmap getCompressBitmap(String imageUri) throws IOException {
137 | File imageFile = new File(compressImage(imageUri,new File(Environment.getExternalStorageDirectory(), "Silicompressor/images")));
138 | Uri newImageUri = Uri.fromFile(imageFile);
139 | Bitmap bitmap = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), newImageUri);
140 | return bitmap;
141 | }
142 |
143 | /**
144 | * Compresses the image at the specified Uri String and and return the bitmap data of the compressed image.
145 | * @param imageUri Uri (String) of the source image you wish to compress
146 | * @param deleteSourceImage If True will delete the source file
147 | * @return Compress image bitmap
148 | * @throws IOException
149 | */
150 | public Bitmap getCompressBitmap(String imageUri, boolean deleteSourceImage) throws IOException {
151 | File imageFile = new File(compressImage(imageUri,new File(Environment.getExternalStorageDirectory(), "Silicompressor/images")));
152 | Uri newImageUri = Uri.fromFile(imageFile);
153 | Bitmap bitmap = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), newImageUri);
154 |
155 | if (deleteSourceImage)
156 | {
157 | File source = new File(getRealPathFromURI(imageUri));
158 | if (source.exists()) {
159 | boolean isdeleted = source.delete();
160 | Log.d(LOG_TAG, (isdeleted) ? "SourceImage File deleted" : "SourceImage File not deleted");
161 | }
162 | }
163 | return bitmap;
164 | }
165 |
166 | /**
167 | * Do the actual compression of this image
168 | * @param imageUri source image file to compress
169 | * @param destDirectory destination directory to place image in
170 | * @return uri string of the compressed image
171 | */
172 | private String compressImage(String imageUri, File destDirectory) {
173 |
174 | String filePath = getRealPathFromURI(imageUri);
175 | Bitmap scaledBitmap = null;
176 |
177 | BitmapFactory.Options options = new BitmapFactory.Options();
178 |
179 | // by setting this field as true, the actual bitmap pixels are not loaded in the memory. Just the bounds are loaded. If
180 | // you try the use the bitmap here, you will get null.
181 | options.inJustDecodeBounds = true;
182 | Bitmap bmp = BitmapFactory.decodeFile(filePath, options);
183 |
184 | int actualHeight = options.outHeight;
185 | int actualWidth = options.outWidth;
186 |
187 | // max Height and width values of the compressed image is taken as 816x612
188 |
189 | float maxHeight = 816.0f;
190 | float maxWidth = 612.0f;
191 | float imgRatio = actualWidth / actualHeight;
192 | float maxRatio = maxWidth / maxHeight;
193 |
194 | // width and height values are set maintaining the aspect ratio of the image
195 |
196 | if (actualHeight > maxHeight || actualWidth > maxWidth) {
197 | if (imgRatio < maxRatio) {
198 | imgRatio = maxHeight / actualHeight;
199 | actualWidth = (int) (imgRatio * actualWidth);
200 | actualHeight = (int) maxHeight;
201 | } else if (imgRatio > maxRatio) {
202 | imgRatio = maxWidth / actualWidth;
203 | actualHeight = (int) (imgRatio * actualHeight);
204 | actualWidth = (int) maxWidth;
205 | } else {
206 | actualHeight = (int) maxHeight;
207 | actualWidth = (int) maxWidth;
208 |
209 | }
210 | }
211 |
212 | // setting inSampleSize value allows to load a scaled down version of the original image
213 |
214 | options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight);
215 |
216 | // inJustDecodeBounds set to false to load the actual bitmap
217 | options.inJustDecodeBounds = false;
218 |
219 | // this options allow android to claim the bitmap memory if it runs low on memory
220 | options.inPurgeable = true;
221 | options.inInputShareable = true;
222 | options.inTempStorage = new byte[16 * 1024];
223 |
224 | try {
225 | // load the bitmap from its path
226 | bmp = BitmapFactory.decodeFile(filePath, options);
227 | } catch (OutOfMemoryError exception) {
228 | exception.printStackTrace();
229 |
230 | }
231 | try {
232 | scaledBitmap = Bitmap.createBitmap(actualWidth, actualHeight, Bitmap.Config.ARGB_8888);
233 | } catch (OutOfMemoryError exception) {
234 | exception.printStackTrace();
235 | }
236 |
237 | float ratioX = actualWidth / (float) options.outWidth;
238 | float ratioY = actualHeight / (float) options.outHeight;
239 | float middleX = actualWidth / 2.0f;
240 | float middleY = actualHeight / 2.0f;
241 |
242 | Matrix scaleMatrix = new Matrix();
243 | scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
244 |
245 | Canvas canvas = new Canvas(scaledBitmap);
246 | canvas.setMatrix(scaleMatrix);
247 | canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
248 |
249 | // check the rotation of the image and display it properly
250 | ExifInterface exif;
251 | try {
252 | exif = new ExifInterface(filePath);
253 |
254 | int orientation = exif.getAttributeInt(
255 | ExifInterface.TAG_ORIENTATION, 0);
256 | Log.d("EXIF", "Exif: " + orientation);
257 | Matrix matrix = new Matrix();
258 | if (orientation == 6) {
259 | matrix.postRotate(90);
260 | Log.d("EXIF", "Exif: " + orientation);
261 | } else if (orientation == 3) {
262 | matrix.postRotate(180);
263 | Log.d("EXIF", "Exif: " + orientation);
264 | } else if (orientation == 8) {
265 | matrix.postRotate(270);
266 | Log.d("EXIF", "Exif: " + orientation);
267 | }
268 | scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0,
269 | scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix,
270 | true);
271 | } catch (IOException e) {
272 | e.printStackTrace();
273 | }
274 |
275 | FileOutputStream out = null;
276 | String filename = getFilename(imageUri, destDirectory);
277 | try {
278 | out = new FileOutputStream(filename);
279 |
280 | // write the compressed bitmap at the destination specified by filename.
281 | scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 80, out);
282 |
283 | } catch (FileNotFoundException e) {
284 | e.printStackTrace();
285 | }
286 |
287 | return filename;
288 |
289 | }
290 |
291 | /**
292 | * Perform background video compression. Make sure the videofileUri and destinationUri are valid
293 | * resources because this method does not account for missing directories hence your converted file
294 | * could be in an unknown location
295 | * This uses default values for the converted videos
296 | * @param videoFilePath source path for the video file
297 | * @param destinationDir destination directory where converted file should be saved
298 | * @return The Path of the compressed video file
299 | */
300 | public String compressVideo(String videoFilePath, String destinationDir) throws URISyntaxException {
301 | return compressVideo( videoFilePath, destinationDir, 0, 0, 0 );
302 | }
303 |
304 | /**
305 | * Perform background video compression. Make sure the videofileUri and destinationUri are valid
306 | * resources because this method does not account for missing directories hence your converted file
307 | * could be in an unknown location
308 | * This uses default values for the converted videos
309 | * @param videoFileUri source uri for the video file
310 | * @param destinationDir destination directory where converted file should be saved
311 | * @return The Path of the compressed video file
312 | */
313 | public String compressVideo(Uri videoFileUri, String destinationDir) throws URISyntaxException {
314 | return compressVideo( videoFileUri, destinationDir, 0, 0, 0 );
315 | }
316 |
317 | /**
318 | * Perform background video compression. Make sure the videofileUri and destinationUri are valid
319 | * resources because this method does not account for missing directories hence your converted file
320 | * could be in an unknown location
321 | * @param videoFileUri source uri for the video file
322 | * @param destinationDir destination directory where converted file should be saved
323 | * @param outWidth the target width of the compressed video or 0 to use default width
324 | * @param outHeight the target height of the compressed video or 0 to use default height
325 | * @param bitrate the target bitrate of the compressed video or 0 to user default bitrate
326 | * @return The Path of the compressed video file
327 | */
328 | public String compressVideo(Uri videoFileUri, String destinationDir, int outWidth, int outHeight, int bitrate) throws URISyntaxException {
329 | boolean isconverted = MediaController.getInstance().convertVideo(Util.getFilePath(mContext, videoFileUri), new File(destinationDir), outWidth, outHeight, bitrate);
330 | if (isconverted){
331 | Log.v(LOG_TAG, "Video Conversion Complete");
332 | }else{
333 | Log.v(LOG_TAG, "Video conversion in progress");
334 | }
335 |
336 | return MediaController.cachedFile.getPath();
337 |
338 | }
339 |
340 |
341 | /**
342 | * Perform background video compression. Make sure the videofileUri and destinationUri are valid
343 | * resources because this method does not account for missing directories hence your converted file
344 | * could be in an unknown location
345 | * @param videoFilePath source path for the video file
346 | * @param destinationDir destination directory where converted file should be saved
347 | * @param outWidth the target width of the compressed video or 0 to use default width
348 | * @param outHeight the target height of the compressed video or 0 to use default height
349 | * @param bitrate the target bitrate of the compressed video or 0 to user default bitrate
350 | * @return The Path of the compressed video file
351 | */
352 | public String compressVideo(String videoFilePath, String destinationDir, int outWidth, int outHeight, int bitrate) throws URISyntaxException {
353 | boolean isconverted = MediaController.getInstance().convertVideo( videoFilePath, new File(destinationDir), outWidth, outHeight, bitrate);
354 | if (isconverted){
355 | Log.v(LOG_TAG, "Video Conversion Complete");
356 | }else{
357 | Log.v(LOG_TAG, "Video conversion in progress");
358 | }
359 |
360 | return MediaController.cachedFile.getPath();
361 |
362 | }
363 |
364 |
365 | private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
366 | final int height = options.outHeight;
367 | final int width = options.outWidth;
368 | int inSampleSize = 1;
369 |
370 | if (height > reqHeight || width > reqWidth) {
371 | final int heightRatio = Math.round((float) height / (float) reqHeight);
372 | final int widthRatio = Math.round((float) width / (float) reqWidth);
373 | inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
374 | }
375 | final float totalPixels = width * height;
376 | final float totalReqPixelsCap = reqWidth * reqHeight * 2;
377 | while (totalPixels / (inSampleSize * inSampleSize) > totalReqPixelsCap) {
378 | inSampleSize++;
379 | }
380 |
381 | return inSampleSize;
382 | }
383 |
384 | private String getFilename(String filename, File file) {
385 | if (!file.exists()) {
386 | file.mkdirs();
387 | }
388 | String ext = ".jpg";
389 | //get extension
390 | /*if (Pattern.matches("^[.][p][n][g]", filename)){
391 | ext = ".png";
392 | }*/
393 |
394 | return (file.getAbsolutePath() + "/IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ext);
395 |
396 | }
397 |
398 | /**
399 | * Gets a valid path from the supply contentURI
400 | * @param contentURI
401 | * @return A validPath of the image
402 | */
403 | private String getRealPathFromURI(String contentURI) {
404 | Uri contentUri = Uri.parse(contentURI);
405 | Cursor cursor = mContext.getContentResolver().query(contentUri, null, null, null, null);
406 | if (cursor == null) {
407 | return contentUri.getPath();
408 | } else {
409 | cursor.moveToFirst();
410 | int index = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
411 | String str = cursor.getString(index);
412 | cursor.close();
413 | return str;
414 | }
415 | // return FileUtils.getPath(mContext, contentUri);
416 |
417 | // return getRealPathFromURI_API19(mContext, contentUri);
418 |
419 |
420 | }
421 | @SuppressLint("NewApi")
422 | public static String getRealPathFromURI_API19(Context context, Uri uri){
423 | String filePath = "";
424 | String wholeID = DocumentsContract.getDocumentId(uri);
425 |
426 | // Split at colon, use second item in the array
427 | String id = wholeID.split(":")[1];
428 |
429 | String[] column = { MediaStore.Images.Media.DATA };
430 |
431 | // where id is equal to
432 | String sel = MediaStore.Images.Media._ID + "=?";
433 |
434 | Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
435 | column, sel, new String[]{ id }, null);
436 |
437 | int columnIndex = cursor.getColumnIndex(column[0]);
438 |
439 | if (cursor.moveToFirst()) {
440 | filePath = cursor.getString(columnIndex);
441 | }
442 | cursor.close();
443 | return filePath;
444 | }
445 |
446 | /**
447 | * Fluent API for creating {@link SiliCompressor} instances.
448 | */
449 | public static class Builder {
450 |
451 | private final Context context;
452 |
453 |
454 | /**
455 | * Start building a new {@link SiliCompressor} instance.
456 | */
457 | public Builder(Context context) {
458 | if (context == null) {
459 | throw new IllegalArgumentException("Context must not be null.");
460 | }
461 | this.context = context.getApplicationContext();
462 | }
463 |
464 |
465 | /**
466 | * Create the {@link SiliCompressor} instance.
467 | */
468 | public SiliCompressor build() {
469 | Context context = this.context;
470 |
471 | return new SiliCompressor(context);
472 | }
473 | }
474 |
475 | }
476 |
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/Util.java:
--------------------------------------------------------------------------------
1 | package com.iceteck.silicompressorr;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.ContentUris;
5 | import android.content.Context;
6 | import android.database.Cursor;
7 | import android.net.Uri;
8 | import android.os.Build;
9 | import android.os.Environment;
10 | import android.provider.DocumentsContract;
11 | import android.provider.MediaStore;
12 |
13 | import java.net.URISyntaxException;
14 |
15 | /**
16 | * Created by Larry Akah on 5/23/17.
17 | */
18 |
19 | public class Util {
20 |
21 | @SuppressLint("NewApi")
22 | public static String getFilePath(Context context, Uri uri) throws URISyntaxException {
23 | String selection = null;
24 | String[] selectionArgs = null;
25 | // Uri is different in versions after KITKAT (Android 4.4), we need to
26 | if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context.getApplicationContext(), uri)) {
27 | if (isExternalStorageDocument(uri)) {
28 | final String docId = DocumentsContract.getDocumentId(uri);
29 | final String[] split = docId.split(":");
30 | return Environment.getExternalStorageDirectory() + "/" + split[1];
31 | } else if (isDownloadsDocument(uri)) {
32 | final String id = DocumentsContract.getDocumentId(uri);
33 | uri = ContentUris.withAppendedId(
34 | Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
35 | } else if (isMediaDocument(uri)) {
36 | final String docId = DocumentsContract.getDocumentId(uri);
37 | final String[] split = docId.split(":");
38 | final String type = split[0];
39 | if ("image".equals(type)) {
40 | uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
41 | } else if ("video".equals(type)) {
42 | uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
43 | } else if ("audio".equals(type)) {
44 | uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
45 | }
46 | selection = "_id=?";
47 | selectionArgs = new String[]{
48 | split[1]
49 | };
50 | }
51 | }
52 | if ("content".equalsIgnoreCase(uri.getScheme())) {
53 | String[] projection = {
54 | MediaStore.Images.Media.DATA
55 | };
56 | Cursor cursor = null;
57 | try {
58 | cursor = context.getContentResolver()
59 | .query(uri, projection, selection, selectionArgs, null);
60 | int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
61 | if (cursor.moveToFirst()) {
62 | return cursor.getString(column_index);
63 | }
64 | } catch (Exception e) {
65 | e.printStackTrace();
66 | }
67 | } else if ("file".equalsIgnoreCase(uri.getScheme())) {
68 | return uri.getPath();
69 | }
70 | return null;
71 | }
72 |
73 | public static boolean isExternalStorageDocument(Uri uri) {
74 | return "com.android.externalstorage.documents".equals(uri.getAuthority());
75 | }
76 |
77 | public static boolean isDownloadsDocument(Uri uri) {
78 | return "com.android.providers.downloads.documents".equals(uri.getAuthority());
79 | }
80 |
81 | public static boolean isMediaDocument(Uri uri) {
82 | return "com.android.providers.media.documents".equals(uri.getAuthority());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/VideoCompress.java:
--------------------------------------------------------------------------------
1 | package com.iceteck.silicompressorr;
2 |
3 | import android.os.AsyncTask;
4 |
5 | import com.iceteck.silicompressorr.videocompression.VideoController;
6 |
7 | /**
8 | * Created by Vincent Woo
9 | * Date: 2017/8/16
10 | * Time: 15:15
11 | */
12 |
13 | public class VideoCompress {
14 | private static final String TAG = VideoCompress.class.getSimpleName();
15 |
16 | public static VideoCompressTask compressVideoHigh(String srcPath, String destPath, CompressListener listener) {
17 | VideoCompressTask task = new VideoCompressTask(listener, VideoController.COMPRESS_QUALITY_HIGH);
18 | task.execute(srcPath, destPath);
19 | return task;
20 | }
21 |
22 | public static VideoCompressTask compressVideoMedium(String srcPath, String destPath, CompressListener listener) {
23 | VideoCompressTask task = new VideoCompressTask(listener, VideoController.COMPRESS_QUALITY_MEDIUM);
24 | task.execute(srcPath, destPath);
25 | return task;
26 | }
27 |
28 | public static VideoCompressTask compressVideoLow(String srcPath, String destPath, CompressListener listener) {
29 | VideoCompressTask task = new VideoCompressTask(listener, VideoController.COMPRESS_QUALITY_LOW);
30 | task.execute(srcPath, destPath);
31 | return task;
32 | }
33 |
34 | private static class VideoCompressTask extends AsyncTask {
35 | private CompressListener mListener;
36 | private int mQuality;
37 |
38 | public VideoCompressTask(CompressListener listener, int quality) {
39 | mListener = listener;
40 | mQuality = quality;
41 | }
42 |
43 | @Override
44 | protected void onPreExecute() {
45 | super.onPreExecute();
46 | if (mListener != null) {
47 | mListener.onStart();
48 | }
49 | }
50 |
51 | @Override
52 | protected Boolean doInBackground(String... paths) {
53 | return VideoController.getInstance().convertVideo(paths[0], paths[1], mQuality, new VideoController.CompressProgressListener() {
54 | @Override
55 | public void onProgress(float percent) {
56 | publishProgress(percent);
57 | }
58 | });
59 | }
60 |
61 | @Override
62 | protected void onProgressUpdate(Float... percent) {
63 | super.onProgressUpdate(percent);
64 | if (mListener != null) {
65 | mListener.onProgress(percent[0]);
66 | }
67 | }
68 |
69 | @Override
70 | protected void onPostExecute(Boolean result) {
71 | super.onPostExecute(result);
72 | if (mListener != null) {
73 | if (result) {
74 | mListener.onSuccess();
75 | } else {
76 | mListener.onFail();
77 | }
78 | }
79 | }
80 | }
81 |
82 | public interface CompressListener {
83 | void onStart();
84 | void onSuccess();
85 | void onFail();
86 | void onProgress(float percent);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/videocompression/Config.java:
--------------------------------------------------------------------------------
1 | package com.iceteck.silicompressorr.videocompression;
2 |
3 | /*
4 | * By Jorge E. Hernandez (@lalongooo) 2015
5 | * */
6 |
7 | /*
8 | * Static class to define general configuration values of the application
9 | * */
10 | public class Config {
11 |
12 | /**
13 | * Application root directory. All media files wi'll be stored here.
14 | */
15 | //public static final String VIDEO_COMPRESSOR_APPLICATION_DIR_NAME = "VideoCompressor";
16 |
17 | /**
18 | * Application folder for video files
19 | */
20 | //public static final String VIDEO_COMPRESSOR_COMPRESSED_VIDEOS_DIR = "/CompressedVideos/";
21 |
22 | /**
23 | * Application folder for video files
24 | */
25 | public static final String VIDEO_COMPRESSOR_TEMP_DIR = "/Temp/";
26 | }
27 |
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/videocompression/InputSurface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
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.iceteck.silicompressorr.videocompression;
18 |
19 | import android.annotation.TargetApi;
20 | import android.opengl.EGL14;
21 | import android.opengl.EGLConfig;
22 | import android.opengl.EGLContext;
23 | import android.opengl.EGLDisplay;
24 | import android.opengl.EGLExt;
25 | import android.opengl.EGLSurface;
26 | import android.os.Build;
27 | import android.view.Surface;
28 |
29 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
30 | public class InputSurface {
31 | private static final boolean VERBOSE = false;
32 | private static final int EGL_RECORDABLE_ANDROID = 0x3142;
33 | private static final int EGL_OPENGL_ES2_BIT = 4;
34 | private EGLDisplay mEGLDisplay;
35 | private EGLContext mEGLContext;
36 | private EGLSurface mEGLSurface;
37 | private Surface mSurface;
38 |
39 | public InputSurface(Surface surface) {
40 | if (surface == null) {
41 | throw new NullPointerException();
42 | }
43 | mSurface = surface;
44 | eglSetup();
45 | }
46 |
47 | private void eglSetup() {
48 | mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
49 | if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
50 | throw new RuntimeException("unable to get EGL14 display");
51 | }
52 | int[] version = new int[2];
53 | if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
54 | mEGLDisplay = null;
55 | throw new RuntimeException("unable to initialize EGL14");
56 | }
57 |
58 | int[] attribList = {
59 | EGL14.EGL_RED_SIZE, 8,
60 | EGL14.EGL_GREEN_SIZE, 8,
61 | EGL14.EGL_BLUE_SIZE, 8,
62 | EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
63 | EGL_RECORDABLE_ANDROID, 1,
64 | EGL14.EGL_NONE
65 | };
66 | EGLConfig[] configs = new EGLConfig[1];
67 | int[] numConfigs = new int[1];
68 | if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
69 | numConfigs, 0)) {
70 | throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
71 | }
72 |
73 | int[] attrib_list = {
74 | EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
75 | EGL14.EGL_NONE
76 | };
77 |
78 | mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0);
79 | checkEglError("eglCreateContext");
80 | if (mEGLContext == null) {
81 | throw new RuntimeException("null context");
82 | }
83 |
84 | int[] surfaceAttribs = {
85 | EGL14.EGL_NONE
86 | };
87 | mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
88 | surfaceAttribs, 0);
89 | checkEglError("eglCreateWindowSurface");
90 | if (mEGLSurface == null) {
91 | throw new RuntimeException("surface was null");
92 | }
93 | }
94 |
95 | public void release() {
96 | if (EGL14.eglGetCurrentContext().equals(mEGLContext)) {
97 | EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
98 | }
99 | EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
100 | EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
101 | mSurface.release();
102 | mEGLDisplay = null;
103 | mEGLContext = null;
104 | mEGLSurface = null;
105 | mSurface = null;
106 | }
107 |
108 | public void makeCurrent() {
109 | if (!EGL14.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext)) {
110 | throw new RuntimeException("eglMakeCurrent failed");
111 | }
112 | }
113 |
114 | public boolean swapBuffers() {
115 | return EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
116 | }
117 |
118 | public Surface getSurface() {
119 | return mSurface;
120 | }
121 |
122 | public void setPresentationTime(long nsecs) {
123 | EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
124 | }
125 |
126 | private void checkEglError(String msg) {
127 | boolean failed = false;
128 | int error;
129 | while ((error = EGL14.eglGetError()) != EGL14.EGL_SUCCESS) {
130 | failed = true;
131 | }
132 | if (failed) {
133 | throw new RuntimeException("EGL error encountered (see log)");
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/silicompressor/src/main/java/com/iceteck/silicompressorr/videocompression/MP4Builder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This is the source code of Telegram for Android v. 1.7.x.
3 | * It is licensed under GNU GPL v. 2 or later.
4 | * You should have received a copy of the license in this archive (see LICENSE).
5 | *
6 | * Copyright Nikolai Kudashov, 2013-2014.
7 | */
8 |
9 | package com.iceteck.silicompressorr.videocompression;
10 |
11 | import android.annotation.TargetApi;
12 | import android.media.MediaCodec;
13 | import android.media.MediaFormat;
14 |
15 | import com.coremedia.iso.BoxParser;
16 | import com.coremedia.iso.IsoFile;
17 | import com.coremedia.iso.IsoTypeWriter;
18 | import com.coremedia.iso.boxes.Box;
19 | import com.coremedia.iso.boxes.Container;
20 | import com.coremedia.iso.boxes.DataEntryUrlBox;
21 | import com.coremedia.iso.boxes.DataInformationBox;
22 | import com.coremedia.iso.boxes.DataReferenceBox;
23 | import com.coremedia.iso.boxes.FileTypeBox;
24 | import com.coremedia.iso.boxes.HandlerBox;
25 | import com.coremedia.iso.boxes.MediaBox;
26 | import com.coremedia.iso.boxes.MediaHeaderBox;
27 | import com.coremedia.iso.boxes.MediaInformationBox;
28 | import com.coremedia.iso.boxes.MovieBox;
29 | import com.coremedia.iso.boxes.MovieHeaderBox;
30 | import com.coremedia.iso.boxes.SampleSizeBox;
31 | import com.coremedia.iso.boxes.SampleTableBox;
32 | import com.coremedia.iso.boxes.SampleToChunkBox;
33 | import com.coremedia.iso.boxes.StaticChunkOffsetBox;
34 | import com.coremedia.iso.boxes.SyncSampleBox;
35 | import com.coremedia.iso.boxes.TimeToSampleBox;
36 | import com.coremedia.iso.boxes.TrackBox;
37 | import com.coremedia.iso.boxes.TrackHeaderBox;
38 | import com.googlecode.mp4parser.DataSource;
39 | import com.googlecode.mp4parser.util.Matrix;
40 |
41 | import java.io.FileOutputStream;
42 | import java.io.IOException;
43 | import java.nio.ByteBuffer;
44 | import java.nio.channels.FileChannel;
45 | import java.nio.channels.WritableByteChannel;
46 | import java.util.ArrayList;
47 | import java.util.Date;
48 | import java.util.HashMap;
49 | import java.util.LinkedList;
50 | import java.util.List;
51 |
52 | @TargetApi(16)
53 | public class MP4Builder {
54 |
55 | private InterleaveChunkMdat mdat = null;
56 | private Mp4Movie currentMp4Movie = null;
57 | private FileOutputStream fos = null;
58 | private FileChannel fc = null;
59 | private long dataOffset = 0;
60 | private long writedSinceLastMdat = 0;
61 | private boolean writeNewMdat = true;
62 | private HashMap