import hashlib,json,os,time,subprocess,sys from pathlib import Path os.environ.setdefault('HF_HUB_DISABLE_PROGRESS_BARS','1') REPO='QingyanBai/Ditto-1M' REV='aac1417418d8f7e77d4e257d5620c36b2c3a00e8' DEST='faraway00/StyleEdit' BASE=Path(__file__).resolve().parent CORE=Path('/opt/style-cleaning-core-v1-20261024') def atomic(p,value): p=Path(p);p.parent.mkdir(parents=True,exist_ok=True) t=p.with_name(p.name+'.tmp');t.write_text(json.dumps(value,ensure_ascii=False,indent=2));os.replace(t,p) def sha(p): h=hashlib.sha256() with open(p,'rb') as f: for b in iter(lambda:f.read(4*1024**2),b''):h.update(b) return h.hexdigest() def stable(row):return hashlib.sha256((REV+'\0'+row['source_path']+'\0'+row['edited_path']).encode()).hexdigest()[:24] def ffprobe(p): d=json.loads(subprocess.check_output(['ffprobe','-v','error','-select_streams','v:0','-show_streams','-show_frames','-show_entries','stream=width,height,pix_fmt,avg_frame_rate,r_frame_rate:frame=best_effort_timestamp_time','-of','json',str(p)])) s=d['streams'][0];s['pts']=[float(x['best_effort_timestamp_time']) for x in d['frames']];s['frames']=len(s['pts']);return s