Spaces:
Sleeping
Sleeping
""" | |
Frame Bridge - ใใใๅฆ็ใในใ็จในใฏใชใใ | |
ใใฉใซใๅ ใฎๅ็ปใใกใคใซใ้ ๆฌก็ตๅใใใในใในใฏใชใใ | |
""" | |
import os | |
import sys | |
import argparse | |
from pathlib import Path | |
import sys | |
sys.path.append('..') | |
from src.frame_bridge import BatchProcessor | |
def main(): | |
"""ใกใคใณๅฆ็""" | |
parser = argparse.ArgumentParser(description="Frame Bridge - ใใใๅ็ป็ตๅ") | |
parser.add_argument("--input", "-i", default="examples/assets/example/REI/input", help="ๅ ฅๅใใฉใซใ (ใใใฉใซใ: examples/assets/example/REI/input)") | |
parser.add_argument("--output", "-o", default="examples/assets/example/REI/output", help="ๅบๅใใฉใซใ (ใใใฉใซใ: examples/assets/example/REI/output)") | |
parser.add_argument("--exclude-edge", action="store_true", default=True, help="ๆๅใจๆๅพใฎใใฌใผใ ใ้คๅค (ใใใฉใซใ: True)") | |
parser.add_argument("--include-edge", action="store_true", help="ๆๅใจๆๅพใฎใใฌใผใ ใๅซใใ") | |
parser.add_argument("--mode", "-m", choices=["sequential", "pairwise"], default="sequential", | |
help="็ตๅใขใผใ: sequential(้ ๆฌก็ตๅ) ใพใใฏ pairwise(ใใข็ตๅ)") | |
parser.add_argument("--filename", "-f", default="merged_sequence.mp4", help="ๅบๅใใกใคใซๅ (sequentialใขใผใใฎใฟ)") | |
args = parser.parse_args() | |
print("๐ฌ Frame Bridge - ใใใๅฆ็ใในใ") | |
print("=" * 60) | |
print(f"๐ ๅ ฅๅใใฉใซใ: {args.input}") | |
print(f"๐ ๅบๅใใฉใซใ: {args.output}") | |
print(f"๐ ๅฆ็ใขใผใ: {args.mode}") | |
if args.mode == "sequential": | |
print(f"๐ ๅบๅใใกใคใซๅ: {args.filename}") | |
print() | |
# ๅ ฅๅใใฉใซใใฎๅญๅจใใงใใฏ | |
if not os.path.exists(args.input): | |
print(f"โ ๅ ฅๅใใฉใซใใ่ฆใคใใใพใใ: {args.input}") | |
return | |
# ใจใใธใใฌใผใ ้คๅค่จญๅฎ | |
exclude_edge_frames = not args.include_edge if args.include_edge else args.exclude_edge | |
print(f"๐ฏ ใจใใธใใฌใผใ ้คๅค: {'ๆๅน' if exclude_edge_frames else '็กๅน'}") | |
print() | |
# ใใใใใญใปใใตใๅๆๅ | |
processor = BatchProcessor(output_dir=args.output, exclude_edge_frames=exclude_edge_frames) | |
# ๅ็ปใใกใคใซใฎ็ขบ่ช | |
video_files = processor.get_video_files(args.input) | |
if len(video_files) < 2: | |
print("โ ็ตๅใซใฏๆไฝ2ใคใฎๅ็ปใใกใคใซใๅฟ ่ฆใงใ") | |
return | |
print(f"โ ๆคๅบใใใๅ็ปใใกใคใซ: {len(video_files)}ๅ") | |
for i, file in enumerate(video_files): | |
print(f" {i+1}. {os.path.basename(file)}") | |
print() | |
# ๅฆ็ใขใผใใซๅฟใใฆๅฎ่ก | |
if args.mode == "sequential": | |
print("๐ ้ ๆฌก็ตๅๅฆ็ใ้ๅง...") | |
success, final_output, results = processor.process_sequential_merge(args.input, args.filename) | |
if success: | |
print(f"โ ้ ๆฌก็ตๅๅฎไบ!") | |
print(f"๐ ๆ็ตๅบๅ: {final_output}") | |
print(f"๐ ใใกใคใซใตใคใบ: {os.path.getsize(final_output) / (1024*1024):.1f} MB") | |
else: | |
print("โ ้ ๆฌก็ตๅใซๅคฑๆใใพใใ") | |
elif args.mode == "pairwise": | |
print("๐ ใใขใฏใคใบ็ตๅๅฆ็ใ้ๅง...") | |
success, output_files, results = processor.process_pairwise_merge(args.input) | |
if success: | |
print(f"โ ใใขใฏใคใบ็ตๅๅฎไบ!") | |
print(f"๐ ๅบๅใใกใคใซๆฐ: {len(output_files)}") | |
for i, file in enumerate(output_files): | |
size_mb = os.path.getsize(file) / (1024*1024) | |
print(f" {i+1}. {os.path.basename(file)} ({size_mb:.1f} MB)") | |
else: | |
print("โ ใใขใฏใคใบ็ตๅใซๅคฑๆใใพใใ") | |
# ใฌใใผใ็ๆ | |
print("\n" + "=" * 60) | |
print("๐ ๅฆ็ใฌใใผใ:") | |
report_path = Path(args.output) / "batch_report.txt" | |
report = processor.generate_report(results, str(report_path)) | |
print(report) | |
print("๐ ใใใๅฆ็ๅฎไบ๏ผ") | |
if __name__ == "__main__": | |
main() |