Repository: opencv
Issue: VideoCapture gives different frame content if file is opened several times
Labels: bug,category: videoio

### System Information

opencv-python 4.10.0.84
Google Colab 
Python 3.10.12

### Detailed description

VideoCapture gives different frame content if file is opened several times. See code below.
This bug happens only on specific video files. Example video is uploaded.



### Steps to reproduce

### Source
```
import cv2
import numpy as np


def get_processed_images():
    cv2_vr = cv2.VideoCapture('/content/4.mp4')
    success, frame = cv2_vr.read()
    print('====', success, frame)
    return frame

v0 = get_processed_images()
v1 = get_processed_images()
v2 = get_processed_images()
v3 = get_processed_images()

print('Result', np.all(v0 == v1), np.all(v0 == v1), np.all(v0 == v2), np.all(v0 == v3))
```

### Output
```
==== True [[[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 ...

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]]
==== True [[[169 180  77]
  [210 148  85]
  [  0   0 169]
  ...
  [210 148  85]
  [  0   0 169]
  [180  77 210]]

 [[169 180  77]
  [210 148  85]
  [  0   0 169]
  ...
  [210 148  85]
  [  0   0 169]
  [180  77 210]]

 [[169 180  77]
  [210 148  85]
  [  0   0 169]
  ...
  [210 148  85]
  [  0   0  60]
  [181  77 210]]

 ...

 [[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [  0   0   0]
  [  0   0   0]
  [  0   0   0]]

 [[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [  0   0   0]
  [  0   0   0]
  [  0   0   0]]

 [[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [  0   0   0]
  [  0   0   0]
  [  0   0   0]]]
==== True [[[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [210 148  85]
  [  0   0 169]
  [180  77 210]]

 [[169 180  77]
  [210 148  85]
  [  0   0 169]
  ...
  [210 148  85]
  [  0   0 169]
  [180  77 210]]

 [[169 180  77]
  [210 148  85]
  [  0   0 169]
  ...
  [210 148  85]
  [  0   0 169]
  [180  77 210]]

 ...

 [[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [  0   0   0]
  [  0   0   0]
  [  0   0   0]]

 [[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [  0   0   0]
  [  0   0   0]
  [  0   0   0]]

 [[  0   0   0]
  [  0   0   0]
  [  0   0   0]
  ...
  [  0   0   0]
  [  0   0   0]
  [  0   0   0]]]
==== True [[[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 ...

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]]
Result False False False False
```

### Expected behaviour

You may see that frame contents are different. At first iteration several first rows are all zeros. At second iteration you may see non-zero values. 

Actually, the resulting values are different from run to run.

After kernel restart (or if the script is run from scratch), the first iteration always gives zeros.

**Download and check the following video file offline. It may not open in browser.**
[https://github.com/user-attachments/assets/31ed62f1-8cdc-483a-afe8-285a955b519b](https://github.com/user-attachments/assets/31ed62f1-8cdc-483a-afe8-285a955b519b)

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)