-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_native_gui_env.py
More file actions
154 lines (128 loc) · 4.51 KB
/
Copy pathtest_native_gui_env.py
File metadata and controls
154 lines (128 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""
GUIと同じ環境でNativeStreamerWrapperをテストするスクリプト
GUI環境を再現して、DLLロードの問題を診断する
"""
import sys
import os
import traceback
# 出力エンコーディング設定
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
# GUIと同じようにSpout関連をインポート
print("=" * 60)
print("GUIと同じ環境でテスト")
print("=" * 60)
# Step 1: GUIと同じインポート順序を再現
print("\n[Step 1] GUIと同じインポートを実行...")
try:
import customtkinter as ctk
print(" ✓ customtkinter imported")
except ImportError as e:
print(f" ✗ customtkinter: {e}")
try:
from PIL import Image
print(" ✓ PIL imported")
except ImportError as e:
print(f" ✗ PIL: {e}")
try:
import SpoutGL
print(" ✓ SpoutGL imported")
except ImportError as e:
print(f" ✗ SpoutGL: {e}")
try:
from OpenGL import GL
print(" ✓ OpenGL imported")
except ImportError as e:
print(f" ✗ OpenGL: {e}")
try:
import numpy as np
print(" ✓ numpy imported")
except ImportError as e:
print(f" ✗ numpy: {e}")
# Step 2: Spout Sender作成(GUIと同じ)
print("\n[Step 2] SpoutSender作成...")
try:
spout_sender = SpoutGL.SpoutSender()
spout_sender.setSenderName("TestSender")
print(" ✓ SpoutSender created")
except Exception as e:
print(f" ✗ SpoutSender: {e}")
spout_sender = None
# Step 3: DLLロードテスト(直接)
print("\n[Step 3] DLL直接ロードテスト...")
try:
import ctypes
from pathlib import Path
dll_path = Path("F:/ytdlpSpout/cpp/build/vs2022/bin/Release/ytdlpspout.dll")
dll_dir = str(dll_path.parent)
print(f" DLL path: {dll_path}")
print(f" DLL exists: {dll_path.exists()}")
# PATH設定
os.environ["PATH"] = dll_dir + os.pathsep + os.environ.get("PATH", "")
# DLL directory追加
if hasattr(os, 'add_dll_directory'):
os.add_dll_directory(dll_dir)
# 依存DLLを先にロード
dep_dlls = [
"zlib1.dll", "avutil-59.dll", "swresample-5.dll",
"avcodec-61.dll", "avformat-61.dll", "swscale-8.dll",
"fmt.dll", "spdlog.dll", "libcurl.dll", "Spout.dll"
]
for dep in dep_dlls:
dep_path = dll_path.parent / dep
if dep_path.exists():
try:
ctypes.WinDLL(str(dep_path))
print(f" ✓ {dep} preloaded")
except Exception as e:
print(f" ✗ {dep}: {e}")
# メインDLLロード
lib = ctypes.WinDLL(str(dll_path))
lib.ytdlpspout_version.restype = ctypes.c_char_p
version = lib.ytdlpspout_version().decode()
print(f" ✓ ytdlpspout.dll loaded, version: {version}")
except Exception as e:
print(f" ✗ DLL load failed: {e}")
traceback.print_exc()
# Step 4: YtdlpSpoutNativeテスト
print("\n[Step 4] YtdlpSpoutNative初期化テスト...")
try:
from python.ytdlpspout_native import YtdlpSpoutNative
native = YtdlpSpoutNative()
print(f" ✓ YtdlpSpoutNative created, version: {native.version}")
except Exception as e:
print(f" ✗ YtdlpSpoutNative failed: {e}")
traceback.print_exc()
# Step 5: NativeStreamerWrapperテスト
print("\n[Step 5] NativeStreamerWrapper テスト...")
try:
from python.native_streamer_wrapper import NativeStreamerWrapper
import time
import threading
wrapper = NativeStreamerWrapper(
video_url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
sender_name="TestNative",
log_cb=lambda msg: print(f" [LOG] {msg}")
)
print(" Starting wrapper...")
wrapper.start()
# 5秒待機
for i in range(10):
time.sleep(0.5)
status = f"playing={wrapper.is_playing}, vod={wrapper.is_vod}, frame={'Yes' if wrapper.latest_frame_bgr is not None else 'No'}"
print(f" [{i*0.5:.1f}s] {status}")
if wrapper.latest_frame_bgr is not None:
print(f" Frame shape: {wrapper.latest_frame_bgr.shape}")
break
print(" Stopping wrapper...")
wrapper.stop()
print(" ✓ Test completed")
except Exception as e:
print(f" ✗ NativeStreamerWrapper failed: {e}")
traceback.print_exc()
# Cleanup
if spout_sender:
spout_sender.releaseSender()
print("\n[Cleanup] SpoutSender released")
print("\n" + "=" * 60)
print("テスト完了")
print("=" * 60)