I recently needed to extract all the frames from a video and thought that maybe others would find it useful as well. This is assuming one has OpenCV installed.
int fileNumber = 0;
string filename = imagepath;
string fileformat = ".jpg";
string filenumber = to_string(fileNumber);
string fullFileName = filename + filenumber + fileformat;
This code will read the video from the videopath and extract all of its image and save it to the imagepath. All the frames will be numbered from 0 to n where n is the number of frames in the video. You can tinker around the code for your purpose. If you like it do leave a comment. 🙂