diff --git a/android/app/src/main/cpp/mobileffmpeg.c b/android/app/src/main/cpp/mobileffmpeg.c index 36a33caf0..5ab2f3a25 100644 --- a/android/app/src/main/cpp/mobileffmpeg.c +++ b/android/app/src/main/cpp/mobileffmpeg.c @@ -848,14 +848,16 @@ JNIEXPORT int JNICALL Java_com_arthenica_mobileffmpeg_Config_setNativeEnvironmen * @return output of the last executed command */ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeLastCommandOutput(JNIEnv *env, jclass object) { - int size = strlen(lastCommandOutput); + if (lastCommandOutput != NULL) { + int size = strlen(lastCommandOutput); - if (size > 0) { - jbyteArray byteArray = (*env)->NewByteArray(env, size); - (*env)->SetByteArrayRegion(env, byteArray, 0, size, lastCommandOutput); - jstring charsetName = (*env)->NewStringUTF(env, "UTF-8"); - return (jstring) (*env)->NewObject(env, stringClass, stringConstructor, byteArray, charsetName); - } else { - return (*env)->NewStringUTF(env, ""); + if (size > 0) { + jbyteArray byteArray = (*env)->NewByteArray(env, size); + (*env)->SetByteArrayRegion(env, byteArray, 0, size, lastCommandOutput); + jstring charsetName = (*env)->NewStringUTF(env, "UTF-8"); + return (jstring) (*env)->NewObject(env, stringClass, stringConstructor, byteArray, charsetName); + } } + + return (*env)->NewStringUTF(env, ""); } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/CommandTabFragment.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/CommandTabFragment.java index ebe7bc7ec..15a516577 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/CommandTabFragment.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/CommandTabFragment.java @@ -78,6 +78,8 @@ public void onClick(View v) { outputText = getView().findViewById(R.id.outputText); outputText.setMovementMethod(new ScrollingMovementMethod()); } + + android.util.Log.d(MainActivity.TAG, "Last command output was: " + FFmpeg.getLastCommandOutput()); } @Override