"""Batch v4 grading. Genuine action/viewing/queue evidence remains operator-reviewed.""" import argparse,json,math,tempfile,shutil from pathlib import Path from verifier_runtime import select_project import single_backend as backend from media_helpers import probe,digest from deterministic_checks import action_checks,GradingError,require_complete POINTS=dict(zip(['a','c','d']+list('efghijklmno'),[2,4,4,8,8,9,12,7,6,5,7,12,10,6])) LABELS=dict(zip(POINTS,['Filmcraft use','Three correct imports','Editable sequence','Visual identification','Target order','First five seconds normal speed','Four decoded source ranges','Cuts and duration in four exports','Four H.264 MP4s, dimensions and 30 fps','Distinct exports, horizontal filenames and directory','Proportional full-image fit in all frames','Editable project supporting four exports','Distractors excluded','Batch attempt and four completed exports'])) assert sum(POINTS.values())==100 def display_size(stream): w,h=stream.get('width',0),stream.get('height',0) par=stream.get('sample_aspect_ratio','1:1') if par not in ['N/A','0:1']: a,b=map(int,par.split(':'));w=w*a/max(1,b) rotation=next((s.get('rotation',0) for s in stream.get('side_data_list',[]) if 'rotation' in s),0) if abs(rotation)%180==90:w,h=h,w return w,h,rotation def evaluate(workspace,report_dir,assets,access): report_dir.mkdir(parents=True,exist_ok=True);out=workspace/'root/Desktop/coffee-ad/output' candidates=[] for p in sorted(out.glob('*.mp4')): try: d,s=probe(p);w,h,rotation=display_size(s);candidates.append({'filename':p.name,'W':round(w),'H':round(h),'rotation':rotation,'probe':d,'portrait':h>w and abs(w/h-9/16)<=.002,'area':w*h}) except Exception:pass # Horizontal identity is strict; portrait names are intentionally unspecified. slots=[{'filename':'final-1080p.mp4','W':1920,'H':1080,'tier':'horizontal-high'},{'filename':'final01-720p.mp4','W':1280,'H':720,'tier':'horizontal-low'}] portraits=sorted([c for c in candidates if c['portrait'] and c['filename'] not in [s['filename'] for s in slots]],key=lambda c:c['area'],reverse=True) for i,tier in enumerate(['vertical-high','vertical-low']): c=portraits[i] if i=2: W,H=slot['W'],slot['H'];natural=(W,H) in [(1080,1920),(720,1280)] state='met' if r['export']['decoded_frames'] and (W