src/main/java/org/jcodec/containers/mp4/QTTimeUtil.java
public static long frameToTimevalue(TrakBox trak, int frameNumber) {
        TimeToSampleBox stts = NodeBox.findFirstPath(trak, TimeToSampleBox.class, Box.path("mdia.minf.stbl.stts"));
        TimeToSampleEntry[] timeToSamples = stts.getEntries();
        long pts = 0;
        int sttsInd = 0, sttsSubInd = frameNumber;
        while (sttsSubInd >= timeToSamples[sttsInd].getSampleCount()) {
            sttsSubInd -= timeToSamples[sttsInd].getSampleCount();
            pts += timeToSamples[sttsInd].getSampleCount() * timeToSamples[sttsInd].getSampleDuration();
            sttsInd++;
        }

        return pts + timeToSamples[sttsInd].getSampleDuration() * sttsSubInd;
    }
public static long frameToTimevalue(TrakBox trak, int frameNumber) {
        TimeToSampleBox stts = NodeBox.findFirstPath(trak, TimeToSampleBox.class, Box.path("mdia.minf.stbl.stts"));
        TimeToSampleEntry[] timeToSamples = stts.getEntries();
        long pts = 0;
        int sttsInd = 0, sttsSubInd = frameNumber;
        while (sttsSubInd >= timeToSamples[sttsInd].getSampleCount()) {
            sttsSubInd -= timeToSamples[sttsInd].getSampleCount();
            pts += timeToSamples[sttsInd].getSampleCount() * timeToSamples[sttsInd].getSampleDuration();
            sttsInd++;
        }

        return pts + timeToSamples[sttsInd].getSampleDuration() * sttsSubInd;
    }
public static long frameToTimevalue ( TrakBox trak , int frameNumber ) { TimeToSampleBox stts = NodeBox . findFirstPath ( trak , TimeToSampleBox . class , Box . path ( "mdia.minf.stbl.stts" ) ) ; TimeToSampleEntry [ ] timeToSamples = stts . getEntries ( ) ; long pts = 0 ; int sttsInd = 0 , sttsSubInd = frameNumber ; while ( sttsSubInd >= timeToSamples [ sttsInd ] . getSampleCount ( ) ) { sttsSubInd -= timeToSamples [ sttsInd ] . getSampleCount ( ) ; pts += timeToSamples [ sttsInd ] . getSampleCount ( ) * timeToSamples [ sttsInd ] . getSampleDuration ( ) ; sttsInd ++ ; } return pts + timeToSamples [ sttsInd ] . getSampleDuration ( ) * sttsSubInd ; }
Finds timevalue of a frame number

might be an expensive operation sinse it traverses compressed time to
sample table

@param frameNumber
@return
Finds timevalue of a frame number