Could not find ffmpeg

编程入门 行业动态 更新时间:2024-10-27 23:21:01

Could not <a href=https://www.elefans.com/category/jswz/34/1771123.html style=find ffmpeg"/>

Could not find ffmpeg

 看看aap的build里是否添了 

 implementation'com.github.adrielcafe:AndroidAudioConverter:0.0.8'

这个依赖,有的话把它注释掉,当然,我们是会用到这依赖的,不过这个依赖里的类很少,可以复制出来一份

 我把他贴出来了,需要的直接复制一个新类

public class AndroidAudioConverter {private static boolean loaded;private Context context;private File audioFile;private AudioFormat format;private IConvertCallback callback;private AndroidAudioConverter(Context context){this.context = context;}public static boolean isLoaded(){return loaded;}public static void load(Context context, final ILoadCallback callback){try {FFmpeg.getInstance(context).loadBinary(new FFmpegLoadBinaryResponseHandler() {@Overridepublic void onStart() {}@Overridepublic void onSuccess() {loaded = true;callback.onSuccess();}@Overridepublic void onFailure() {loaded = false;callback.onFailure(new Exception("Failed to loaded FFmpeg lib"));}@Overridepublic void onFinish() {}});} catch (Exception e){loaded = false;callback.onFailure(e);}}public static AndroidAudioConverter with(Context context) {return new AndroidAudioConverter(context);}public AndroidAudioConverter setFile(File originalFile) {this.audioFile = originalFile;return this;}public AndroidAudioConverter setFormat(AudioFormat format) {this.format = format;return this;}public AndroidAudioConverter setCallback(IConvertCallback callback) {this.callback = callback;return this;}public void convert() {if(!isLoaded()){callback.onFailure(new Exception("FFmpeg not loaded"));return;}if(audioFile == null || !audioFile.exists()){callback.onFailure(new IOException("File not exists"));return;}if(!audioFile.canRead()){callback.onFailure(new IOException("Can't read the file. Missing permission?"));return;}final File convertedFile = getConvertedFile(audioFile, format);final String[] cmd = new String[]{"-y", "-i", audioFile.getPath(), convertedFile.getPath()};try {FFmpeg.getInstance(context).execute(cmd, new FFmpegExecuteResponseHandler() {@Overridepublic void onStart() {}@Overridepublic void onProgress(String message) {}@Overridepublic void onSuccess(String message) {callback.onSuccess(convertedFile);}@Overridepublic void onFailure(String message) {callback.onFailure(new IOException(message));}@Overridepublic void onFinish() {}});} catch (Exception e){callback.onFailure(e);}}private static File getConvertedFile(File originalFile, AudioFormat format){String[] f = originalFile.getPath().split("\\.");String filePath = originalFile.getPath().replace(f[f.length - 1], format.getFormat());return new File(filePath);}
}
public enum AudioFormat {AAC,MP3,M4A,WMA,WAV,FLAC;public String getFormat() {return name().toLowerCase();}
}

以及接口

public interface IConvertCallback {void onSuccess(File convertedFile);void onFailure(Exception error);}
public interface ILoadCallback {void onSuccess();void onFailure(Exception error);}

不知道有没有漏的,不是第一时间过来写,有点忘了,可以去查那里依赖里面的内容,先把里面内容全搬出来,在注释掉那个依赖就可以了!!!!

第一次记录,最开始弄过一次,后面再弄一次就忘记了,搞了好半天才想起来!!,新手小白的我做个记录吧

更多推荐

Could not find ffmpeg

本文发布于:2024-03-08 02:01:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1719552.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:find   ffmpeg

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!