arthenica / ffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.
https://arthenica.github.io/ffmpeg-kit
GNU Lesser General Public License v3.0
4.35k stars 581 forks source link

App crashes on start only for Android #340

Closed patelnirav48 closed 2 years ago

patelnirav48 commented 2 years ago

Description App crashes on start only for Android

Logs E/AndroidRuntime(14869): FATAL EXCEPTION: main E/AndroidRuntime(14869): Process: com.xyz.sssss, PID: 14869 E/AndroidRuntime(14869): java.lang.Error: FFmpegKit failed to start on brand: google, model: sdk_gphone_x86, device: generic_x86_arm, api level: 29, abis: x86 armeabi-v7a armeabi, 32bit abis: x86 armeabi-v7a armeabi, 64bit abis: . E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.NativeLoader.loadLibrary(NativeLoader.java:50) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.NativeLoader.loadFFmpegKit(NativeLoader.java:189) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.FFmpegKitConfig.(FFmpegKitConfig.java:145) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.FFmpegKitConfig.enableFFmpegSessionCompleteCallback(FFmpegKitConfig.java:864) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin.registerGlobalCallbacks(FFmpegKitFlutterPlugin.java:168) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin.init(FFmpegKitFlutterPlugin.java:652) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin.onAttachedToActivity(FFmpegKitFlutterPlugin.java:198) E/AndroidRuntime(14869): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add(FlutterEngineConnectionRegistry.java:153) E/AndroidRuntime(14869): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:36) E/AndroidRuntime(14869): at com.dddd.ddddd.MainActivity.configureFlutterEngine(MainActivity.kt:10) E/AndroidRuntime(14869): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:187) E/AndroidRuntime(14869): at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:430) E/AndroidRuntime(14869): at android.app.Activity.performCreate(Activity.java:7989) E/AndroidRuntime(14869): at android.app.Activity.performCreate(Activity.java:7978) E/AndroidRuntime(14869): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) E/AndroidRuntime(14869): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3315) E/AndroidRuntime(14869): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484) E/AndroidRuntime(14869): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) E/AndroidRuntime(14869): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime(14869): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime(14869): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044) E/AndroidRuntime(14869): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(14869): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime(14869): at android.app.ActivityThread.main(ActivityThread.java:7476) E/AndroidRuntime(14869): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(14869): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) E/AndroidRuntime(14869): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:939) E/AndroidRuntime(14869): Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_log_default_callback" referenced by "/data/app/~~wsAHO3BWyrWmntUZrPVlRQ==/com.dddd.ddd-FZzxp2Q-nCTdSPVZlyj9VQ==/base.apk!/lib/x86/libffmpegkit.so"... E/AndroidRuntime(14869): at java.lang.Runtime.loadLibrary0(Runtime.java:1087) E/AndroidRuntime(14869): at java.lang.Runtime.loadLibrary0(Runtime.java:1008) E/AndroidRuntime(14869): at java.lang.System.loadLibrary(System.java:1661) E/AndroidRuntime(14869): at com.arthenica.ffmpegkit.NativeLoader.loadLibrary(NativeLoader.java:48) E/AndroidRuntime(14869): ... 26 more

courtneypresto commented 2 years ago

I'm having this exact same issue too

marcobraghim commented 2 years ago

Same issue here

3DJakob commented 2 years ago

Have this issue too. I have tried the LTS version as well same issue. Using: "ffmpeg-kit-react-native": "^4.5.1" "react-native": "0.67.3"

tanersener commented 2 years ago

I don't see instructions to reproduce this issue. Try to provide them if you need help about this.

tanatos91 commented 2 years ago

Same problem

DotProduct commented 2 years ago

I am receiving an UnsatisfiedLinkError, same as the above. Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_log_default_callback" referenced by "/data/app/~~i-6C8EpEmC0MKxRZf6LYIg==/com.sample.app-4UO3PuGNRiDSnMcZILXt2g==/base.apk!/lib/arm64-v8a/libffmpegkit.so"... I am using the latest version.

tanersener commented 2 years ago

As I said above, I don't see instructions to reproduce this issue. Try to provide them if you need help about this.

DotProduct commented 2 years ago

