簡體   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