Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1006986 // Test reading .m4a [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 654K of libraries. Click here for Pure Java version (1942L/13K/45K).

!7

lib 1006985 // JAAD for AAC decoding

import net.sourceforge.jaad.mp4.*;
import net.sourceforge.jaad.mp4.api.*;
import net.sourceforge.jaad.mp4.api.Frame;
import net.sourceforge.jaad.aac.*;

p {
  File file = getProgramFile(#1006739, "Prince - Motherless Child - Live!-99Q31nyH16w.m4a");
  assertTrue("Please run #1006739", file.exists());
  
  fixContextClassLoader();
  MP4Container container = new MP4Container(new RandomAccessFile(file, "r"));
  Movie movie = container.getMovie();
  List<Track> tracks = movie.getTracks(AudioTrack.AudioCodec.AAC);
  if (tracks.size() > 0) {
    Track track = tracks.get(0);
    
    byte[] decoderSpecificInfo = track.getDecoderSpecificInfo();
    Decoder dec = new Decoder(decoderSpecificInfo);
    
    new SampleBuffer buf;
    Frame frame;
    while not null (frame = track.readNextFrame()) {
      dec.decodeFrame(frame.getData(), buf);
      byte[] audio = buf.getData();
      print("Got audio: " + l(audio) + " channels: " + buf.getChannels() + " bits/sample: " + buf.getBitsPerSample() + " " + (buf.isBigEndian() ? "big endian" : "little endian") + ", " + buf.getSampleRate() + " hz");
    }
  }
  print("Got " + n(tracks, "tracks"));
}

Author comment

Began life as a copy of #1006984

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1006986
Snippet name: Test reading .m4a [dev.]
Eternal ID of this version: #1006986/15
Text MD5: e6a967742749e86ceacde426c5d44e46
Transpilation MD5: aad555e7235ef27d46f14a2e7a1cc56a
Author: stefan
Category: javax / audio
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-22 00:08:00
Source code size: 1220 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 483 / 595
Version history: 14 change(s)
Referenced in: