本文整理匯總了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);
}