public static int timevalueToFrame ( TrakBox trak , long tv ) { TimeToSampleEntry [ ] tts = NodeBox . findFirstPath ( trak , TimeToSampleBox . class , Box . path ( "mdia.minf.stbl.stts" ) ) . getEntries ( ) ; int frame = 0 ; for ( int i = 0 ; tv > 0 && i < tts . length ; i ++ ) { long rem = tv / tts [ i ] . getSampleDuration ( ) ; tv -= tts [ i ] . getSampleCount ( ) * tts [ i ] . getSampleDuration ( ) ; frame += tv > 0 ? tts [ i ] . getSampleCount ( ) : rem ; } return frame ; }
Finds frame by timevalue