首页 > 微信 > 详细

如何将微信上传AMR格式语音转化为MP3格式

时间:2017-04-17 15:57:37      阅读:327      评论:0      收藏:0      [点我收藏+]

1. 服务器安装ffmpeg

2. 执行命令 ffmpeg -i {amr_file_path} -f mp3 -acodec libmp3lame -y {mp3_file_path}

    public static boolean changeAmr2Mp3(final String ffmpegPath, final String amrFilePath, final String mp3FilePath) {

        if (!Mp3TranslateUtils.checkfile(amrFilePath)) {
            Mp3TranslateUtils.LOGGER.error(amrFilePath + " is not file");
            return false;
        }

        final List<String> command = new ArrayList<String>();
        command.add(ffmpegPath);
        command.add("-i");
        command.add(amrFilePath);
        command.add("-f");
        command.add("mp3");
        command.add("-acodec");
        command.add("libmp3lame");
        command.add("-y");
        command.add(mp3FilePath);
        try {
            final ProcessBuilder builder = new ProcessBuilder();
            builder.redirectErrorStream(true);
            builder.command(commend);
            final Process process = builder.start();
            try {
                process.waitFor();
            } catch (final InterruptedException e) {
                e.printStackTrace();
                Thread.currentThread().interrupt();
            }
            process.getErrorStream().close();
            return true;
        } catch (final Exception e) {
            e.printStackTrace();
            return false;
        }
    }

 

如何将微信上传AMR格式语音转化为MP3格式

原文:http://www.cnblogs.com/roostinghawk/p/6723101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!