diff --git a/FFmpegAndroid/assets/armeabi-v7a/ffmpeg b/FFmpegAndroid/libs/armeabi-v7a/libffmpeg.so old mode 100644 new mode 100755 similarity index 100% rename from FFmpegAndroid/assets/armeabi-v7a/ffmpeg rename to FFmpegAndroid/libs/armeabi-v7a/libffmpeg.so diff --git a/FFmpegAndroid/libs/armeabi/libffmpeg.so b/FFmpegAndroid/libs/armeabi/libffmpeg.so new file mode 100755 index 0000000..036bf6f Binary files /dev/null and b/FFmpegAndroid/libs/armeabi/libffmpeg.so differ diff --git a/FFmpegAndroid/assets/x86/ffmpeg b/FFmpegAndroid/libs/x86/libffmpeg.so old mode 100644 new mode 100755 similarity index 100% rename from FFmpegAndroid/assets/x86/ffmpeg rename to FFmpegAndroid/libs/x86/libffmpeg.so diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CommonInstrumentationTestCase.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CommonInstrumentationTestCase.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CommonTestCase.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CommonTestCase.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CpuArchHelperTest.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CpuArchHelperTest.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CpuArchTest.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CpuArchTest.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/LogTest.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/LogTest.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/ShellCommandTest.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/ShellCommandTest.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/UtilTest.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/UtilTest.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/utils/AssertionHelper.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/utils/AssertionHelper.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/utils/StubInputStream.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/utils/StubInputStream.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/utils/StubOutputStream.java b/FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/utils/StubOutputStream.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/AndroidManifest.xml b/FFmpegAndroid/src/main/AndroidManifest.xml old mode 100644 new mode 100755 index 91fae4d..ba696e7 --- a/FFmpegAndroid/src/main/AndroidManifest.xml +++ b/FFmpegAndroid/src/main/AndroidManifest.xml @@ -1,5 +1,9 @@ - + - + diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CommandResult.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CommandResult.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CpuArch.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CpuArch.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CpuArchHelper.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CpuArchHelper.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ExecuteBinaryResponseHandler.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ExecuteBinaryResponseHandler.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpeg.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpeg.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegExecuteAsyncTask.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegExecuteAsyncTask.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegExecuteResponseHandler.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegExecuteResponseHandler.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegInterface.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegInterface.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadBinaryResponseHandler.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadBinaryResponseHandler.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadLibraryAsyncTask.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadLibraryAsyncTask.java old mode 100644 new mode 100755 index 6783d28..3a4d47b --- a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadLibraryAsyncTask.java +++ b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegLoadLibraryAsyncTask.java @@ -20,27 +20,9 @@ class FFmpegLoadLibraryAsyncTask extends AsyncTask { @Override protected Boolean doInBackground(Void... params) { File ffmpegFile = new File(FileUtils.getFFmpeg(context)); - if (ffmpegFile.exists() && isDeviceFFmpegVersionOld() && !ffmpegFile.delete()) { - return false; - } - if (!ffmpegFile.exists()) { - boolean isFileCopied = FileUtils.copyBinaryFromAssetsToData(context, - cpuArchNameFromAssets + File.separator + FileUtils.ffmpegFileName, - FileUtils.ffmpegFileName); - - // make file executable - if (isFileCopied) { - if(!ffmpegFile.canExecute()) { - Log.d("FFmpeg is not executable, trying to make it executable ..."); - if (ffmpegFile.setExecutable(true)) { - return true; - } - } else { - Log.d("FFmpeg is executable"); - return true; - } - } - } + + + return ffmpegFile.exists() && ffmpegFile.canExecute(); } @@ -57,7 +39,4 @@ protected void onPostExecute(Boolean isSuccess) { } } - private boolean isDeviceFFmpegVersionOld() { - return CpuArch.fromString(FileUtils.SHA1(FileUtils.getFFmpeg(context))).equals(CpuArch.NONE); - } } diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FileUtils.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FileUtils.java old mode 100644 new mode 100755 index d59cfa4..49504e6 --- a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FileUtils.java +++ b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FileUtils.java @@ -15,10 +15,11 @@ class FileUtils { - static final String ffmpegFileName = "ffmpeg"; + static final String ffmpegFileName = "libffmpeg.so"; private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; private static final int EOF = -1; + /* static boolean copyBinaryFromAssetsToData(Context context, String fileNameFromAssets, String outputFileName) { // create files directory under /data/data/package name @@ -45,14 +46,19 @@ static boolean copyBinaryFromAssetsToData(Context context, String fileNameFromAs } return false; } - - static File getFilesDirectory(Context context) { - // creates files directory under data/data/package name - return context.getFilesDir(); - } + */ static String getFFmpeg(Context context) { - return getFilesDirectory(context).getAbsolutePath() + File.separator + FileUtils.ffmpegFileName; + + String archFolder = ""; + + if (CpuArchHelper.getCpuArch() == CpuArch.x86){ + archFolder = "x86"; + } else if (CpuArchHelper.getCpuArch() == CpuArch.ARMv7){ + archFolder = "arm"; + } + + return context.getPackageResourcePath().replaceAll("/([^/]+)$", "/lib/") + archFolder + "/" + ffmpegFileName; } static String getFFmpeg(Context context, Map environmentVars) { diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/LoadBinaryResponseHandler.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/LoadBinaryResponseHandler.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/Log.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/Log.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ResponseHandler.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ResponseHandler.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ShellCommand.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ShellCommand.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/Util.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/Util.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/exceptions/FFmpegCommandAlreadyRunningException.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/exceptions/FFmpegCommandAlreadyRunningException.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/exceptions/FFmpegNotSupportedException.java b/FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/exceptions/FFmpegNotSupportedException.java old mode 100644 new mode 100755 diff --git a/FFmpegAndroid/src/main/res/values/strings.xml b/FFmpegAndroid/src/main/res/values/strings.xml old mode 100644 new mode 100755 diff --git a/build.gradle b/build.gradle index 939b683..a5c2d19 100644 --- a/build.gradle +++ b/build.gradle @@ -21,9 +21,9 @@ allprojects { } ext { - compileSdkVersion = 22 - buildToolsVersion = '22.0.1' - targetSdkVersion = 22 + compileSdkVersion = 26 + buildToolsVersion = '26.0.3' + targetSdkVersion = 26 minSdkVersion = 16 versionCode = 28 versionName = "0.3.2"