const fs=require('node:fs'),path=require('node:path'),{spawnSync}=require('node:child_process'); const local=path.resolve('work/frame-builder/node_modules/ffmpeg-static/ffmpeg.exe'); const ff=process.env.PVF_FFMPEG||(fs.existsSync(local)?local:'ffmpeg'),d=__dirname,log=[]; function run(a){const r=spawnSync(ff,['-hide_banner','-nostdin','-y',...a],{cwd:d,maxBuffer:50e6});log.push({args:a,status:r.status,stderr:String(r.stderr)});fs.writeFileSync(d+'/command-output.txt',JSON.stringify(log,null,2));if(r.status)throw Error(String(r.stderr));return r;} const w=1024,h=16,n=12,raw=Buffer.alloc(w*h*3*2*n); for(let f=0;fbytes===2?b.readUInt16LE(x*2):b[x]); const repeats=row.slice(1).filter((v,i)=>v===row[i]).length; results.outputs[name]={pixelFormat:fmt,decodedFrames:b.length/(w*h*3*bytes),distinctFirstRowLuma:new Set(row).size,repeatedAdjacentPairs:repeats,min:Math.min(...row),max:Math.max(...row),row}; } fs.writeFileSync(d+'/measurements.json',JSON.stringify(results,null,2));console.log(JSON.stringify({...results,outputs:Object.fromEntries(Object.entries(results.outputs).map(([k,v])=>[k,{...v,row:undefined}]))},null,2));