cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER) error

Environment:
CMake:3.28.0-rcl
GStreamer:1.22.6 MSVC 64bit
Opencv:4.8.0
Python:3.11.4
OS:Windows 10

I compiled opencv with Gstreamer support.
image

When I run the code below in terminal and cmd。Both worked well。
gst-launch-1.0 rtspsrc location=rtsp://admin:zjkjc123@10.23.105.116/LiveMedia/ch1/Media1/trackID=1 latency=20 ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink

Then,I run the code:

import os
import cv2
import ctypes

# os.add_dll_directory(r"C:\gstreamer\1.0\msvc_x86_64\bin")


pipeline = "rtspsrc location=rtsp://my-url ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert !  appsink"
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

while True:
    ret, frame = cap.read()
    if ret:
        frame_new = cv2.resize(frame, (640, 480))
        cv2.imshow('frame', frame_new)
    else:
        print("ret false")
        break
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

The error is:

(python.exe:19968): GStreamer-WARNING **: 10:02:15.827: Failed to load plugin 'C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gstgio.dll': 'C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gstgio.dll': �Ҳ���ָ���ij���

(python.exe:19968): GStreamer-WARNING **: 10:02:15.829: Failed to load plugin 'C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gsttcp.dll': 'C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gsttcp.dll': �Ҳ���ָ���ij���
(python.exe:35280): GStreamer-WARNING **: 10:05:26.387: Failed to load plugin 'C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gsttypefindfunctions.dll': 'C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gsttypefindfunctions.dll': �Ҳ���ָ���ij���

However,I can find these dll in the path:C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0,also in gstreamer installation path。I copy these dlls to my code’s dictionary,and add load code:

dll1 = "./gstgio.dll"
dll2 = './gsttcp.dll'
my_dll1 = ctypes.CDLL(dll1)
my_dll2 = ctypes.CDLL(dll2)
# dll3 = './gsttypefindfunctions.dll'
# my_dll3 = ctypes.WinDLL(dll3)

dll1 & dll2 were loaded,gsttypefindfunctions.dll were not:

my_dll3 = ctypes.WinDLL(dll3)
 ^^^^^^^^^^^^^^^^^^^ 
File "C:\Users\admin\anaconda3\envs\jdswj\Lib\ctypes\__init__.py", line 376, in __init__ self._handle = _dlopen(self._name, mode)
 ^^^^^^^^^^^^^^^^^^^^^^^^^ 
OSError: [WinError 127] 找不到指定的程序。

I delete dll3 in the path:C:\Users\admin\Anaconda3\Library\lib\gstreamer-1.0\gsttypefindfunctions.dll。
Now,the error is:

[ WARN:0@30.032] global cap_gstreamer.cpp:1697 cv::GStreamerCapture::open OpenCV | GStreamer warning: unable to query duration of stream

(python.exe:32464): GStreamer-CRITICAL **: 10:11:58.583: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(python.exe:32464): GStreamer-CRITICAL **: 10:11:58.583: gst_structure_get_int: assertion 'structure != NULL' failed
[ WARN:0@30.032] global cap_gstreamer.cpp:1707 cv::GStreamerCapture::open OpenCV | GStreamer warning: cannot query video width/height

(python.exe:32464): GStreamer-CRITICAL **: 10:11:58.583: gst_structure_get_fraction: assertion 'structure != NULL' failed
[ WARN:0@30.032] global cap_gstreamer.cpp:1713 cv::GStreamerCapture::open OpenCV | GStreamer warning: cannot query video fps
[ WARN:0@30.032] global cap_gstreamer.cpp:1728 cv::GStreamerCapture::open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

(python.exe:32464): GStreamer-CRITICAL **: 10:13:03.603: gst_sample_get_caps: assertion 'GST_IS_SAMPLE (sample)' failed
[ERROR:0@95.052] global cap_gstreamer.cpp:925 cv::GStreamerCapture::retrieveVideoFrame GStreamer: gst_sample_get_caps() returns NULL

So, How to solve it?could anyone help me