import json import shutil import os import argparse def main(args): with open(args.json) as f: clips = json.load(f) if isinstance(clips, dict): clips = [clips] for clip in clips: clip_id = clip["clip_id"] split = clip["split"] folder = clip["source_video_folder"] out_dir = os.path.join(args.dst, split, clip_id) os.makedirs(out_dir, exist_ok=True) for frame in clip["frames"]: src = os.path.join(args.src, folder, frame["source_frame"]) dst = os.path.join(out_dir, frame["new_frame"]) shutil.copy2(src, dst) print(f"Copied {src} -> {dst}") if __name__ == "__main__": parser = argparse.ArgumentParser(description="Map old clip/frame names to new ones and copy files.") parser.add_argument("--json", default="./OLiVES_VOS_metadata.json", help="Path to the clips JSON file") parser.add_argument("--src", default="./OLiVES/input", help="Path to the low-light videos directory") args = parser.parse_args() main(args)