android – I am trying to merge audio in video using ffmpeg but it is crashing

I am getting this crash message when i click on third button to merge audio with video , first i am selecting the path of video and audio then i am merging the audio with video

 private fun mergeAudioAndVideo(videoFile: String, audioFile: String, outputFile: File) {
        val command = arrayOf(
            "ffmpeg",
            "-i", videoFile,
            "-i", audioFile,
            "-c:v", "copy",
            "-c:a", "aac",
            "-strict", "experimental",
            "-map", "0:v:0",
            "-map", "1:a:0",
            "-shortest",outputFile.absolutePath

        )
        val process = Runtime.getRuntime().exec(command)
        process.waitFor()


    }

The crash i am getting on LogCat is here

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.mergev, PID: 10113
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:622)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) 
     Caused by: java.io.IOException: Cannot run program "ffmpeg": error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
        at java.lang.Runtime.exec(Runtime.java:699)
        at java.lang.Runtime.exec(Runtime.java:564)
        at com.example.mergev.MainActivity.mergeAudioAndVideo(MainActivity.kt:65)
        at com.example.mergev.MainActivity.onCreate$lambda$2(MainActivity.kt:45)
        at com.example.mergev.MainActivity.$r8$lambda$9Q0VdcecuU1VoneEsUOL6ljoNPQ(Unknown Source:0)
        at com.example.mergev.MainActivity$$ExternalSyntheticLambda2.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:7570)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1202)
        at android.view.View.performClickInternal(View.java:7525)
        at android.view.View.access$3900(View.java:836)
        at android.view.View$PerformClick.run(View.java:28680)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:263)
        at android.app.ActivityThread.main(ActivityThread.java:8296)
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) 
     Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
        at java.lang.ProcessImpl.start(ProcessImpl.java:141)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        at java.lang.Runtime.exec(Runtime.java:699) 
        at java.lang.Runtime.exec(Runtime.java:564) 
        at com.example.mergev.MainActivity.mergeAudioAndVideo(MainActivity.kt:65) 
        at com.example.mergev.MainActivity.onCreate$lambda$2(MainActivity.kt:45) 
        at com.example.mergev.MainActivity.$r8$lambda$9Q0VdcecuU1VoneEsUOL6ljoNPQ(Unknown Source:0) 
        at com.example.mergev.MainActivity$$ExternalSyntheticLambda2.onClick(Unknown Source:2) 
        at android.view.View.performClick(View.java:7570) 
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1202) 
        at android.view.View.performClickInternal(View.java:7525) 
        at android.view.View.access$3900(View.java:836) 
        at android.view.View$PerformClick.run(View.java:28680) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:263) 
        at android.app.ActivityThread.main(ActivityThread.java:8296) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) 
I/Process: Sending signal. PID: 10113 SIG: 9

I have a video and a audio and i want to merge the audio and video using ffmpeg

I am getting this crash message when i click on third button to merge audio with video , first i am selecting the path of video and audio then i am merging the audio with video

Read more here: Source link