1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > jav音频格式转换 ffmpeg 微信录音amr转mp3

jav音频格式转换 ffmpeg 微信录音amr转mp3

时间:2020-07-03 13:55:53

相关推荐

jav音频格式转换 ffmpeg 微信录音amr转mp3

项目背景:

之前公司开发了一个微信公众号,要求把js-sdk录音文件在web网页也能播放。众所周知,html的<audio>标签ogg,mp3,wav,也有所说苹果safari支持m4a格式,在iphone上测试不支持,支持播放mp3格式的.所以amr格式要转换成MP3或wav,ogg。其中MP3最好,原因自己百度。所以自己上百度了一下,发现了下面的这个处理方式。感觉挺好的,牛逼的大神已经封装好了,直接上代码吧。

架包:链接:/s/1geLQaLt 密码:t7wj (这里不能上传,我也是笑了,链接过期的可以联系博主)

说明:这个架包之前不知道在哪里下载的,测试的时候widows上是没问题的,可是linux就不可以了,所以我记得我自己又改过一些地方,具体的忘了,有兴趣研究的可以上官网看看。如果懂java调用命令的,基本其他的都会了。这里就不具体研究。不过这个架包的原理实现就是调用的命令行。

ffmpeg官网: /

package ykxw.web.file.action.utils;import it.sauronsoftware.jave.AudioAttributes;import it.sauronsoftware.jave.Encoder;import it.sauronsoftware.jave.EncoderException;import it.sauronsoftware.jave.EncodingAttributes;import java.io.File;/*** Created by Administrator on /11/25.*/public class AmrToMp3Util {public static void toMp3(String sourcePath, String targetPath) {File source = new File(sourcePath);File target = new File(targetPath);AudioAttributes audio = new AudioAttributes();Encoder encoder = new Encoder();audio.setCodec("libmp3lame");EncodingAttributes encodingAttributes = new EncodingAttributes();encodingAttributes.setFormat("mp3");encodingAttributes.setAudioAttributes(audio);try {encoder.encode(source, target, encodingAttributes);} catch (EncoderException e) {}}}

ffmpeg(一个强大的流媒体文件处理软件,不单单做音频处理)

使用:官方有教程

下载:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。