Divide video file into images and Generate video from images - C++