private boolean isTimeGap(TapeTimecode prevTimecode, TapeTimecode tapeTimecode) { boolean gap = false; int sec = toSec(tapeTimecode); int secDiff = sec - toSec(prevTimecode); if (secDiff == 0) { int frameDiff = tapeTimecode.getFrame() - prevTimecode.getFrame(); if (fpsEstimate != -1) frameDiff = (frameDiff + fpsEstimate) % fpsEstimate; gap = frameDiff != 1; } else if (secDiff == 1) { if (fpsEstimate == -1) { if (tapeTimecode.getFrame() == 0) fpsEstimate = prevTimecode.getFrame() + 1; else gap = true; } else { int firstFrame = tapeTimecode.isDropFrame() && (sec % 60) == 0 && (sec % 600) != 0 ? 2 : 0; if (tapeTimecode.getFrame() != firstFrame || prevTimecode.getFrame() != fpsEstimate - 1) gap = true; } } else { gap = true; } return gap; }
private boolean isTimeGap(TapeTimecode prevTimecode, TapeTimecode tapeTimecode) { boolean gap = false; int sec = toSec(tapeTimecode); int secDiff = sec - toSec(prevTimecode); if (secDiff == 0) { int frameDiff = tapeTimecode.getFrame() - prevTimecode.getFrame(); if (fpsEstimate != -1) frameDiff = (frameDiff + fpsEstimate) % fpsEstimate; gap = frameDiff != 1; } else if (secDiff == 1) { if (fpsEstimate == -1) { if (tapeTimecode.getFrame() == 0) fpsEstimate = prevTimecode.getFrame() + 1; else gap = true; } else { int firstFrame = tapeTimecode.isDropFrame() && (sec % 60) == 0 && (sec % 600) != 0 ? 2 : 0; if (tapeTimecode.getFrame() != firstFrame || prevTimecode.getFrame() != fpsEstimate - 1) gap = true; } } else { gap = true; } return gap; }
private boolean isTimeGap(TapeTimecode prevTimecode, TapeTimecode tapeTimecode) { boolean gap = false; int sec = toSec(tapeTimecode); int secDiff = sec - toSec(prevTimecode); if (secDiff == 0) { int frameDiff = tapeTimecode.getFrame() - prevTimecode.getFrame(); if (fpsEstimate != -1) frameDiff = (frameDiff + fpsEstimate) % fpsEstimate; gap = frameDiff != 1; } else if (secDiff == 1) { if (fpsEstimate == -1) { if (tapeTimecode.getFrame() == 0) fpsEstimate = prevTimecode.getFrame() + 1; else gap = true; } else { int firstFrame = tapeTimecode.isDropFrame() && (sec % 60) == 0 && (sec % 600) != 0 ? 2 : 0; if (tapeTimecode.getFrame() != firstFrame || prevTimecode.getFrame() != fpsEstimate - 1) gap = true; } } else { gap = true; } return gap; }
private int toCounter(TapeTimecode tc, int fps) { int frames = toSec(tc) * fps + tc.getFrame(); if (tc.isDropFrame()) { long D = frames / 18000; long M = frames % 18000; frames -= 18 * D + 2 * ((M - 2) / 1800); } return frames; }
private int toCounter(TapeTimecode tc, int fps) { int frames = toSec(tc) * fps + tc.getFrame(); if (tc.isDropFrame()) { long D = frames / 18000; long M = frames % 18000; frames -= 18 * D + 2 * ((M - 2) / 1800); } return frames; }
private int toCounter(TapeTimecode tc, int fps) { int frames = toSec(tc) * fps + tc.getFrame(); if (tc.isDropFrame()) { long D = frames / 18000; long M = frames % 18000; frames -= 18 * D + 2 * ((M - 2) / 1800); } return frames; }
private void outTimecodeSample() throws IOException { if (sampleDuration > 0) { if (firstTimecode != null) { if (fpsEstimate == -1) fpsEstimate = prevTimecode.getFrame() + 1; TimecodeSampleEntry tmcd = TimecodeSampleEntry.createTimecodeSampleEntry((firstTimecode.isDropFrame() ? 1 : 0), _timescale, (int) (sampleDuration / tcFrames), fpsEstimate); sampleEntries.add(tmcd); ByteBuffer sample = ByteBuffer.allocate(4); sample.putInt(toCounter(firstTimecode, fpsEstimate)); sample.flip(); addFrame(MP4Packet.createMP4Packet(sample, samplePts, _timescale, sampleDuration, 0, FrameType.KEY, null, 0, samplePts, sampleEntries.size() - 1)); lower.add(new Edit(sampleDuration, samplePts, 1.0f)); } else { lower.add(new Edit(sampleDuration, -1, 1.0f)); } } }
private void outTimecodeSample() throws IOException { if (sampleDuration > 0) { if (firstTimecode != null) { if (fpsEstimate == -1) fpsEstimate = prevTimecode.getFrame() + 1; TimecodeSampleEntry tmcd = new TimecodeSampleEntry((firstTimecode.isDropFrame() ? 1 : 0), timescale, (int) (sampleDuration / tcFrames), fpsEstimate); sampleEntries.add(tmcd); ByteBuffer sample = ByteBuffer.allocate(4); sample.putInt(toCounter(firstTimecode, fpsEstimate)); sample.flip(); addFrame(new MP4Packet(sample, samplePts, timescale, sampleDuration, 0, true, null, samplePts, sampleEntries.size() - 1)); lower.add(new Edit(sampleDuration, samplePts, 1.0f)); } else { lower.add(new Edit(sampleDuration, -1, 1.0f)); } } }
private void outTimecodeSample() throws IOException { if (sampleDuration > 0) { if (firstTimecode != null) { if (fpsEstimate == -1) fpsEstimate = prevTimecode.getFrame() + 1; TimecodeSampleEntry tmcd = new TimecodeSampleEntry((firstTimecode.isDropFrame() ? 1 : 0), timescale, (int) (sampleDuration / tcFrames), fpsEstimate); sampleEntries.add(tmcd); ByteBuffer sample = ByteBuffer.allocate(4); sample.putInt(toCounter(firstTimecode, fpsEstimate)); sample.flip(); addFrame(new MP4Packet(sample, samplePts, timescale, sampleDuration, 0, true, null, samplePts, sampleEntries.size() - 1)); lower.add(new Edit(sampleDuration, samplePts, 1.0f)); } else { lower.add(new Edit(sampleDuration, -1, 1.0f)); } } }
@Override public void write(ByteBuffer bb) { BitWriter bw = new BitWriter(bb); if (timeCode == null) bw.writeNBit(0, 25); else { bw.write1Bit(timeCode.isDropFrame() ? 1 : 0); bw.writeNBit(timeCode.getHour(), 5); bw.writeNBit(timeCode.getMinute(), 6); bw.write1Bit(1); bw.writeNBit(timeCode.getSecond(), 6); bw.writeNBit(timeCode.getFrame(), 6); } bw.write1Bit(closedGop ? 1 : 0); bw.write1Bit(brokenLink ? 1 : 0); bw.flush(); }