2026-05-18-20-18-20 对齐结果视频时长
This commit is contained in:
@@ -2,7 +2,7 @@ from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from backend.main import app
|
||||
from backend.main import ROOT, app
|
||||
from scripts.generate_sample import make_frame
|
||||
|
||||
import cv2
|
||||
@@ -62,12 +62,25 @@ def test_segment_video_and_compare_frame(tmp_path: Path):
|
||||
assert payload["kind"] == "video"
|
||||
assert payload["video_url"].endswith(".mp4")
|
||||
assert payload["source_fps"] > 0
|
||||
assert payload["result_fps"] == 8.0
|
||||
assert payload["result_fps"] == payload["source_fps"]
|
||||
assert payload["result_duration"] == payload["duration"]
|
||||
assert len(payload["frames"]) == 3
|
||||
first_frame = payload["frames"][0]
|
||||
assert first_frame["source_time"] == 0.0
|
||||
assert first_frame["result_time"] == 0.0
|
||||
assert first_frame["result_index"] == 0
|
||||
second_frame = payload["frames"][1]
|
||||
assert second_frame["result_time"] == second_frame["source_time"]
|
||||
assert second_frame["result_index"] == second_frame["frame_index"]
|
||||
|
||||
result_path = ROOT / payload["video_url"].lstrip("/")
|
||||
result_capture = cv2.VideoCapture(str(result_path))
|
||||
assert result_capture.isOpened()
|
||||
result_frames = int(result_capture.get(cv2.CAP_PROP_FRAME_COUNT) or 0)
|
||||
result_fps = float(result_capture.get(cv2.CAP_PROP_FPS) or 0)
|
||||
result_capture.release()
|
||||
assert result_frames == 18
|
||||
assert abs((result_frames / result_fps) - payload["duration"]) < 0.25
|
||||
|
||||
with video_path.open("rb") as handle:
|
||||
compare = client.post(
|
||||
|
||||
Reference in New Issue
Block a user