Package net.sourceforge.jaad.mp4.api

Examples of net.sourceforge.jaad.mp4.api.ID3Tag


    if(!track.hasMoreFrames()) {
      buffer.close();
      return;
    }
    try {
      final Frame frame = track.readNextFrame();
      if(frame==null) {
        buffer.close();
        return;
      }
      decoder.decodeFrame(frame.getData(), sampleBuffer);
    }
    catch(IOException e) {
      buffer.close();
      return;
    }
View Full Code Here


     
     
      //create AAC decoder
      Decoder dec = new Decoder(audioTrack.getDecoderSpecificInfo());
      //decode
      Frame frame;
      SampleBuffer buf = new SampleBuffer();
      while(audioTrack.hasMoreFrames()) {
        frame = audioTrack.readNextFrame();
        try {
          dec.decodeFrame(frame.getData(), buf);
          b = buf.getData();
          line.write(b, 0, b.length);
        }
        catch(AACException e) {
          e.printStackTrace();
View Full Code Here

            audioFormat = new AudioFormat((float) track.getSampleRate(), bps * 8, track.getChannelCount(), true, false);
    }

    private void parseGaplessInfo(Movie movie) {
        gaplessPadding = track.getLastFramePadding();
        MetaData metaData = movie.getMetaData();
        String iTunSMPB = metaData.get(MetaData.Field.GAPLESS_PLAYBACK);
        if (iTunSMPB != null && iTunSMPB.length() > 0) {
            String[] data = iTunSMPB.trim().split(" ");
            gaplessDelay = Integer.parseInt(data[1], 16);
            gaplessPadding = (int) (track.getSampleDuration(0) - Integer.parseInt(data[2], 16));
        } else {
            //now estimate gapless delay based on the tool
            String tool = metaData.get(MetaData.Field.ENCODER_TOOL);
            if (tool != null && !tool.isEmpty()) {
                if (tool.startsWith("Nero")) {
                    gaplessDelay = (int) (track.getSampleDuration(0) * 2 + 576);
                } else if (tool.startsWith("FAAC")) {
                    gaplessDelay = (int) track.getSampleDuration(0);
View Full Code Here

    }

    private void initDecoder(long sample) throws IOException {
        in.seek(0);
        MP4Container cont = new MP4Container(in);
        Movie movie = cont.getMovie();
        List<net.sourceforge.jaad.mp4.api.Track> tracks = movie.getTracks(AudioTrack.AudioCodec.AAC);

        if (tracks == null || tracks.isEmpty()) {
            throw new IOException("Could not find AAC track");
        }
View Full Code Here

  private byte[] saved;

  MP4AudioInputStream(InputStream in, AudioFormat format, long length) throws IOException {
    super(in, format, length);
    final MP4Container cont = new MP4Container(in);
    final Movie movie = cont.getMovie();
    final List<Track> tracks = movie.getTracks(AudioTrack.AudioCodec.AAC);
    if(tracks.isEmpty()) throw new IOException("movie does not contain any AAC track");
    track = (AudioTrack) tracks.get(0);

    decoder = new Decoder(track.getDecoderSpecificInfo());
    sampleBuffer = new SampleBuffer();
View Full Code Here

  }

  //TODO: pdin, movie fragments??
  public Movie getMovie() {
    if(moov==null) return null;
    else if(movie==null) movie = new Movie(moov, in);
    return movie;
  }
View Full Code Here

  private void decodeMP4(String in) throws Exception {
    byte[] b;
    try {
      //create container
      final MP4Container cont = new MP4Container(new RandomAccessFile(in, "r"));
      final Movie movie = cont.getMovie();
      //find AAC track
      List<net.sourceforge.jaad.mp4.api.Track> tracks = movie.getTracks(AudioTrack.AudioCodec.AAC);
      if(tracks.isEmpty()) throw new Exception("movie does not contain any AAC track");
      audioTrack = (AudioTrack) tracks.get(0);
      //create audio format
      final AudioFormat aufmt = new AudioFormat(audioTrack.getSampleRate(), audioTrack.getSampleSize(), audioTrack.getChannelCount(), true, true);
      line = AudioSystem.getSourceDataLine(aufmt);
View Full Code Here

  private final Codec originalFormat;

  protected Protection(Box sinf) {
    //original format
    final long type = ((OriginalFormatBox) sinf.getChild(BoxTypes.ORIGINAL_FORMAT_BOX)).getOriginalFormat();
    Codec c;
    //TODO: currently it tests for audio and video codec, can do this any other way?
    if(!(c = AudioTrack.AudioCodec.forType(type)).equals(AudioTrack.AudioCodec.UNKNOWN_AUDIO_CODEC)) originalFormat = c;
    else if(!(c = VideoTrack.VideoCodec.forType(type)).equals(VideoTrack.VideoCodec.UNKNOWN_VIDEO_CODEC)) originalFormat = c;
    else originalFormat = null;
  }
View Full Code Here

  static Protection parse(Box sinf) {
    Protection p = null;
    if(sinf.hasChild(BoxTypes.SCHEME_TYPE_BOX)) {
      final SchemeTypeBox schm = (SchemeTypeBox) sinf.getChild(BoxTypes.SCHEME_TYPE_BOX);
      final long l = schm.getSchemeType();
      if(l==Scheme.ITUNES_FAIR_PLAY.type) p = new ITunesProtection(sinf);
    }

    if(p==null) p = new UnknownProtection(sinf);
    return p;
  }
View Full Code Here

  private Codec codec;

  public AudioTrack(Box trak, MP4InputStream in) {
    super(trak, in);

    final Box mdia = trak.getChild(BoxTypes.MEDIA_BOX);
    final Box minf = mdia.getChild(BoxTypes.MEDIA_INFORMATION_BOX);
    smhd = (SoundMediaHeaderBox) minf.getChild(BoxTypes.SOUND_MEDIA_HEADER_BOX);

    final Box stbl = minf.getChild(BoxTypes.SAMPLE_TABLE_BOX);

    //sample descriptions: 'mp4a' and 'enca' have an ESDBox, all others have a CodecSpecificBox
    final SampleDescriptionBox stsd = (SampleDescriptionBox) stbl.getChild(BoxTypes.SAMPLE_DESCRIPTION_BOX);
    if(stsd.getChildren().get(0) instanceof AudioSampleEntry) {
      sampleEntry = (AudioSampleEntry) stsd.getChildren().get(0);
      final long type = sampleEntry.getType();
      if(sampleEntry.hasChild(BoxTypes.ESD_BOX)) findDecoderSpecificInfo((ESDBox) sampleEntry.getChild(BoxTypes.ESD_BOX));
      else decoderInfo = DecoderInfo.parse((CodecSpecificBox) sampleEntry.getChildren().get(0));
View Full Code Here

TOP

Related Classes of net.sourceforge.jaad.mp4.api.ID3Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.