本文整理汇总了Java中it.sauronsoftware.jave.AudioAttributes.setChannels方法的典型用法代码示例。如果您正苦于以下问题:Java AudioAttributes.setChannels方法的具体用法?Java AudioAttributes.setChannels怎么用?Java AudioAttributes.setChannels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.sauronsoftware.jave.AudioAttributes
的用法示例。
在下文中一共展示了AudioAttributes.setChannels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mp4ToMp3
import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
/**
* Converts Mp4 file to MP3
*
* @param fileMp4
* @param fileMp3
* @return true if it has been converted
*/
public static boolean mp4ToMp3(File fileMp4, File fileMp3)
{
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
try
{
encoder.encode(fileMp4, fileMp3, attrs);
Log.info("File MP4 convertito in MP3");
return true;
}
catch (IllegalArgumentException | EncoderException e)
{
Log.error("File non convertito");
Log.stackTrace(e.getStackTrace());
return false;
}
}
示例2: FileEncoder
import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
public FileEncoder(String inFileName, String outFileName)
{
encoder = new Encoder();
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(320000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
inputFile = new File(inFileName);
outputFile = new File(outFileName);
}
示例3: writeMP3
import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
/**
* Converts the given <code>sequence</code> to a wav file and then to a mp3 file.
* The temporary wav file is deleted afterwards.
*
* @param sequence The sequence to write to the file
* @param fileName The file to write to
* @throws IOException Thrown if writing to file was not possible
* @see MusicWriter#writeWav(Sequence, String)
*/
public static void writeMP3(Sequence sequence, String fileName) throws IOException {
String file = fileNameWithoutEnding(fileName);
File wav = new File(file + System.currentTimeMillis() + ".wav");
File mp3 = new File(file + ".mp3");
mp3.delete();
writeWav(sequence, wav.getPath());
//Convert wav to mp3
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(64000);
audio.setChannels(2);
audio.setSamplingRate(22050);
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
try {
encoder.encode(wav, mp3, attrs);
if (!fileName.equals(mp3.getName()))
System.out.println("Wrote mp3 to \"" + mp3.getPath() + "\"");
} catch (EncoderException e) {
e.printStackTrace();
} finally {
if (!wav.delete())
System.err.println("Could not delete temporary wav file");
}
}
示例4: encodeMP3
import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
public boolean encodeMP3() {
try {
File fileConvert = new File(System.getProperty("user.dir") + "/" + toConvert);
File fileConversion = new File(System.getProperty("user.dir") + "/" + resultConversion);
Encoder enc = new Encoder();
EncodingAttributes att = new EncodingAttributes();
InfoMusic inf = new InfoMusic(fileConvert);
att.setDuration((float) inf.getFullTime());
AudioAttributes audioAttributes = new AudioAttributes();
audioAttributes.setBitRate(BITRATE);
audioAttributes.setChannels(CHANNELS);
audioAttributes.setSamplingRate((int) SAMPLE);
att.setAudioAttributes(audioAttributes);
att.setFormat("mp3");
enc.encode(fileConvert, fileConversion, att);
} catch (EncoderException e) {
e.printStackTrace();
return false;
}
return true;
}