Spaces:
Running
Running
| import json | |
| import logging | |
| from pathlib import Path | |
| from video_assembler import assemble_video | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| # Load the JSON | |
| json_path = "output/ai_tools_20260322_095831.json" | |
| with open(json_path, "r") as f: | |
| video_json = json.load(f) | |
| # Mock audio results (first 3 scenes only for speed) | |
| audio_results = [ | |
| {"scene_number": 1, "path": "assets/audio/scene_01.mp3", "duration": 4.6}, | |
| {"scene_number": 2, "path": "assets/audio/scene_02.mp3", "duration": 3.1}, | |
| {"scene_number": 3, "path": "assets/audio/scene_03.mp3", "duration": 3.5}, | |
| ] | |
| # Mock media results (first 3 scenes) | |
| # I'll find existing clips in assets/clips | |
| clips_dir = Path("assets/clips") | |
| media_results = [] | |
| for i in range(1, 4): | |
| found = list(clips_dir.glob(f"scene_{i:02d}_*.mp4")) | |
| if found: | |
| media_results.append({ | |
| "scene_number": i, | |
| "path": str(found[0]), | |
| "type": "video", | |
| "approved": True | |
| }) | |
| # Trim JSON to 3 scenes | |
| video_json["scenes"] = video_json["scenes"][:3] | |
| logger.info("Starting standalone assembly test...") | |
| try: | |
| output_path = assemble_video( | |
| video_json=video_json, | |
| audio_results=audio_results, | |
| media_results=media_results, | |
| editing_style="social_media", | |
| output_filename="assembly_verify_test.mp4" | |
| ) | |
| print(f"\nSUCCESS: Video assembled at {output_path}") | |
| except Exception as e: | |
| import traceback | |
| print(f"\nFAILURE: Assembly failed!") | |
| traceback.print_exc() | |