public static Label[] getLabels(TrakBox trakBox) { return getLabels((AudioSampleEntry) trakBox.getSampleEntries()[0]); }
public static Label[] getLabelsFromTrack(TrakBox trakBox) { return AudioSampleEntry.getLabelsFromSampleEntry((AudioSampleEntry) trakBox.getSampleEntries()[0]); }
public static Label[] getLabels(TrakBox trakBox) { return getLabels((AudioSampleEntry) trakBox.getSampleEntries()[0]); }
MovieBox movie = MP4Util.parseMovie(new File("path to file")); Assert.assertEquals(movie.getVideoTrack().getSampleEntries()[0].getFourcc(), "avc1"); for (TrakBox trakBox : movie.getAudioTracks()) { Assert.assertEquals(trakBox.getSampleEntries()[0].getFourcc(), "mp4a"); }
/** * Retrieves coded size of this video track. * * Note: May be different from video display dimension. * * @return */ public Size getCodedSize() { SampleEntry se = getSampleEntries()[0]; if (!(se instanceof VideoSampleEntry)) throw new IllegalArgumentException("Not a video track"); VideoSampleEntry vse = (VideoSampleEntry) se; return new Size(vse.getWidth(), vse.getHeight()); }
/** * Retrieves coded size of this video track. * * Note: May be different from video display dimension. * * @return */ public Size getCodedSize() { SampleEntry se = getSampleEntries()[0]; if (!(se instanceof VideoSampleEntry)) throw new IllegalArgumentException("Not a video track"); VideoSampleEntry vse = (VideoSampleEntry) se; return new Size(vse.getWidth(), vse.getHeight()); }
/** * Retrieves coded size of this video track. * * Note: May be different from video display dimension. * * @return */ public Size getCodedSize() { SampleEntry se = getSampleEntries()[0]; if (!(se instanceof VideoSampleEntry)) throw new IllegalArgumentException("Not a video track"); VideoSampleEntry vse = (VideoSampleEntry) se; return new Size(vse.getWidth(), vse.getHeight()); }
public void setPAR(Rational par) { for (SampleEntry sampleEntry : getSampleEntries()) { sampleEntry.removeChildren("pasp"); sampleEntry.add(new PixelAspectExt(par)); } }
/** * Converts timevalue to frame number based on timecode track * * @param timecodeTrack * @param tv * @return */ public static int timevalueToTimecodeFrame(TrakBox timecodeTrack, RationalLarge tv, int movieTimescale) { TimecodeSampleEntry se = (TimecodeSampleEntry) timecodeTrack.getSampleEntries()[0]; return (int) ((2 * tv.multiplyS(se.getTimescale()) / se.getFrameDuration()) + 1) / 2; }
public void setPAR(Rational par) { SampleEntry[] sampleEntries = getSampleEntries(); for (int i = 0; i < sampleEntries.length; i++) { SampleEntry sampleEntry = sampleEntries[i]; sampleEntry.removeChildren("pasp"); sampleEntry.add(PixelAspectExt.createPixelAspectExt(par)); } }
/** * Converts timevalue to frame number based on timecode track * * @param timecodeTrack * @param tv * @return */ public static int timevalueToTimecodeFrame(TrakBox timecodeTrack, RationalLarge tv, int movieTimescale) { TimecodeSampleEntry se = (TimecodeSampleEntry) timecodeTrack.getSampleEntries()[0]; return (int) ((2 * tv.multiplyS(se.getTimescale()) / se.getFrameDuration()) + 1) / 2; }
/** * Converts timevalue to frame number based on timecode track * * @param timecodeTrack * @param tv * @return */ public static int timevalueToTimecodeFrame(TrakBox timecodeTrack, RationalLarge tv, int movieTimescale) { TimecodeSampleEntry se = (TimecodeSampleEntry) timecodeTrack.getSampleEntries()[0]; return (int) ((2 * tv.multiplyS(se.getTimescale()) / se.getFrameDuration()) + 1) / 2; }
public void setPAR(Rational par) { for (SampleEntry sampleEntry : getSampleEntries()) { sampleEntry.removeChildren("pasp"); sampleEntry.add(new PixelAspectExt(par)); } }
private static int appendEntries(TrakBox trakBox1, TrakBox trakBox2) { appendDrefs(trakBox1, trakBox2); SampleEntry[] ent1 = trakBox1.getSampleEntries(); SampleEntry[] ent2 = trakBox2.getSampleEntries(); SampleDescriptionBox stsd = SampleDescriptionBox.createSampleDescriptionBox(ent1); for (int i = 0; i < ent2.length; i++) { SampleEntry se = ent2[i]; se.setDrefInd((short) (se.getDrefInd() + ent1.length)); stsd.add(se); } NodeBox.findFirstPath(trakBox1, NodeBox.class, Box.path("mdia.minf.stbl")).replace("stsd", stsd); return ent1.length; }
public ChunkWriter(TrakBox trak, SeekableByteChannel[] inputs, SeekableByteChannel out) { this.buf = new byte[8092]; entries = trak.getSampleEntries(); ChunkOffsetsBox stco = trak.getStco(); ChunkOffsets64Box co64 = trak.getCo64(); int size; if (stco != null) size = stco.getChunkOffsets().length; else size = co64.getChunkOffsets().length; this.inputs = inputs; offsets = new long[size]; this.out = out; this.trak = trak; }
private void cleanDrefs(TrakBox trak) { MediaInfoBox minf = trak.getMdia().getMinf(); DataInfoBox dinf = trak.getMdia().getMinf().getDinf(); if (dinf == null) { dinf = DataInfoBox.createDataInfoBox(); minf.add(dinf); } DataRefBox dref = dinf.getDref(); if (dref == null) { dref = DataRefBox.createDataRefBox(); dinf.add(dref); } dref.getBoxes().clear(); dref.add(AliasBox.createSelfRef()); SampleEntry[] sampleEntries = trak.getSampleEntries(); for (int i = 0; i < sampleEntries.length; i++) { SampleEntry entry = sampleEntries[i]; entry.setDrefInd((short) 1); } }
public TimecodeMP4DemuxerTrack(MovieBox movie, TrakBox trak, SeekableByteChannel input) throws IOException { this.box = trak; this.input = input; this.movie = movie; NodeBox stbl = trak.getMdia().getMinf().getStbl(); TimeToSampleBox stts = NodeBox.findFirst(stbl, TimeToSampleBox.class, "stts"); SampleToChunkBox stsc = NodeBox.findFirst(stbl, SampleToChunkBox.class, "stsc"); ChunkOffsetsBox stco = NodeBox.findFirst(stbl, ChunkOffsetsBox.class, "stco"); ChunkOffsets64Box co64 = NodeBox.findFirst(stbl, ChunkOffsets64Box.class, "co64"); timeToSamples = stts.getEntries(); chunkOffsets = stco != null ? stco.getChunkOffsets() : co64.getChunkOffsets(); sampleToChunks = stsc.getSampleToChunk(); if (chunkOffsets.length == 1) { cacheSamples(sampleToChunks, chunkOffsets); } tse = (TimecodeSampleEntry) box.getSampleEntries()[0]; }
public TimecodeMP4DemuxerTrack(MovieBox movie, TrakBox trak, SeekableByteChannel input) throws IOException { this.box = trak; this.input = input; this.movie = movie; NodeBox stbl = trak.getMdia().getMinf().getStbl(); TimeToSampleBox stts = findFirst(stbl, TimeToSampleBox.class, "stts"); SampleToChunkBox stsc = findFirst(stbl, SampleToChunkBox.class, "stsc"); ChunkOffsetsBox stco = findFirst(stbl, ChunkOffsetsBox.class, "stco"); ChunkOffsets64Box co64 = findFirst(stbl, ChunkOffsets64Box.class, "co64"); timeToSamples = stts.getEntries(); chunkOffsets = stco != null ? stco.getChunkOffsets() : co64.getChunkOffsets(); sampleToChunks = stsc.getSampleToChunk(); if (chunkOffsets.length == 1) { cacheSamples(sampleToChunks, chunkOffsets); } tse = (TimecodeSampleEntry) box.getSampleEntries()[0]; }
public TimecodeMP4DemuxerTrack(MovieBox movie, TrakBox trak, SeekableByteChannel input) throws IOException { this.box = trak; this.input = input; this.movie = movie; NodeBox stbl = trak.getMdia().getMinf().getStbl(); TimeToSampleBox stts = findFirst(stbl, TimeToSampleBox.class, "stts"); SampleToChunkBox stsc = findFirst(stbl, SampleToChunkBox.class, "stsc"); ChunkOffsetsBox stco = findFirst(stbl, ChunkOffsetsBox.class, "stco"); ChunkOffsets64Box co64 = findFirst(stbl, ChunkOffsets64Box.class, "co64"); timeToSamples = stts.getEntries(); chunkOffsets = stco != null ? stco.getChunkOffsets() : co64.getChunkOffsets(); sampleToChunks = stsc.getSampleToChunk(); if (chunkOffsets.length == 1) { cacheSamples(sampleToChunks, chunkOffsets); } tse = (TimecodeSampleEntry) box.getSampleEntries()[0]; }