Congratulations on stumbling into a colossally deep rabbit hole.
The issue is that any photo you find online or elsewhere, unless you are using the camera “raw” encoded file, has a number of twists and turns applied to it. That is, the still image from a camera, even if directly off of the card, has been manipulated.
Inverting the situation makes it easier to comprehend. That is, if we were to look outside a window, we could draw a grid on the window and capture the emission of each smaller window “pixel” region. To “play that back”, we would use a projector that was capable of projecting that exact dynamic range onto a wall. Of course, no such projector exists.
So your camera is bending the scene values it has captured from the sensor, and also likely applying some other aesthetic twists. Normally, for a “Hey that’s a nice photo!” everything is great. For compositing CGI however, it’s nothing but problems as the photo and the CGI components are warped entirely differently. To do things “properly”, the entirety of the warping stack would need to be undone and aligned to a single ground truth.
So how to take a random photo or video found somewhere and merge CGI into it? You can’t! Not without massaging and guessing and other estimates. Even after all of that, you can’t do it ideally, and still will end up with suboptimal results.
If you have access to the camera raw encoded file, it’s quite easy.
The best you can do is to pretend the image is encoded a certain way that it is not, and use that cheated hack to fudge the values. At 8 bit per channel however, you’ll also likely face other issues.
Leaving it at that until more information is available. For those who haven’t read it, Paul Chamber’s has an excellent series of blog posts that dives into the nuances of compositing CGI elements into a captured shot that are well worth reading. Everything from proximity lighting to understanding how some consumer cameras encode the scene. Great series.