Library : implementation 'com.arthenica:mobile-ffmpeg-full:4.2.2.LTS'
List<String> cmdList = new ArrayList<>();
cmdList.clear();
cmdList.add("-y");
cmdList.add("-i");
cmdList.add(orignalAudio);
cmdList.add("-stream_loop");
cmdList.add("-1");
cmdList.add("-i");
cmdList.add(backgroundAudio);
cmdList.add("-filter_complex");
cmdList.add("[0]volume=1:precision=fixed[a];" + "[1]volume=0.1:precision=fixed[b];" +
"[a][b]amix=inputs=2:duration=shortest");
// Note : you can set volume of both audio by change value of volume parameter. volume value is 0.0 to 1.
cmdList.add("-ac");
cmdList.add("2");
cmdList.add("-c:a");
cmdList.add("libmp3lame");
cmdList.add("-q:a");
cmdList.add("4");
cmdList.add(outputPath);
int returnCode = com.arthenica.mobileffmpeg.FFmpeg.execute(cmdList.toArray(new String[cmdList.size()]));
if (returnCode == RETURN_CODE_SUCCESS) {
// Completed with success
} else if (returnCode == RETURN_CODE_CANCEL) {
} else {
}
Comments
Post a Comment