that code is meant to convert the input mts file into images, but it will not work on a broken stream.