Working on a project where I need to use FFmpeg library in Kotlin to work on some audio files. However I’m unable to initialize the ffmpeg library itself.
this is the error I’m getting
Could not find an ffmpeg binary for your Android system. Did you forget calling: 'new AndroidFFMPEGLocator(this);' ? 2024-07-22 18:48:33.910 11800-11800 PipeDecoder com.example.sangeet E Tried to unpack a statically compiled ffmpeg binary for your architecture to: /data/user/0/com.example.sangeet/cache/ffmpeg 2024-07-22 18:48:33.923 11800-11800 AndroidRuntime com.example.sangeet E FATAL EXCEPTION: main (Ask Gemini) Process: com.example.sangeet, PID: 11800 java.lang.Error: Decoding via a pipe will not work: Could not find an ffmpeg binary for your system
@HiltAndroidApp
class Sangeet: Application(){
override fun onCreate() {
super.onCreate()
provideFirebaseApp(this)
FFmpegKitConfig.setLogLevel(Level.AV_LOG_INFO)
FFmpegKitConfig.enableLogCallback { Log.d("ffmpeg", it.message) }
initializeFFmpegKit()
}
private fun initializeFFmpegKit() {
// This method should be sufficient to ensure FFmpegKit is ready to use
val ffmpegSession = FFmpegKit.execute("ffmpeg -version")
if (ReturnCode.isSuccess(ffmpegSession.returnCode)) {
Log.d("FFmpeg", "FFmpeg is ready to use.")
} else {
Log.e("FFmpeg", "Failed to initialize FFmpeg: ${ffmpegSession.failStackTrace}")
initializeFFmpegBinary()
}
}
private fun initializeFFmpegBinary() {
val ffmpegBinaryPath = filesDir.absolutePath + "/ffmpeg"
val binaryFile = File(ffmpegBinaryPath)
if (!binaryFile.exists()) {
Log.e("FFmpeg", "FFmpeg binary not found at $ffmpegBinaryPath")
// Copy or download the FFmpeg binary to this path
} else {
Log.d("FFmpeg", "FFmpeg binary found at $ffmpegBinaryPath")
}
}
}