private boolean readSamples() throws IOException { int read = frameSize; boolean ret = false; while (frameSize == read) { ret = true; byte[] data = new byte[frameSize]; read = inputStream.read(data); if (read == frameSize) { samples.add(ByteBuffer.wrap(data)); stts.add(new TimeToSampleBox.Entry(1, 1536)); } } return ret; }
private boolean readSamples() throws IOException { int read = frameSize; boolean ret = false; while (frameSize == read) { ret = true; byte[] data = new byte[frameSize]; read = inputStream.read(data); if (read == frameSize) { samples.add(ByteBuffer.wrap(data)); stts.add(new TimeToSampleBox.Entry(1, 1536)); } } return ret; }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { List<TimeToSampleBox.Entry> stts = new LinkedList<TimeToSampleBox.Entry>(); long lastEnd = 0; for (Line sub : subs) { long silentTime = sub.from - lastEnd; if (silentTime > 0) { stts.add(new TimeToSampleBox.Entry(1, silentTime)); } else if (silentTime < 0) { throw new Error("Subtitle display times may not intersect"); } stts.add(new TimeToSampleBox.Entry(1, sub.to - sub.from)); lastEnd = sub.to; } return stts; }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { List<TimeToSampleBox.Entry> stts = new LinkedList<TimeToSampleBox.Entry>(); long lastEnd = 0; for (Line sub : subs) { long silentTime = sub.from - lastEnd; if (silentTime > 0) { stts.add(new TimeToSampleBox.Entry(1, silentTime)); } else if (silentTime < 0) { throw new Error("Subtitle display times may not intersect"); } stts.add(new TimeToSampleBox.Entry(1, sub.to - sub.from)); lastEnd = sub.to; } return stts; }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { LinkedList<TimeToSampleBox.Entry> timesToSample = new LinkedList<TimeToSampleBox.Entry>(); LinkedList<Long> keys = new LinkedList<Long>(rawSamples.keySet()); Collections.sort(keys); long lastTimeStamp = 0; for (Long key : keys) { long delta = key - lastTimeStamp; if (timesToSample.size() > 0 && timesToSample.peek().getDelta() == delta) { timesToSample.peek().setCount(timesToSample.peek().getCount() + 1); } else { timesToSample.add(new TimeToSampleBox.Entry(1, delta)); } lastTimeStamp = key; } return timesToSample; }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { List<TimeToSampleBox.Entry> stts = new LinkedList<TimeToSampleBox.Entry>(); long lastEnd = 0; for (Line sub : subs) { long silentTime = sub.from - lastEnd; if (silentTime > 0) { stts.add(new TimeToSampleBox.Entry(1, silentTime)); } else if (silentTime < 0) { throw new Error("Subtitle display times may not intersect"); } stts.add(new TimeToSampleBox.Entry(1, sub.to - sub.from)); lastEnd = sub.to; } return stts; }
public SilenceTrackImpl(Track ofType, long ms) { source = ofType; if ("mp4a".equals(ofType.getSampleDescriptionBox().getSampleEntry().getType())) { long numFrames = getTrackMetaData().getTimescale() * ms / 1000 / 1024; long standZeit = getTrackMetaData().getTimescale() * ms / numFrames / 1000; entry = new TimeToSampleBox.Entry(numFrames, standZeit); while (numFrames-- > 0) { samples.add((ByteBuffer) ByteBuffer.wrap(new byte[]{ 0x21, 0x10, 0x04, 0x60, (byte) 0x8c, 0x1c, }).rewind()); } } else { throw new RuntimeException("Tracks of type " + ofType.getClass().getSimpleName() + " are not supported"); } }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<TimeToSampleBox.Entry>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
public SilenceTrackImpl(Track ofType, long ms) { source = ofType; if ("mp4a".equals(ofType.getSampleDescriptionBox().getSampleEntry().getType())) { long numFrames = getTrackMetaData().getTimescale() * ms / 1000 / 1024; long standZeit = getTrackMetaData().getTimescale() * ms / numFrames / 1000; entry = new TimeToSampleBox.Entry(numFrames, standZeit); while (numFrames-- > 0) { samples.add((ByteBuffer) ByteBuffer.wrap(new byte[]{ 0x21, 0x10, 0x04, 0x60, (byte) 0x8c, 0x1c, }).rewind()); } } else { throw new RuntimeException("Tracks of type " + ofType.getClass().getSimpleName() + " are not supported"); } }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
protected void createStts(Track track, SampleTableBox stbl) { TimeToSampleBox.Entry lastEntry = null; List<TimeToSampleBox.Entry> entries = new ArrayList<>(); for (long delta : track.getSampleDurations()) { if (lastEntry != null && lastEntry.getDelta() == delta) { lastEntry.setCount(lastEntry.getCount() + 1); } else { lastEntry = new TimeToSampleBox.Entry(1, delta); entries.add(lastEntry); } } TimeToSampleBox stts = new TimeToSampleBox(); stts.setEntries(entries); stbl.addBox(stts); }
public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { List<TimeToSampleBox.Entry> stts = new LinkedList<TimeToSampleBox.Entry>(); long lastEnd = 0; for (Line sub : subs) { long silentTime = sub.from - lastEnd; if (silentTime > 0) { stts.add(new TimeToSampleBox.Entry(1, silentTime)); } else if (silentTime < 0) { throw new Error("Subtitle display times may not intersect"); } stts.add(new TimeToSampleBox.Entry(1, sub.to - sub.from)); lastEnd = sub.to; } return stts; }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); int entryCount = l2i(IsoTypeReader.readUInt32(content)); entries = new ArrayList<Entry>(entryCount); for (int i = 0; i < entryCount; i++) { entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content))); } }
List<TimeToSampleBox.Entry> adjustTts() { List<TimeToSampleBox.Entry> origTts = source.getDecodingTimeEntries(); LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>(); for (TimeToSampleBox.Entry e : origTts) { entries2.add(new TimeToSampleBox.Entry(e.getCount(), e.getDelta() / timeScaleDivisor)); } return entries2; }
static List<TimeToSampleBox.Entry> adjustTts(List<TimeToSampleBox.Entry> source, int timeScaleFactor) { LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>(); for (TimeToSampleBox.Entry e : source) { entries2.add(new TimeToSampleBox.Entry(e.getCount(), timeScaleFactor * e.getDelta())); } return entries2; }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); int entryCount = l2i(IsoTypeReader.readUInt32(content)); entries = new ArrayList<Entry>(entryCount); for (int i = 0; i < entryCount; i++) { entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content))); } }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); int entryCount = l2i(IsoTypeReader.readUInt32(content)); entries = new ArrayList<Entry>(entryCount); for (int i = 0; i < entryCount; i++) { entries.add(new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content))); } }
static List<TimeToSampleBox.Entry> adjustTts(List<TimeToSampleBox.Entry> source, int timeScaleFactor) { LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>(); for (TimeToSampleBox.Entry e : source) { entries2.add(new TimeToSampleBox.Entry(e.getCount(), timeScaleFactor * e.getDelta())); } return entries2; }
List<TimeToSampleBox.Entry> adjustTts() { List<TimeToSampleBox.Entry> origTts = source.getDecodingTimeEntries(); LinkedList<TimeToSampleBox.Entry> entries2 = new LinkedList<TimeToSampleBox.Entry>(); for (TimeToSampleBox.Entry e : origTts) { entries2.add(new TimeToSampleBox.Entry(e.getCount(), e.getDelta() / timeScaleDivisor)); } return entries2; }