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

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

时间:2023-05-14 09:19:10

相关推荐

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

项目背景:

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

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

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

ffmpeg官网: /

packageykxw.web.file.action.utils;importit.sauronsoftware.jave.AudioAttributes;importit.sauronsoftware.jave.Encoder;importit.sauronsoftware.jave.EncoderException;importit.sauronsoftware.jave.EncodingAttributes;importjava.io.File;/*** Created by Administrator on /11/25.*/

public classAmrToMp3Util {public static voidtoMp3(String sourcePath, String targetPath) {

File source= newFile(sourcePath);

File target= newFile(targetPath);

AudioAttributes audio= newAudioAttributes();

Encoder encoder= newEncoder();

audio.setCodec("libmp3lame");

EncodingAttributes encodingAttributes= newEncodingAttributes();

encodingAttributes.setFormat("mp3");

encodingAttributes.setAudioAttributes(audio);try{

encoder.encode(source, target, encodingAttributes);

}catch(EncoderException e) {

}

}

}

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

使用:官方有教程

下载:

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