这里须要用到一个jar包:jave-1.0.1.jar,下载地址的话自己百度吧.

废话不多说直接贴代码:

import it.sauronsoftware.jave.AudioAttributes;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.EncodingAttributes; import java.io.File; public class Test {
    
    /**
     * 运行转化过程
     *
     * @param source
     *            源文件
     * @param desFileName
     *            目标文件名称
     * @return 转化后的文件
     */
    public static File execute(File source, String desFileName)
            throws Exception {
        File target = new File(desFileName);
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec("libmp3lame");
        audio.setBitRate(new Integer(36000)); //音频比率 MP3默认是1280000
        audio.setChannels(new Integer(2));
        audio.setSamplingRate(new Integer(44100));
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("mp3");
        attrs.setAudioAttributes(audio);
        Encoder encoder = new Encoder();
        encoder.encode(source, target, attrs);
        return target;
    }
    
   public static void main(String[] args) throws Exception {
           File file = new File("c://1111.wav");
           execute(file,  "c://111.mp3");
   }
}

java,wavToMP3格式转换的更多相关文章

  1. Java日期格式转换

    Java时间格式转换大全 import java.text.*;import java.util.Calendar;public class VeDate {/**   * 获取现在时间   *    ...

  2. Java时间格式转换工具类

    把当前时间修改成指定时间 //把当前时间修改成指定时间 public String dateUtil(Integer seconds, String dateFormatPattern){ Date ...

  3. java时间格式转换任意格式

    例如:20180918/120023转换成2018-09-18 12:00:23 //时间格式转换 public String getNomalTime(String oldTime){ String ...

  4. JAVA时间格式转换大全

    import java.text.*; import java.util.Calendar; public class VeDate { /** * 获取现在时间 * * @return 返回时间类型 ...

  5. java视频格式转换代码

    http://blog.163.com/zzf_fly/blog/static/20958915820127217443816/ package com.gkzx.online.action; imp ...

  6. java时间格式转换

    package org.shineway.com; import java.text.ParseException; import java.text.SimpleDateFormat; import ...

  7. java日期格式转换工具类

    原文地址:http://blog.csdn.net/zhiweianran/article/details/7991531 package com.ace.backoffice.utils; impo ...

  8. java视频格式转换

    项目中需要对各种视频格式转码为mp4格式,试了好多办法,最后使用ffmpeg 工具完美转码,ffmpeg能解析的格式:(asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv等) 链接 ...

  9. Java日期格式转换不用发愁

    前言 Java 中日期.时间相关的类相当的多,并且分不同的版本提供了不同的实现,包括 Date . Calendar . LocalDateTime . ZoneDateTime . OffsetDa ...

随机推荐

  1. 解决IE不支持Data.parse()的问题

    Date.parse()函数的返回值为Number类型,返回该字符串所表示的日期与 1970 年 1 月 1 日午夜之间相差的毫秒数. var nowtime = "2017-02-08&q ...

  2. POJ 1160 DP

    题目: poj 1160 题意: 给你n个村庄和它的坐标,现在要在其中一些村庄建m个邮局,想要村庄到最近的邮局距离之和最近. 分析: 这道题.很经典的dp dp[i][j]表示建第i个邮局,覆盖到第j ...

  3. R - Games

    Problem description Manao works on a sports TV. He's spent much time watching the football games of ...

  4. C - Anton and Danik

    Problem description Anton likes to play chess, and so does his friend Danik. Once they have played n ...

  5. B - String Task

    Problem description Petya started to attend programming lessons. On the first lesson his task was to ...

  6. C#三种创建对象方法所需时间比较。。。。。

    C#创建对象的三种方法  new().Activator.Assembly,接下来通过代码直接来看看运行的速度.... 首先,先看看三种创建对象实例的方法: //new(); public stati ...

  7. 可变长度参数列表(Stering...aaa)

  8. Ajax 传递json字符串到客户端时报 Internal server error

    架构:struts2+JQuery 需求:就是前台请求后台,后台查询数据库,将数据转换成json格式,使用struts2框架赋值给action内的变量jsonStr,前台通过 response.jso ...

  9. andorid 查看OpenCv Mat的Debug信息

    在进行Android调试时,不能再Console显示Debug信息,只能在LogCat上显示,显示信息如下图: 代码段: public void printMat2Txt(Mat ElemM, Str ...

  10. 为什么使用dispatch_sync

    1.充分利用多线程的性能: 2.将分散在多线程中的核心操作归并到一个queue执行(通常为一个串行队列). 3.便于在任务线程中进行后继操作. 术语: 任务线程: 同步模块.