public static AudioSampleEntry createAudioSampleEntry(Header header, short drefInd, short channelCount, short sampleSize, int sampleRate, short revision, int vendor, int compressionId, int pktSize, int samplesPerPkt, int bytesPerPkt, int bytesPerFrame, int bytesPerSample, short version) { AudioSampleEntry audio = new AudioSampleEntry(header); audio.drefInd = drefInd; audio.channelCount = channelCount; audio.sampleSize = sampleSize; audio.sampleRate = sampleRate; audio.revision = revision; audio.vendor = vendor; audio.compressionId = compressionId; audio.pktSize = pktSize; audio.samplesPerPkt = samplesPerPkt; audio.bytesPerPkt = bytesPerPkt; audio.bytesPerFrame = bytesPerFrame; audio.bytesPerSample = bytesPerSample; audio.version = version; return audio; }
public int calcSampleSize() { return calcFrameSize() / channelCount; }
public AudioFormat getFormat() { return new AudioFormat((int) sampleRate, calcSampleSize() << 3, channelCount, true, getEndian() == Endian.BIG_ENDIAN); }
public ChannelLabel[] getLabels() { ChannelBox channelBox = NodeBox.findFirst(this, ChannelBox.class, "chan"); if (channelBox != null) { Label[] labels = AudioSampleEntry.getLabelsFromChan(channelBox); if (channelCount == 2) return translate(translationStereo, labels); else return translate(translationSurround, labels); } else { switch (channelCount) { case 1: return new ChannelLabel[] { ChannelLabel.MONO }; case 2: return new ChannelLabel[] { ChannelLabel.STEREO_LEFT, ChannelLabel.STEREO_RIGHT }; case 6: return new ChannelLabel[] { ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.CENTER, ChannelLabel.LFE, ChannelLabel.REAR_LEFT, ChannelLabel.REAR_RIGHT }; default: ChannelLabel[] lbl = new ChannelLabel[channelCount]; Arrays.fill(lbl, ChannelLabel.MONO); return lbl; } } }
public static Label[] getLabelsFromSampleEntry(AudioSampleEntry se) { ChannelBox channel = NodeBox.findFirst(se, ChannelBox.class, "chan"); if (channel != null) return getLabelsFromChan(channel); else { short channelCount = se.getChannelCount(); switch (channelCount) { case 1: return new Label[] { Label.Mono }; case 2: return new Label[] { Label.Left, Label.Right }; case 3: return new Label[] { Label.Left, Label.Right, Label.Center }; case 4: return new Label[] { Label.Left, Label.Right, Label.LeftSurround, Label.RightSurround }; case 5: return new Label[] { Label.Left, Label.Right, Label.Center, Label.LeftSurround, Label.RightSurround }; case 6: return new Label[] { Label.Left, Label.Right, Label.Center, Label.LFEScreen, Label.LeftSurround, Label.RightSurround }; default: Label[] res = new Label[channelCount]; Arrays.fill(res, Label.Mono); return res; } } }
public static AudioSampleEntry audioSampleEntry(String fourcc, int drefId, int sampleSize, int channels, int sampleRate, Endian endian) { AudioSampleEntry ase = new AudioSampleEntry(new Header(fourcc, 0), (short) drefId, (short) channels, (short) 16, sampleRate, (short) 0, 0, 65535, 0, 1, sampleSize, channels * sampleSize, sampleSize, (short) 1); NodeBox wave = new NodeBox(new Header("wave")); ase.add(wave); wave.add(new FormatBox(fourcc)); wave.add(new EndianBox(endian)); wave.add(terminatorAtom()); // ase.add(new ChannelBox(atom)); return ase; }
public void parse(ByteBuffer input) { super.parse(input); version = input.getShort(); revision = input.getShort(); vendor = input.getInt(); channelCount = input.getShort(); sampleSize = input.getShort(); compressionId = input.getShort(); pktSize = input.getShort(); long sr = input.getInt() & 0xffffffffL; sampleRate = (float) sr / 65536f; if (version == 1) { samplesPerPkt = input.getInt(); bytesPerPkt = input.getInt(); bytesPerFrame = input.getInt(); bytesPerSample = input.getInt(); } else if (version == 2) { input.getInt(); /* sizeof struct only */ sampleRate = (float) Double.longBitsToDouble(input.getLong()); channelCount = (short) input.getInt(); input.getInt(); /* always 0x7F000000 */ sampleSize = (short) input.getInt(); lpcmFlags = (int) input.getInt(); bytesPerFrame = (int) input.getInt(); samplesPerPkt = (int) input.getInt(); } parseExtensions(input); }
public static AudioSampleEntry audioSampleEntry(String fourcc, int drefId, int sampleSize, int channels, int sampleRate, ByteOrder endian) { AudioSampleEntry ase = createAudioSampleEntry(Header.createHeader(fourcc, 0), (short) drefId, (short) channels, (short) 16, sampleRate, (short) 0, 0, 65535, 0, 1, sampleSize, channels * sampleSize, sampleSize, (short) 1); NodeBox wave = new NodeBox(new Header("wave")); ase.add(wave); wave.add(FormatBox.createFormatBox(fourcc)); wave.add(EndianBox.createEndianBox(endian)); wave.add(Box.terminatorAtom()); // ase.add(new ChannelBox(atom)); return ase; }
public ChannelLabel[] getLabels() { ChannelBox channelBox = Box.findFirst(this, ChannelBox.class, "chan"); if (channelBox != null) { Label[] labels = ChannelUtils.getLabels(channelBox); if (channelCount == 2) return translate(translationStereo, labels); else return translate(translationSurround, labels); } else { switch (channelCount) { case 1: return new ChannelLabel[] { ChannelLabel.MONO }; case 2: return new ChannelLabel[] { ChannelLabel.STEREO_LEFT, ChannelLabel.STEREO_RIGHT }; case 6: return new ChannelLabel[] { ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.CENTER, ChannelLabel.LFE, ChannelLabel.REAR_LEFT, ChannelLabel.REAR_RIGHT }; default: ChannelLabel[] lbl = new ChannelLabel[channelCount]; Arrays.fill(lbl, ChannelLabel.MONO); return lbl; } } }
public static Label[] getLabels(AudioSampleEntry se) { ChannelBox channel = Box.findFirst(se, ChannelBox.class, "chan"); if (channel != null) return ChannelUtils.getLabels(channel); else { short channelCount = se.getChannelCount(); switch (channelCount) { case 1: return new Label[] { Label.Mono }; case 2: return new Label[] { Label.Left, Label.Right }; case 3: return new Label[] { Label.Left, Label.Right, Label.Center }; case 4: return new Label[] { Label.Left, Label.Right, Label.LeftSurround, Label.RightSurround }; case 5: return new Label[] { Label.Left, Label.Right, Label.Center, Label.LeftSurround, Label.RightSurround }; case 6: return new Label[] { Label.Left, Label.Right, Label.Center, Label.LFEScreen, Label.LeftSurround, Label.RightSurround }; default: Label[] res = new Label[channelCount]; Arrays.fill(res, Label.Mono); return res; } } }
public static AudioSampleEntry audioSampleEntry(String fourcc, int drefId, int sampleSize, int channels, int sampleRate, Endian endian) { AudioSampleEntry ase = new AudioSampleEntry(new Header(fourcc, 0), (short) drefId, (short) channels, (short) 16, sampleRate, (short) 0, 0, 65535, 0, 1, sampleSize, channels * sampleSize, sampleSize, (short) 1); NodeBox wave = new NodeBox(new Header("wave")); ase.add(wave); wave.add(new FormatBox(fourcc)); wave.add(new EndianBox(endian)); wave.add(terminatorAtom()); // ase.add(new ChannelBox(atom)); return ase; }
public void parse(ByteBuffer input) { super.parse(input); version = input.getShort(); revision = input.getShort(); vendor = input.getInt(); channelCount = input.getShort(); sampleSize = input.getShort(); compressionId = input.getShort(); pktSize = input.getShort(); long sr = input.getInt() & 0xffffffffL; sampleRate = (float) sr / 65536f; if (version == 1) { samplesPerPkt = input.getInt(); bytesPerPkt = input.getInt(); bytesPerFrame = input.getInt(); bytesPerSample = input.getInt(); } else if (version == 2) { input.getInt(); /* sizeof struct only */ sampleRate = (float) Double.longBitsToDouble(input.getLong()); channelCount = (short) input.getInt(); input.getInt(); /* always 0x7F000000 */ sampleSize = (short) input.getInt(); lpcmFlags = (int) input.getInt(); bytesPerFrame = (int) input.getInt(); samplesPerPkt = (int) input.getInt(); } parseExtensions(input); }
public ChannelLabel[] getLabels() { ChannelBox channelBox = Box.findFirst(this, ChannelBox.class, "chan"); if (channelBox != null) { Label[] labels = ChannelUtils.getLabels(channelBox); if (channelCount == 2) return translate(translationStereo, labels); else return translate(translationSurround, labels); } else { switch (channelCount) { case 1: return new ChannelLabel[] { ChannelLabel.MONO }; case 2: return new ChannelLabel[] { ChannelLabel.STEREO_LEFT, ChannelLabel.STEREO_RIGHT }; case 6: return new ChannelLabel[] { ChannelLabel.FRONT_LEFT, ChannelLabel.FRONT_RIGHT, ChannelLabel.CENTER, ChannelLabel.LFE, ChannelLabel.REAR_LEFT, ChannelLabel.REAR_RIGHT }; default: ChannelLabel[] lbl = new ChannelLabel[channelCount]; Arrays.fill(lbl, ChannelLabel.MONO); return lbl; } } }
public static Label[] getLabels(AudioSampleEntry se) { ChannelBox channel = Box.findFirst(se, ChannelBox.class, "chan"); if (channel != null) return ChannelUtils.getLabels(channel); else { short channelCount = se.getChannelCount(); switch (channelCount) { case 1: return new Label[] { Label.Mono }; case 2: return new Label[] { Label.Left, Label.Right }; case 3: return new Label[] { Label.Left, Label.Right, Label.Center }; case 4: return new Label[] { Label.Left, Label.Right, Label.LeftSurround, Label.RightSurround }; case 5: return new Label[] { Label.Left, Label.Right, Label.Center, Label.LeftSurround, Label.RightSurround }; case 6: return new Label[] { Label.Left, Label.Right, Label.Center, Label.LFEScreen, Label.LeftSurround, Label.RightSurround }; default: Label[] res = new Label[channelCount]; Arrays.fill(res, Label.Mono); return res; } } }
public FramesMP4MuxerTrack addCompressedAudioTrack(String fourcc, int timescale, int channels, int sampleRate, int samplesPerPkt, Box... extra) { FramesMP4MuxerTrack track = addTrack(SOUND, timescale); AudioSampleEntry ase = new AudioSampleEntry(new Header(fourcc, 0), (short) 1, (short) channels, (short) 16, sampleRate, (short) 0, 0, 65534, 0, samplesPerPkt, 0, 0, 2, (short) 1); NodeBox wave = new NodeBox(new Header("wave")); ase.add(wave); wave.add(new FormatBox(fourcc)); for (Box box : extra) wave.add(box); wave.add(terminatorAtom()); track.addSampleEntry(ase); return track; } }
public AudioFormat getFormat() { return new AudioFormat((int) sampleRate, calcSampleSize() << 3, channelCount, true, getEndian() == Endian.BIG_ENDIAN); }
public int calcSampleSize() { return calcFrameSize() / channelCount; }
public void parse(ByteBuffer input) { super.parse(input); version = input.getShort(); revision = input.getShort(); vendor = input.getInt(); channelCount = input.getShort(); sampleSize = input.getShort(); compressionId = input.getShort(); pktSize = input.getShort(); long sr = input.getInt() & 0xffffffffL; sampleRate = (float) sr / 65536f; if (version == 1) { samplesPerPkt = input.getInt(); bytesPerPkt = input.getInt(); bytesPerFrame = input.getInt(); bytesPerSample = input.getInt(); } else if (version == 2) { input.getInt(); /* sizeof struct only */ sampleRate = (float) Double.longBitsToDouble(input.getLong()); channelCount = (short) input.getInt(); input.getInt(); /* always 0x7F000000 */ sampleSize = (short) input.getInt(); lpcmFlags = (int) input.getInt(); bytesPerFrame = (int) input.getInt(); samplesPerPkt = (int) input.getInt(); } parseExtensions(input); }