1

我想将我的 3gp 音频转换为 .wav 格式。我用ffmpeg来转换那个。因为它显示成功,没有出现任何错误。但我无法获得最终的输出文件。请帮我解决这个问题。

这是我的代码。

sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/OfficeRecordings/");
    if (!sampleDir.exists()) {
        sampleDir.mkdirs();
    }

    outputFile =  sampleDir+"/"+"sample_record.3gp";

    finalFile =  sampleDir+"/"+"final_record.wav"; 

    final String[] cmd = new String[]{"-y", "-i", outputFile, finalFile};


    execFFmpegBinary(cmd);


 private void execFFmpegBinary(final String[] command) {

        FFmpeg ffmpeg = FFmpeg.getInstance(this);
        try {
            FFmpeg.getInstance(MainActivity.this).loadBinary(new FFmpegLoadBinaryResponseHandler() {
                @Override
                public void onStart() {
                    Log.e("start",".......");

                }

                @Override
                public void onSuccess() {

                    Log.e("success",".......");
                }

                @Override
                public void onFailure() {
                    Log.e("fail",".......");

                }

                @Override
                public void onFinish() {
                    Log.e("finish",".......");

                }
            });
        } catch (FFmpegNotSupportedException e) {
            e.printStackTrace();
        }
4

1 回答 1

2

在尝试了很多方法之后。我得到了它工作正常的解决方案。

最终 FFmpeg ffmpeg = FFmpeg.getInstance(this);

    try {
        ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

            @Override
            public void onStart() {
                Log.d("audio", "starting to load binary");
            }

            @Override
            public void onFailure() {
                Log.d("audio", "failed to load binary");
            }

            @Override
            public void onSuccess() {
                Log.d("audio", "loaded binary");
                try {

                    ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

                        @Override
                        public void onStart() {
                            Log.d("audio", " starting to get audio " + "");

                        }

                        @Override
                        public void onProgress(String message) {
                            Log.d("audio", " progress getting audio from ");

                        }

                        @Override
                        public void onFailure(String message) {
                            Log.d("audio", " failed to get audio ");

                        }

                        @Override
                        public void onSuccess(String message) {
                            Log.d("audio", " success getting audio from video");
                        }

                        @Override
                        public void onFinish() {



                        }
                    });
                } catch (FFmpegCommandAlreadyRunningException e) {

                    e.printStackTrace();
                }
            }

            @Override
            public void onFinish() {
            }
        });
    } catch (FFmpegNotSupportedException e) {
        // Handle if FFmpeg is not supported by device
    } 
于 2020-03-11T11:08:50.290 回答