Avoid reading extra one frame at the end of the input file.