本文整理汇总了Java中net.sourceforge.jaad.aac.Decoder类的典型用法代码示例。如果您正苦于以下问题:Java Decoder类的具体用法?Java Decoder怎么用?Java Decoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Decoder类属于net.sourceforge.jaad.aac包,在下文中一共展示了Decoder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AACDecoder
import net.sourceforge.jaad.aac.Decoder; //导入依赖的package包/类
public AACDecoder(byte[] decoderSpecificInfo, javax.sound.sampled.AudioFormat format) throws AACException {
this.format = new AudioFormat(
(int)format.getSampleRate(),
format.getSampleSizeInBits(),
format.getChannels(),
format.getEncoding() == Encoding.PCM_SIGNED,
format.isBigEndian());
this.decoder = new Decoder(decoderSpecificInfo);
}
示例2: decodeAAC
import net.sourceforge.jaad.aac.Decoder; //导入依赖的package包/类
private AudioInputStream decodeAAC(File inputFile) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AudioFormat audioFormat;
try {
final ADTSDemultiplexer adts = new ADTSDemultiplexer(new FileInputStream(inputFile));
final Decoder dec = new Decoder(adts.getDecoderSpecificInfo());
final SampleBuffer buf = new SampleBuffer();
byte[] b;
while (true) {
try {
b = adts.readNextFrame();
}
catch (Exception e) {
break;
}
dec.decodeFrame(b, buf);
outputStream.write(buf.getData());
}
audioFormat = new AudioFormat(buf.getSampleRate(), buf.getBitsPerSample(), buf.getChannels(), true, buf.isBigEndian());
} finally {
// nop
}
byte[] outputStreamByteArray = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStreamByteArray);
return new AudioInputStream(inputStream, audioFormat, outputStreamByteArray.length);
}
示例3: decodeMP4
import net.sourceforge.jaad.aac.Decoder; //导入依赖的package包/类
private AudioInputStream decodeMP4(File inputFile) throws UnsupportedAudioFileException, IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AudioFormat audioFormat;
try {
RandomAccessFile randomAccessFile = new RandomAccessFile(inputFile, "r");
final MP4Container cont = new MP4Container(randomAccessFile);
final Movie movie = cont.getMovie();
final List<Track> tracks = movie.getTracks(AudioTrack.AudioCodec.AAC);
if (tracks.isEmpty()) {
throw new UnsupportedAudioFileException("Movie does not contain any AAC track");
}
final AudioTrack track = (AudioTrack) tracks.get(0);
final Decoder dec = new Decoder(track.getDecoderSpecificInfo());
Frame frame;
final SampleBuffer buf = new SampleBuffer();
while (track.hasMoreFrames()) {
frame = track.readNextFrame();
dec.decodeFrame(frame.getData(), buf);
outputStream.write(buf.getData());
}
audioFormat = new AudioFormat(track.getSampleRate(), track.getSampleSize(), track.getChannelCount(), true, true);
} finally {
// nop
}
byte[] outputStreamByteArray = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStreamByteArray);
return new AudioInputStream(inputStream, audioFormat, outputStreamByteArray.length);
}
示例4: canDecode
import net.sourceforge.jaad.aac.Decoder; //导入依赖的package包/类
public static boolean canDecode(Profile profile) {
return Decoder.canDecode(profile);
}