码迷,mamicode.com
首页 > 微信 > 详细

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

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

标签:comm   current   list   build   sla   UI   style   nal   erro   

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格式

标签:comm   current   list   build   sla   UI   style   nal   erro   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!