Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
Merge pull request #36 from arthenica/development
Browse files Browse the repository at this point in the history
merge v5.1 test applications
  • Loading branch information
tanersener authored Oct 2, 2022
2 parents 828e1c1 + 18407d4 commit 7ff3e2a
Show file tree
Hide file tree
Showing 168 changed files with 5,305 additions and 503 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
.vscode
.history
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Test applications for [FFmpegKit](https://github.com/arthenica/ffmpeg-kit).
- `Android` under the [android](https://github.com/arthenica/ffmpeg-kit-test/tree/main/android) folder
- `Flutter` under the [flutter](https://github.com/arthenica/ffmpeg-kit-test/tree/main/flutter) folder
- `iOS` under the [ios](https://github.com/arthenica/ffmpeg-kit-test/tree/main/ios) folder
- `Linux` under the [linux](https://github.com/arthenica/ffmpeg-kit-test/tree/main/linux) folder
- `macOS` under the [macos](https://github.com/arthenica/ffmpeg-kit-test/tree/main/macos) folder
- `React Native` under the [react-native](https://github.com/arthenica/ffmpeg-kit-test/tree/main/react-native) folder
- `tvOS` under the [tvos](https://github.com/arthenica/ffmpeg-kit-test/tree/main/tvos) folder
Expand All @@ -19,8 +20,17 @@ demonstrate how SAF uris can be used with `FFmpegKit`.

Test applications are tagged with `ffmpeg-kit` release they depend on.

| Platform | FFmpegKit Version | Tag |
| :----: |:-----------------:|:----------------------------------------------------------------------------------:|
| Platform | FFmpegKit Version | Tag |
| :----: |:-----------------:|:---------------------------------------------------------------------------------:|
| Android | 5.1 | [5.1](https://github.com/arthenica/ffmpeg-kit-test/tree/android.v5.1) |
| Android | 5.1.LTS | [5.1.LTS](https://github.com/arthenica/ffmpeg-kit-test/tree/android.v5.1.lts) |
| iOS | 5.1 | [5.1](https://github.com/arthenica/ffmpeg-kit-test/tree/ios.v5.1) |
| iOS | 5.1.LTS | [5.1.LTS](https://github.com/arthenica/ffmpeg-kit-test/tree/ios.v5.1.lts) |
| macOS | 5.1 | [5.1](https://github.com/arthenica/ffmpeg-kit-test/tree/macos.v5.1) |
| macOS | 5.1.LTS | [5.1.LTS](https://github.com/arthenica/ffmpeg-kit-test/tree/macos.v5.1.lts) |
| tvOS | 5.1 | [5.1](https://github.com/arthenica/ffmpeg-kit-test/tree/tvos.v5.1) |
| tvOS | 5.1.LTS | [5.1.LTS](https://github.com/arthenica/ffmpeg-kit-test/tree/tvos.v5.1.lts) |
| - | - | - |
| React Native | 4.5.2 | [4.5.2](https://github.com/arthenica/ffmpeg-kit-test/tree/react.native.v4.5.2) |
| Flutter | 4.5.1 | [4.5.1](https://github.com/arthenica/ffmpeg-kit-test/tree/flutter.v4.5.1) |
| Flutter | 4.5.1-LTS | [4.5.1-LTS](https://github.com/arthenica/ffmpeg-kit-test/tree/flutter.v4.5.1.lts) |
Expand Down
5 changes: 2 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.3.0'
}
}

allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
17 changes: 9 additions & 8 deletions android/test-app-local-dependency/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ android {
keyPassword 'android'
}
}
compileSdkVersion 30
namespace 'com.arthenica.ffmpegkit.test'
compileSdk 31
defaultConfig {
applicationId "com.arthenica.ffmpegkit.test"
minSdkVersion 24
targetSdkVersion 30
versionCode 240451
versionName "4.5.1"
minSdk 24
targetSdk 31
versionCode 240510
versionName "5.1"
}
buildTypes {
debug {
Expand Down Expand Up @@ -53,7 +54,7 @@ android.applicationVariants.all { variant ->
dependencies {
// implementation files('../../../ffmpeg-kit/prebuilt/bundle-android-aar-lts/ffmpeg-kit/ffmpeg-kit.aar')
implementation files('../../../ffmpeg-kit/prebuilt/bundle-android-aar/ffmpeg-kit/ffmpeg-kit.aar')
implementation 'com.arthenica:smart-exception-java:0.1.1'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.arthenica:smart-exception-java:0.2.1'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.arthenica.ffmpegkit.test">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -21,7 +20,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.arthenica.ffmpegkit.test.MainActivity">
<activity
android:name="com.arthenica.ffmpegkit.test.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void encodeAudio() {

clearOutput();

android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
android.util.Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void runFFmpeg() {

android.util.Log.d(MainActivity.TAG, "Testing FFmpeg COMMAND asynchronously.");

android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process started with arguments:\n'%s'", ffmpegCommand));
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process started with arguments: '%s'", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -147,9 +147,9 @@ public void runFFprobe() {

android.util.Log.d(MainActivity.TAG, "Testing FFprobe COMMAND asynchronously.");

android.util.Log.d(MainActivity.TAG, String.format("FFprobe process started with arguments:\n'%s'", ffprobeCommand));
android.util.Log.d(MainActivity.TAG, String.format("FFprobe process started with arguments: '%s'", ffprobeCommand));

FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(ffprobeCommand), new FFprobeSessionCompleteCallback() {
FFprobeSession session = FFprobeSession.create(FFmpegKitConfig.parseArguments(ffprobeCommand), new FFprobeSessionCompleteCallback() {

@Override
public void apply(final FFprobeSession session) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void encodeVideo(final int buttonNumber) {

final String ffmpegCommand = Video.generateEncodeVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath(), "mpeg4", "");

Log.d(TAG, String.format("FFmpeg process starting for button %d with arguments\n'%s'.", buttonNumber, ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process starting for button %d with arguments: '%s'.", buttonNumber, ffmpegCommand));

final FFmpegSession session = FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -218,6 +218,7 @@ public void apply(final FFmpegSession session) {
break;
default: {
sessionId3 = sessionId;
FFmpegKitConfig.setSessionHistorySize(3);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public class HttpsTabFragment extends Fragment {

public static final String HTTPS_TEST_FAIL_URL = "https://download2.blender.org/peach/trailer/trailer_1080p.ogg";

public static final String HTTPS_TEST_RANDOM_URL_1 = "https://file-examples-com.github.io/uploads/2018/04/file_example_MOV_640_800kB.mov";
public static final String HTTPS_TEST_RANDOM_URL_1 = "https://filesamples.com/samples/video/mov/sample_640x360.mov";

public static final String HTTPS_TEST_RANDOM_URL_2 = "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3";
public static final String HTTPS_TEST_RANDOM_URL_2 = "https://filesamples.com/samples/audio/mp3/sample3.mp3";

public static final String HTTPS_TEST_RANDOM_URL_3 = "https://file-examples-com.github.io/uploads/2020/03/file_example_WEBP_50kB.webp";
public static final String HTTPS_TEST_RANDOM_URL_3 = "https://filesamples.com/samples/image/webp/sample1.webp";

private static final Random testUrlRandom = new Random();
private static final Object outputLock = new Object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void onCreate(final Bundle savedInstanceState) {
}

try {
registerAppFont();
registerApplicationFonts();
Log.d(TAG, "Application fonts registered.");
} catch (final IOException e) {
Log.e(TAG, String.format("Font registration failed.%s.", Exceptions.getStackTraceString(e)));
Expand Down Expand Up @@ -166,7 +166,7 @@ public static void addUIAction(final Runnable runnable) {
handler.post(runnable);
}

protected void registerAppFont() throws IOException {
protected void registerApplicationFonts() throws IOException {
final File cacheDirectory = getCacheDir();
final File fontDirectory = new File(cacheDirectory, "fonts");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void apply(FFmpegSession session) {

String chromaprintCommand = String.format("-hide_banner -y -i %s -f chromaprint -fp_format 2 %s", audioSampleFile, getChromaprintOutputFile().getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", chromaprintCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", chromaprintCommand));

FFmpegKit.executeAsync(chromaprintCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -184,7 +184,7 @@ protected void testDav1d() {

final String ffmpegCommand = String.format("-hide_banner -y -i %s %s", DAV1D_TEST_DEFAULT_URL, getDav1dOutputFile().getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand All @@ -208,7 +208,7 @@ protected void testWebp() {

final String ffmpegCommand = String.format("-hide_banner -y -i %s %s", imageFile.getAbsolutePath(), outputFile.getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -242,7 +242,7 @@ protected void testZscale() {

final String ffmpegCommand = Video.generateZscaleVideoScript(videoFile.getAbsolutePath(), zscaledVideoFile.getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void createVideo() {

final String ffmpegCommand = Video.generateCreateVideoWithPipesScript(pipe1, pipe2, pipe3, videoFile.getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -246,20 +246,18 @@ protected void showProgressDialog() {
}

protected void updateProgressDialog() {
if (statistics == null) {
if (statistics == null || statistics.getTime() < 0) {
return;
}

int timeInMilliseconds = this.statistics.getTime();
if (timeInMilliseconds > 0) {
int totalVideoDuration = 9000;
int totalVideoDuration = 9000;

String completePercentage = new BigDecimal(timeInMilliseconds).multiply(new BigDecimal(100)).divide(new BigDecimal(totalVideoDuration), 0, BigDecimal.ROUND_HALF_UP).toString();
String completePercentage = new BigDecimal(timeInMilliseconds).multiply(new BigDecimal(100)).divide(new BigDecimal(totalVideoDuration), 0, BigDecimal.ROUND_HALF_UP).toString();

TextView textView = progressDialog.findViewById(R.id.progressDialogText);
if (textView != null) {
textView.setText(String.format("Creating video: %% %s.", completePercentage));
}
TextView textView = progressDialog.findViewById(R.id.progressDialogText);
if (textView != null) {
textView.setText(String.format("Creating video: %% %s.", completePercentage));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
package com.arthenica.ffmpegkit.test;

import android.content.Context;
import android.widget.Toast;

public class Popup {

public static void show(final Context context, final String message) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// DISABLED DUE TO THE java.io.IOException: Failed to load asset path ERROR ON API LEVEL 31
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void runFFprobe() {

Log.d(TAG, "Testing FFprobe COMMAND synchronously.");

Log.d(TAG, String.format("FFprobe process started with arguments\n'%s'", ffprobeCommand));
Log.d(TAG, String.format("FFprobe process started with arguments: '%s'", ffprobeCommand));

final FFprobeSession session = FFprobeKit.execute(ffprobeCommand);

Expand Down Expand Up @@ -178,7 +178,7 @@ private void encodeVideo() {

final String ffmpegCommand = Video.generateEncodeVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoPath, selectedCodec, getCustomOptions(selectedCodec));

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegSession session = FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -332,20 +332,18 @@ private void showProgressDialog() {
}

private void updateProgressDialog() {
if (statistics == null) {
if (statistics == null || statistics.getTime() < 0) {
return;
}

int timeInMilliseconds = this.statistics.getTime();
if (timeInMilliseconds > 0) {
int totalVideoDuration = 9000;
int totalVideoDuration = 9000;

String completePercentage = new BigDecimal(timeInMilliseconds).multiply(new BigDecimal(100)).divide(new BigDecimal(totalVideoDuration), 0, BigDecimal.ROUND_HALF_UP).toString();
String completePercentage = new BigDecimal(timeInMilliseconds).multiply(new BigDecimal(100)).divide(new BigDecimal(totalVideoDuration), 0, BigDecimal.ROUND_HALF_UP).toString();

TextView textView = progressDialog.findViewById(R.id.progressDialogText);
if (textView != null) {
textView.setText(String.format("Encoding video: %% %s.", completePercentage));
}
TextView textView = progressDialog.findViewById(R.id.progressDialogText);
if (textView != null) {
textView.setText(String.format("Encoding video: %% %s.", completePercentage));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void burnSubtitles() {

final String ffmpegCommand = Video.generateEncodeVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath(), "mpeg4", "");

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

state = State.CREATING;

Expand All @@ -177,7 +177,7 @@ public void run() {

showBurnProgressDialog();

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", burnSubtitlesCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", burnSubtitlesCommand));

state = State.BURNING;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public void apply(final com.arthenica.ffmpegkit.Log log) {
});
}

public void disableStatisticsCallback() {
FFmpegKitConfig.enableStatisticsCallback(null);
}

public void stabilizeVideo() {
final File image1File = new File(requireContext().getCacheDir(), "machupicchu.jpg");
final File image2File = new File(requireContext().getCacheDir(), "pyramid.jpg");
Expand Down Expand Up @@ -135,7 +139,7 @@ public void stabilizeVideo() {

final String ffmpegCommand = Video.generateShakingVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", ffmpegCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", ffmpegCommand));

FFmpegKit.executeAsync(ffmpegCommand, new FFmpegSessionCompleteCallback() {

Expand All @@ -157,7 +161,7 @@ public void run() {

showStabilizeProgressDialog();

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", analyzeVideoCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", analyzeVideoCommand));

FFmpegKit.executeAsync(analyzeVideoCommand, new FFmpegSessionCompleteCallback() {

Expand All @@ -168,7 +172,7 @@ public void apply(final FFmpegSession secondSession) {
if (ReturnCode.isSuccess(secondSession.getReturnCode())) {
final String stabilizeVideoCommand = String.format("-y -i %s -vf vidstabtransform=smoothing=30:input=%s -c:v mpeg4 %s", videoFile.getAbsolutePath(), shakeResultsFile.getAbsolutePath(), stabilizedVideoFile.getAbsolutePath());

Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'.", stabilizeVideoCommand));
Log.d(TAG, String.format("FFmpeg process started with arguments: '%s'.", stabilizeVideoCommand));

FFmpegKit.executeAsync(stabilizeVideoCommand, new FFmpegSessionCompleteCallback() {

Expand Down Expand Up @@ -280,6 +284,7 @@ public File getStabilizedVideoFile() {
public void setActive() {
Log.i(MainActivity.TAG, "VidStab Tab Activated");
enableLogCallback();
disableStatisticsCallback();
Popup.show(requireContext(), getString(R.string.vidstab_test_tooltip_text));
}

Expand Down
Loading

0 comments on commit 7ff3e2a

Please sign in to comment.