My apologies. I'm sure it is annoying dealing with people's "It doesn't work" complaints. :) Here is what I did. (Compiling to run on Android) I cloned the latest from "main". I ensured all libraries from your README were present on my development computer. I ran the following build script: ./android.sh --enable-gpl --enable-x264 --disable-arm-v7a-neon

No issues with running the build. I added your project as a dependency to my project. I ran set up executeAsynch according to your examples Here is the command line that I tried executing.

-r 60 -f image2 -s 640x512 -start_number 0 -i <folderPath>/frame_%d.jpg -vcodec libx264 -crf 25 -vframes ${proj.current_frame} -pix_fmt yuv420p <folderPath>/test.mp4

After trying to execute the above, I get the UnsatisfiedLink error, listed above.

Your scripts ran with no issues at all, so I don't have very much that I can supply you. To give you some context, I am trying to convert a folder of images into an "MP4" file.

tanersener commented 2 years ago

@DotProduct Thanks. Can you also share the architecture/ABI that receives this error? And your other gradle dependencies?

DotProduct commented 2 years ago

The device I was receiving the error on runs arm64-v8a -> Pixel 5a I am running OpenCV via JNI as well. Here is the build.gradle:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.rorschachinteractive.videoze"
        minSdk 26
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        externalNativeBuild {
            cmake {
                arguments '-DANDROID_STL=c++_shared', '-DANROID_TOOLCHAIN=g++', '-D OPENCV_DISABLE_FILESYSTEM_SUPPORT=ON'
            }
        }
        ndk {
            stl = "gnustl_shared"
            abiFilters 'arm64-v8a', 'armeabi-v7a'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
    buildFeatures {
        viewBinding true
    }

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"

        }
    }
    ndkVersion '21.0.6113669'
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
    implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'

    //KOIN
    implementation 'io.insert-koin:koin-android:3.0.1'

    //CAMERAX
    implementation 'androidx.camera:camera-core:1.0.2'
    implementation 'androidx.camera:camera-camera2:1.0.2'
    implementation 'androidx.camera:camera-lifecycle:1.0.2'
    implementation 'androidx.camera:camera-view:1.1.0-beta03'
    implementation 'androidx.camera:camera-extensions:1.1.0-beta03'

    //COROUTINES
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
    implementation project(path: ':ffmpeg-kit-android-lib')
    implementation project(path: ':ffmpeg-kit-android-lib')

    //TESTS
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
tanersener commented 2 years ago

I am running OpenCV via JNI as well.

How is OpenCV integrated into your app? I don't see an OpenCV dependency.

DotProduct commented 2 years ago

I use it with C++ only with JNI. I compiled it from source. It is in my CMAKE file. Not very much information for you to see but here it is just in case.....

cmake_minimum_required(VERSION 3.4.1)

include_directories(sdk)

add_library(
        opencv_java4
        STATIC
        IMPORTED
)

set_target_properties(
        opencv_java4
        PROPERTIES
        IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../../../libs/${ANDROID_ABI}/libopencv_java4.so
)

add_library(
        videoze-lib
        SHARED
        videoze-lib.cpp
)

find_library(
        log-lib
        log
)

target_link_libraries(
        videoze-lib
        -ljnigraphics
        opencv_java4
        ${log-lib}
)
tanersener commented 2 years ago

Yeah, the cmake file doesn't tell much. I don't see how I can package my test app the same way your app does.

The issue is, av_log_default_callback is a function defined in libavutil.so. And libavutil.so is one of the libraries that comes with ffmpeg. So, when you get cannot locate symbol "av_log_default_callback" error this means that either libavutil.so is not there or something is preventing from loading it.

Hard to say what it is if we cannot reproduce it. My suggestion is to check whether libavutil.so is packaged correctly or not. And whether your app depends on a dependency other than ffmpeg-kit that comes with libavutil.so.

DotProduct commented 2 years ago

Ok. I understand. If I figure it out, I'll let you know what I did to solve it. Thank you for looking into it. Cheers

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 7 days with no activity.

yangjieK commented 2 years ago

arguments '-DANDROID_STL=c++_shared', '-DANR

I got same problem, Did you kill it?

Quietly-20201113 commented 2 years ago

我也有同样的问题,无法处理