-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_upscale.py
More file actions
59 lines (47 loc) · 1.92 KB
/
test_upscale.py
File metadata and controls
59 lines (47 loc) · 1.92 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
import os
import subprocess
import sys
# Add src to python path so we can import video_processing_engine
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
# Add ffmpeg to PATH for subprocess to find it
ffmpeg_bin = os.path.join(os.path.dirname(__file__), 'ffmpeg', 'bin')
os.environ["PATH"] = ffmpeg_bin + os.pathsep + os.environ["PATH"]
from video_processing_engine import VideoProcessingEngine
def create_test_video(path="input.mp4"):
print(f"Creating test video at {path}...")
cmd = [
"ffmpeg", "-y",
"-f", "lavfi",
"-i", "testsrc=duration=1:size=640x360:rate=30",
"-c:v", "libx264",
path
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
print(f"FFmpeg error generating test file: {result.stderr}")
return False
print("Test video created.")
return True
def test_upscale():
if not create_test_video():
return
engine = VideoProcessingEngine()
# We need to simulate self.sr_engine being not None for the upscaling to happen
print(f"SR Engine initialized: {engine.sr_engine is not None}")
# Force sr_engine to true to trigger the FFmpeg branch
if engine.sr_engine is None:
print("Forcing sr_engine to True for testing the FFmpeg upscaling parameters...")
engine.sr_engine = True
print("Starting render with AI upscale...")
success = engine.render("input.mp4", "output_upscaled.mp4", width=1920, height=1080, use_ai_upscale=True)
if success:
print("Export successful!")
if os.path.exists("output_upscaled.mp4"):
size = os.path.getsize("output_upscaled.mp4")
print(f"Output file size: {size} bytes")
else:
print("output_upscaled.mp4 not found on disk despite returning success.")
else:
print("Export failed.")
if __name__ == "__main__":
test_upscale()