Java,wavtomp3 format Conversion

Source: Internet
Author: User

Here need to use a jar package: Jave-1.0.1.jar, the words own Baidu Bar.


No more nonsense. Direct Sticker Code:


Import It.sauronsoftware.jave.audioattributes;import It.sauronsoftware.jave.encoder;import It.sauronsoftware.jave.encodingattributes;import Java.io.file;public class Test {        /**     * Run conversion process      *      * @param source      *            Source Files       * @param desfilename     *             Target file name      * @return converted files      */    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)); Audio ratio MP3 default is 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,&nbSp "C://111.mp3");  }}




Java,wavtomp3 format Conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.