public long rescale(long tv, long ts) { return (tv * getTimescale()) / ts; }
public long rescale(long tv, long ts) { return (tv * getTimescale()) / ts; }
public long rescale(long tv, long ts) { return (tv * getTimescale()) / ts; }
public RationalLarge getDuration() { return new RationalLarge(box.getMediaDuration(), box.getTimescale()); }
public RationalLarge getDuration() { return new RationalLarge(box.getMediaDuration(), box.getTimescale()); }
public RationalLarge getDuration() { return new RationalLarge(box.getMediaDuration(), box.getTimescale()); }
/** * Calculates and formats standard time as in Quicktime player * * @param movie * @param mediaFrameNo * @return */ public static String qtPlayerTime(MovieBox movie, int mediaFrameNo) { TrakBox videoTrack = movie.getVideoTrack(); long editedTv = mediaToEdited(videoTrack, frameToTimevalue(videoTrack, mediaFrameNo), movie.getTimescale()); int sec = (int) (editedTv / videoTrack.getTimescale()); return String.format("%02d", sec / 3600) + "_" + String.format("%02d", (sec % 3600) / 60) + "_" + String.format("%02d", sec % 60); }
/** * Calculates and formats standard time as in Quicktime player * * @param movie * @param mediaFrameNo * @return */ public static String qtPlayerTime(MovieBox movie, int mediaFrameNo) { TrakBox videoTrack = movie.getVideoTrack(); long editedTv = mediaToEdited(videoTrack, frameToTimevalue(videoTrack, mediaFrameNo), movie.getTimescale()); int sec = (int) (editedTv / videoTrack.getTimescale()); return String.format("%02d", sec / 3600) + "_" + String.format("%02d", (sec % 3600) / 60) + "_" + String.format("%02d", sec % 60); }
/** * Calculates and formats standard time as in Quicktime player * * @param movie * @param mediaFrameNo * @return */ public static String qtPlayerTime(MovieBox movie, int mediaFrameNo) { TrakBox videoTrack = movie.getVideoTrack(); long editedTv = mediaToEdited(videoTrack, frameToTimevalue(videoTrack, mediaFrameNo), movie.getTimescale()); int sec = (int) (editedTv / videoTrack.getTimescale()); return String.format("%02d", sec / 3600) + "_" + String.format("%02d", (sec % 3600) / 60) + "_" + String.format("%02d", sec % 60); }
/** * Splits track on the timevalue specified * * @param movie * @param track * @param tvMv * @return */ public static Pair<List<Edit>> split(MovieBox movie, TrakBox track, long tvMv) { return splitEdits(track.getEdits(), new Rational(track.getTimescale(), movie.getTimescale()), tvMv); }
public int timeCodeToFrameNo(String timeCode) throws Exception { if (isValidTimeCode(timeCode)) { int movieFrame = parseTimecode(timeCode.trim()) - sampleCache[0]; int frameRate = tse.getNumFrames(); long framesInTimescale = movieFrame * tse.getTimescale(); long mediaToEdited = QTTimeUtil.mediaToEdited(box, framesInTimescale / frameRate, movie.getTimescale()) * frameRate; return (int) (mediaToEdited / box.getTimescale()); } return -1; }
public int timeCodeToFrameNo(String timeCode) throws Exception { if (isValidTimeCode(timeCode)) { int movieFrame = parseTimecode(timeCode.trim()) - sampleCache[0]; int frameRate = tse.getNumFrames(); long framesInTimescale = movieFrame * tse.getTimescale(); long mediaToEdited = QTTimeUtil.mediaToEdited(box, framesInTimescale / frameRate, movie.getTimescale()) * frameRate; return (int) (mediaToEdited / box.getTimescale()); } return -1; }
public int timeCodeToFrameNo(String timeCode) throws Exception { if (isValidTimeCode(timeCode)) { int movieFrame = parseTimecode(timeCode.trim()) - sampleCache[0]; int frameRate = tse.getNumFrames(); long framesInTimescale = movieFrame * tse.getTimescale(); long mediaToEdited = QTTimeUtil.mediaToEdited(box, framesInTimescale / frameRate, movie.getTimescale()) * frameRate; return (int) (mediaToEdited / box.getTimescale()); } return -1; }
public static int tv2QTFrameNo(MovieBox movie, long tv) { TrakBox videoTrack = movie.getVideoTrack(); TrakBox timecodeTrack = movie.getTimecodeTrack(); if (timecodeTrack != null && BoxUtil.containsBox2(videoTrack, "tref", "tmcd")) { return timevalueToTimecodeFrame(timecodeTrack, new RationalLarge(tv, videoTrack.getTimescale()), movie.getTimescale()); } else { return timevalueToFrame(videoTrack, tv); } }
public static int tv2QTFrameNo(MovieBox movie, long tv) { TrakBox videoTrack = movie.getVideoTrack(); TrakBox timecodeTrack = movie.getTimecodeTrack(); if (timecodeTrack != null && Box.findFirst(videoTrack, "tref", "tmcd") != null) { return timevalueToTimecodeFrame(timecodeTrack, new RationalLarge(tv, videoTrack.getTimescale()), movie.getTimescale()); } else { return timevalueToFrame(videoTrack, tv); } }
public static int tv2QTFrameNo(MovieBox movie, long tv) { TrakBox videoTrack = movie.getVideoTrack(); TrakBox timecodeTrack = movie.getTimecodeTrack(); if (timecodeTrack != null && Box.findFirst(videoTrack, "tref", "tmcd") != null) { return timevalueToTimecodeFrame(timecodeTrack, new RationalLarge(tv, videoTrack.getTimescale()), movie.getTimescale()); } else { return timevalueToFrame(videoTrack, tv); } }
public MP4Packet getTimecode(MP4Packet pkt) throws IOException { long tv = QTTimeUtil.editedToMedia(box, box.rescale(pkt.getPts(), pkt.getTimescale()), movie.getTimescale()); int sample; int ttsInd = 0, ttsSubInd = 0; for (sample = 0; sample < sampleCache.length - 1; sample++) { int dur = timeToSamples[ttsInd].getSampleDuration(); if (tv < dur) break; tv -= dur; ttsSubInd++; if (ttsInd < timeToSamples.length - 1 && ttsSubInd >= timeToSamples[ttsInd].getSampleCount()) ttsInd++; } int frameNo = (int) ((((2 * tv * tse.getTimescale()) / box.getTimescale()) / tse.getFrameDuration()) + 1) / 2; return new MP4Packet(pkt, getTimecode(getTimecodeSample(sample), frameNo, tse)); }
public MP4Packet getTimecode(MP4Packet pkt) throws IOException { long tv = QTTimeUtil.editedToMedia(box, box.rescale(pkt.getPts(), pkt.getTimescale()), movie.getTimescale()); int sample; int ttsInd = 0, ttsSubInd = 0; for (sample = 0; sample < sampleCache.length - 1; sample++) { int dur = timeToSamples[ttsInd].getSampleDuration(); if (tv < dur) break; tv -= dur; ttsSubInd++; if (ttsInd < timeToSamples.length - 1 && ttsSubInd >= timeToSamples[ttsInd].getSampleCount()) ttsInd++; } int frameNo = (int) ((((2 * tv * tse.getTimescale()) / box.getTimescale()) / tse.getFrameDuration()) + 1) / 2; return MP4Packet.createMP4PacketWithTimecode(pkt, _getTimecode(getTimecodeSample(sample), frameNo, tse)); }
public MP4Packet getTimecode(MP4Packet pkt) throws IOException { long tv = QTTimeUtil.editedToMedia(box, box.rescale(pkt.getPts(), pkt.getTimescale()), movie.getTimescale()); int sample; int ttsInd = 0, ttsSubInd = 0; for (sample = 0; sample < sampleCache.length - 1; sample++) { int dur = timeToSamples[ttsInd].getSampleDuration(); if (tv < dur) break; tv -= dur; ttsSubInd++; if (ttsInd < timeToSamples.length - 1 && ttsSubInd >= timeToSamples[ttsInd].getSampleCount()) ttsInd++; } int frameNo = (int) ((((2 * tv * tse.getTimescale()) / box.getTimescale()) / tse.getFrameDuration()) + 1) / 2; return new MP4Packet(pkt, getTimecode(getTimecodeSample(sample), frameNo, tse)); }
public AbstractMP4DemuxerTrack(TrakBox trak) { no = trak.getTrackHeader().getNo(); type = MP4Demuxer.getTrackType(trak); sampleEntries = Box.findAll(trak, SampleEntry.class, "mdia", "minf", "stbl", "stsd", null); 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(); sampleToChunks = stsc.getSampleToChunk(); chunkOffsets = stco != null ? stco.getChunkOffsets() : co64.getChunkOffsets(); for (TimeToSampleEntry ttse : timeToSamples) { duration += ttse.getSampleCount() * ttse.getSampleDuration(); } box = trak; timescale = trak.getTimescale(); }