private long findFrame ( RandomAccessInputStream raf , int offset ) throws IOException { long loc = - 1 ; raf . seek ( offset ) ; while ( loc == - 1 ) { byte test = raf . readByte ( ) ; if ( ( test & 0xFF ) == 0xFF ) { test = raf . readByte ( ) ; if ( ( test & 0xE0 ) == 0xE0 ) { return raf . getFilePointer ( ) - 2 ; } } } return - 1 ; }
Searches through the file and finds the first occurrence of an mpeg frame . Returns the location of the header of the frame .