How to find/detect the real video resolution?
If you satisfy with your video outputting on a 1080p device, the original video aspect ratio has to be 16:9; therefore, the original video has no choice to be 480p, 720p, or 1080p. The next step is the transformation, there are plenty of filters you can choose to determine it is 480p; on the other hand, choosing transforming to 720p or no transformation, stay in 1080p, depends on contours detection on white background.
As you mentioned ffmpeg and opencv, you should find such APIs easily.