有没有办法将webm和m4a文件转换为mp3在android studio中。 因为更改文件扩展名使它看起来像mp3文件,但在更改扩展名后无法访问... webm和m4a文件只包含音频。
答案 0 :(得分:1)
您可以轻松地执行https://github.com/adrielcafe/AndroidAudioConverter。
您需要使用
将其导入项目repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.adrielcafe:AndroidAudioConverter:0.0.8'
}
并且根据github页面,您还需要编译com.github.hiteshsondhi88.libffmpeg dependencie。
答案 1 :(得分:1)
这是我用过的ffmpeg的功能.....我只是导入了ffmpeg库..
private void calculate(final String title , final String Type, final int id){
FFmpeg ffmpeg = FFmpeg.getInstance(getApplicationContext());
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(new String[]{"-i",Environment.getExternalStoragePublicDirectory(DIRECTORY_MUSIC)+"/"+title+"."+Type, Environment.getExternalStoragePublicDirectory(DIRECTORY_MUSIC)+"/"+title+".mp3"}, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {}
@Override
public void onProgress(String message) {
Log.d("ffmpegevent", "onProgress: "+message);
}
@Override
public void onFailure(String message) {
Log.d("ffmpegevent", "onProgress: "+message);
Log.d("ffmpegevent", "onFailure: ");
}
@Override
public void onSuccess(String message) {
Log.d("ffmpegevent", "onSuccess: ");
}
@Override
public void onFinish() {
Log.d("ffmpegevent", "onProgress: Finished");
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
}
}