Android:无法使用ffmpeg Android合并两个音频文件(onFailure)

时间:2019-03-27 12:03:59

标签: android audio merge ffmpeg

我正在尝试使用FFMPEG库将两个wav音频文件合并为一个。

这是我用于合并两个音频文件的命令。

String s = "ffmpeg -i "+recordFile+" -i "+audioFromVideo+" -filter_complex amix=inputs=3:duration=first:dropout_transition=3 "+finalAudio;

下面是我的音频合并代码:

public void mergeMediaFiles(Context context,String[] cmd) {
            FFmpeg ffmpeg = FFmpeg.getInstance(context);
            try {
                try {
                    //Load the binary
                    ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

                        @Override
                        public void onStart() {
                        }

                        @Override
                        public void onFailure() {
                        }

                        @Override
                        public void onSuccess() {
                        }

                        @Override
                        public void onFinish() {
                        }
                    });
                } catch (FFmpegNotSupportedException e) {
                    // Handle if FFmpeg is not supported by device
                }
                // to execute "ffmpeg -version" command you just need to pass "-version"
                ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

                    @Override
                    public void onStart() {
                        Log.d("ttt", "onStart:merge ");
                    }

                    @Override
                    public void onProgress(String message) {
                        Log.d("ttt", "onProgress: merge");
                    }

                    @Override
                    public void onFailure(String message) {
                        Log.d("ttt", "onFailure: stock down");
                    }

                    @Override
                    public void onSuccess(String message) {
                        Log.d("ttt", "onSuccess: stock up");
                        File file= new File(finalAudio);
                        if (file.exists()) {
                            Log.d(TAG, "onPostExecute: mila bhai");
                            startPlaying(file.getPath());
                        }
                    }

                    @Override
                    public void onFinish() {
                        Log.d("ttt", "onFinish: merge ");
                    }
                });
            } catch (FFmpegCommandAlreadyRunningException e) {
                //
            }
        }

    }

当我尝试运行此代码时。它总是触发失败回调。 我只是想了解命令和合并代码有什么问题?

0 个答案:

没有答案