I-VideoCapture inikela umsebenzi wenethiwekhi kubackend eyikhethile. Nge-OpenCV build ene-FFmpeg, i-URL yevidiyo ye-HTTP ingathola inketho ye-http_proxy ye-FFmpeg ngendawo yezinketho zokuthwebula:

import os
os.environ['OPENCV_FFMPEG_CAPTURE_OPTIONS'] = (
    'http_proxy;http://proxy.example:8080'
)

import cv2
capture = cv2.VideoCapture(
    'http://media.example/video.mp4',
    cv2.CAP_FFMPEG,
)
try:
    if not capture.isOpened():
        raise RuntimeError('Video input did not open')
    ok, frame = capture.read()
finally:
    capture.release()

I-backend ye-FFmpeg ye-OpenCV ihlaziya intambo yezinketho njengezibhangqwana zokhiye;inani, kunomugqa oqondile phakathi kwezibhangqwana eziningi. Isibonelo sibeka indawo ngaphambi kokungenisa i-OpenCV futhi sicela ngokusobala i-CAP_FFMPEG.

I-FFmpeg ibhala i-http_proxy njenge-URL ye-proxy yephrothokholi ye-HTTP; uhlu lwe-HTTP proxy lunikeza abazokhetha umgwaqo wemidiya ye-HTTP womphakathi. Lokho akulungiseleli i-backend yokuthwebula engahlobene, ikhamera yasendaweni noma ithrafikhi ye-RTSP/UDP engafanele.

Hlola i-backend namakhono e-FFmpeg e-OpenCV build yangempela. Inani le-proxy alikwazi ukwengeza i-backend noma idikhoda engekho.

Ukuvula okokufaka kwemidiya nokudikoda ifreyimu nakho kuyimiphumela ehlukene. Ukwehluleka kwekhodekhi ngemva kokulanda okuphumelelayo akufanele kubikwe njengobufakazi bokuthi i-proxy ibingafinyeleleki.

Izihloko ezihlobene