zoukankan      html  css  js  c++  java
  • 如何将微信上传AMR格式语音转化为MP3格式

    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;
            }
        }
    ---栖息之鹰(一个外表懒洋洋的内心有激情的程序员) 此博客为笔者原著,转载时请注明出处,谢谢!
  • 相关阅读:
    [题解] [JSOI2015] 圈地
    [题解] [JSOI2015] 最小表示
    [题解] [JSOI2015] 套娃
    [题解] [JSOI2015] 非诚勿扰
    [题解] [JSOI2015] 送礼物
    [题解] [JSOI2015] 送礼物
    [题解] [JSOI2015] 子集选取
    [题解] [JSOI2015] salesman
    AC自动机学习笔记
    [题解] [JSOI2014] 矩形并
  • 原文地址:https://www.cnblogs.com/roostinghawk/p/6723101.html
Copyright © 2011-2022 走看看