correct keep_frames function algorithm and parameter cut_percent