/** * Seeks to a previous key frame prior or on the given frame, if the track is * not seekable returns 0. * * @param frame * A frame to seek * @return Frame number of a key frame or 0 if the track is not seekable. * @throws IOException */ protected int seekToKeyFrame(int frame) throws IOException { if (videoInputTrack instanceof SeekableDemuxerTrack) { SeekableDemuxerTrack seekable = (SeekableDemuxerTrack) videoInputTrack; seekable.gotoSyncFrame(frame); return (int) seekable.getCurFrame(); } else { Logger.warn("Can not seek in " + videoInputTrack + " container."); return -1; } }