From a7a5b85f4e0f90e5f2b41149f6368b185cb7b59f Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Sat, 3 May 2025 09:46:48 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=B5=8B=E7=BB=98=E7=AB=99=E9=87=87?= =?UTF-8?q?=E9=9B=86.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/测绘站采集.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/py/测绘站采集.py b/py/测绘站采集.py index 82d7090..3970be0 100644 --- a/py/测绘站采集.py +++ b/py/测绘站采集.py @@ -90,21 +90,24 @@ def validate_video(url, mcast): print(f"正在验证: {video_url}") try: - # 设置超时参数 + # 使用 FFmpeg 作为后端来打开视频流 cap = cv2.VideoCapture(video_url, cv2.CAP_FFMPEG) - cap.set(cv2.CAP_PROP_TIMEOUT, 5000) # 5秒超时 - if cap.isOpened(): - width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) - height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) - cap.release() - return width > 0 and height > 0 - return False + # 设置超时参数 + ret, frame = cap.read() + if not ret: + print(f"视频验证失败: 无法读取帧") + return False + + # 检查视频流是否有效 + width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) + height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) + cap.release() + return width > 0 and height > 0 except Exception as e: print(f"视频验证异常: {str(e)}") return False - def main(): # 获取需要处理的文件列表 files = [f.split('.')[0] for f in os.listdir('rtp') if f.endswith('.txt')] @@ -127,7 +130,7 @@ def main(): continue # 构造搜索请求 - search_txt = f'"udpxy" && country="CN" && region="{province}"' + search_txt = f'"udpxy" && country="CN" && region="{province}" && aXNfZG9tYWluPXRydWU%3D' encoded_query = base64.b64encode(search_txt.encode()).decode() search_url = f'https://fofa.info/result?qbase64={encoded_query}'