如何用Java编写FLAC文件 [英] How to write FLAC files in java

查看:405
本文介绍了如何用Java编写FLAC文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须写在Java FLAC文件的要求。早些时候,我在写音频输入成WAV文件,然后使用一个外部转换器将其转换为FLAC文件

I have a requirement to write FLAC files in java. Earlier I was writing the audio input into a WAV file and then converting it to FLAC file using a external converter

我一直在寻找进入JFlac发现,通过它我可以写FLAC文件的任何API。我发现在java中的为AudioFileFormat.Type仅支持以下文件格式 - AIFC,AIFF,SND,AU,WAVE。

I was looking into JFlac to find any API through which I can write FLAC files. I found that AudioFileFormat.TYPE in java supports only the following file formats - AIFC, AIFF, SND, AU, WAVE .

我会是我捕捉来自麦克风的音频,并使用API​​,如Audiosystem.write,其写入FLAC文件,而不是WAV文件的方法。

What I would is a method where I capture the audio from the microphone, and using an API such as Audiosystem.write, write it to a FLAC file instead of WAV file.

请提出一个方法或API,可以解决我的问题。

Please suggest a method or an API that can solve my problem.

推荐答案

您可以使用库。下面是使用版本0.2.3(javaFlacEn codeR-0.2.3-all.tar.gz)一个简单的例子。提取dowloaded文件,然后导入javaFlacEn codeR-0.2.3.jar到项目中。如需更多资料,请参阅here:

You can use this lib. Here is a simple example using version 0.2.3 (javaFlacEncoder-0.2.3-all.tar.gz). Extract the dowloaded file, and then import javaFlacEncoder-0.2.3.jar to your project. For more documentation, see here:

package fr.telecomParisTech;
import java.io.File;
import javaFlacEncoder.FLAC_FileEncoder;
public class SoundConverter {
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        FLAC_FileEncoder flacEncoder = new FLAC_FileEncoder();
        File inputFile = new File("hello.wav");
        File outputFile = new File("hello.flac");

        flacEncoder.encode(inputFile, outputFile);
        System.out.println("Done");
    }
}

这篇关于如何用Java编写FLAC文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