I am not that familiar with OpenCV. However, after this line, you will have the img stored in the variable as a jpeg image. You may have to write as bytes. I don’t know the equivalent in OpenCV.
There are issues with this approach:
the frames will be coming in at around 30fps, so you’ll get a lot of frames. you’ll need to increment the filenames
each frame will be a lower resolution than if you took an image
each frame will not have spherical metadata. Some viewers may not be able to display image without the metadata
For a test, you can use this tool to inject the spatial media metadata back into the image frame.
This is an example in dart of saving the frame.
Multiple frames
Instead of extracting the frame, does your application allow you to take an image of the scene that you want?
If not, can you take an 8K 2fps video and then extract the frames from the video file?
If you advise on your use case, we may be able to provide more ideas.