Opencv build from source read video slower than using pip install opencv-python

I’ve build opencv c++ and python from source but it run slower than opencv-python which i’ve install through pip install.

my code bendmark run time above

import cv2
import time


cap = cv2.VideoCapture("file.mp4")
fps = 0.0
prev = time.time()
while True:
    now = time.time()
    fps = (fps*FPS_SMOOTHING + (1/(now - prev))*(1.0 - FPS_SMOOTHING))
    prev = now

    print("fps: {:.1f}".format(fps))

    got, frame =
    if not got: 

I’ve build opencv again and python code can run the same fps with using pip install. But using c++ still slower than python?