繁体   English   中英

如何在Android的ffmpeg库中使用SoxController类? 任何例子

[英]How to use SoxController Class In ffmpeg library In android ? Any Example

在使用SoxController类时遇到问题。 任何人都可以给我SoxController类中trimaudio函数的示例吗?

让我们尝试一下,我认为它非常适合您,因为我已经测试过了。 它运作良好

/**
 * Trim File Wave
 */
public class TrimFileWave extends AsyncTask<String, Void, Void> {
    private ProgressDialogUtil progressDialogUtil;
    private Context            context;

    public TrimFileWave(Context context) {
        this.context = context;
        progressDialogUtil = new ProgressDialogUtil(context, R.string.progressing);
    }

    @Override
    protected void onPreExecute() {
        progressDialogUtil.show();
    }

    @Override
    protected Void doInBackground(String... params) {
        startTrimFile();
        return null;
    }

    @Override
    protected void onPostExecute(Void unused) {
        progressDialogUtil.dismiss();
    }

    private void startTrimFile() {
        File fileAppRoot = new File(context.getApplicationInfo().dataDir);
        try {
            SoxController sxCon = new SoxController(context, fileAppRoot, new ShellUtils.ShellCallback() {
                @Override
                public void shellOut(String shellLine) {
                    DebugUtil.log(new Exception(), shellLine);
                }

                @Override
                public void processComplete(int exitValue) {
                    DebugUtil.log(new Exception(), exitValue);
                }
            });
            double length = sxCon.getLength(MyApplication.FILE_NAME_RECORDED_WAVE);
            DebugUtil.log(new Exception(), "[length]" + length);
            // sxCon.trimAudio(MyApplication.FILE_MERGE_WAVE, 0, length);
            // Type {"q", "h", "t", "l", "p"}
            sxCon.fadeAudio(MyApplication.FILE_MERGE_WAVE, "t", 0, length, 1);
        }
        catch (Exception e) {
            DebugUtil.logInfo(new Exception(), e.toString());
        }
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM