|
| 1 | +name: dscan-snap-multi |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ci/dscan-snap-multi] |
| 5 | +jobs: |
| 6 | + snap: |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + os: [ubuntu-latest, windows-latest] |
| 12 | + timeout-minutes: 40 |
| 13 | + steps: |
| 14 | + - uses: actions/setup-node@v4 |
| 15 | + with: |
| 16 | + node-version: 24 |
| 17 | + - uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: "3.12" |
| 20 | + - name: ffmpeg |
| 21 | + shell: bash |
| 22 | + run: (command -v ffmpeg >/dev/null) || (choco install ffmpeg -y --no-progress >/dev/null 2>&1 || sudo apt-get install -y ffmpeg >/dev/null) |
| 23 | + - name: build project |
| 24 | + shell: python |
| 25 | + run: | |
| 26 | + import os,subprocess |
| 27 | + os.makedirs("proj/compositions",exist_ok=True); os.chdir("proj") |
| 28 | + open("hyperframes.json","w").write("{}") |
| 29 | + subprocess.run(["ffmpeg","-v","error","-y","-f","lavfi","-i","color=c=0x2255aa:s=300x300","-frames:v","1","logo.png"],check=True) |
| 30 | + beats=[(14.5,"A"),(18.5,"B"),(22.5,"C"),(25.01,"D"),(27.01,"E")] |
| 31 | + def tmpl(cid,body,js,css=""): |
| 32 | + return f'<template id="{cid}-template"><div data-composition-id="{cid}" data-width="1920" data-height="1080" data-duration="30">{body}<style>[data-composition-id="{cid}"]{{position:relative;width:1920px;height:1080px;font-family:Arial;color:#fff}}{css}</style><script>(function(){{const tl=gsap.timeline({{paused:true}});{js}window.__timelines=window.__timelines||{{}};window.__timelines["{cid}"]=tl;}})();</script></div></template>' |
| 33 | + # brand: the same logo repeated at every beat |
| 34 | + body="".join(f'<img class="logo" id="logo{i}" src="../logo.png" style="position:absolute;left:{100+i*300}px;top:100px;width:200px;opacity:0">' for i,_ in enumerate(beats)) |
| 35 | + js="".join(f'tl.to("#logo{i}",{{opacity:1,duration:0.2}},{t-0.6});tl.to("#logo{i}",{{opacity:0,duration:0.2}},{t+1.2});' for i,(t,_) in enumerate(beats)) |
| 36 | + open("compositions/brand.html","w").write(tmpl("brand",body,js)) |
| 37 | + body="".join(f'<div id="ttl{i}" style="position:absolute;left:120px;top:500px;font-size:96px;opacity:0">Title {n} text</div>' for i,(t,n) in enumerate(beats)) |
| 38 | + js="".join(f'tl.to("#ttl{i}",{{opacity:1,duration:0.2}},{t-0.6});tl.to("#ttl{i}",{{opacity:0,duration:0.2}},{t+1.2});' for i,(t,_) in enumerate(beats)) |
| 39 | + open("compositions/titles.html","w").write(tmpl("titles",body,js)) |
| 40 | + body="".join(f'<div id="cap{i}" style="position:absolute;left:300px;top:900px;font-size:56px;opacity:0">Caption line {n}</div>' for i,(t,n) in enumerate(beats)) |
| 41 | + js="".join(f'tl.to("#cap{i}",{{opacity:1,duration:0.1}},{t-0.5});tl.to("#cap{i}",{{opacity:0,duration:0.1}},{t+1.0});' for i,(t,_) in enumerate(beats)) |
| 42 | + open("compositions/captions.html","w").write(tmpl("captions",body,js)) |
| 43 | + layers="".join(f'<div id="{c}-layer" data-composition-id="{c}" data-composition-src="compositions/{c}.html" data-start="0" data-duration="30" data-track-index="{k}"></div>' for k,c in enumerate(["brand","titles","captions"],1)) |
| 44 | + open("index.html","w").write(f'<!doctype html><html><head><meta charset="utf-8"><script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script></head><body style="margin:0;background:#101820"><div id="root" data-composition-id="main" data-start="0" data-duration="30" data-width="1920" data-height="1080">{layers}</div><script>window.__timelines=window.__timelines||{{}};window.__timelines["main"]=gsap.timeline({{paused:true}});</script></body></html>') |
| 45 | + - name: multi vs solo |
| 46 | + shell: python |
| 47 | + continue-on-error: true |
| 48 | + run: | |
| 49 | + import os,subprocess,hashlib,glob |
| 50 | + os.chdir("proj") |
| 51 | + times=["14.5","18.5","22.5","25.01","27.01"] |
| 52 | + def snap(at,out): |
| 53 | + r=subprocess.run(["npx","-y","hyperframes@0.8.219","snapshot","--at",at,"--no-end","--describe","false","-o",out],capture_output=True,text=True,shell=(os.name=="nt")) |
| 54 | + if r.returncode: print("EXIT",r.returncode,r.stdout[-400:],r.stderr[-400:]) |
| 55 | + return sorted(glob.glob(out+"/*.png")) |
| 56 | + def h(p): d=open(p,"rb").read(); return hashlib.sha256(d).hexdigest()[:10],len(d) |
| 57 | + multi=snap(",".join(times),"multi") |
| 58 | + rows=[] |
| 59 | + for i,t in enumerate(times): |
| 60 | + solo=snap(t,"solo%d"%i) |
| 61 | + rows.append((t,h(multi[i]),h(solo[0]))) |
| 62 | + for t,m,s in rows: print("AT",t,"multi",m,"solo",s,"SAME" if m==s else "DIFF") |
| 63 | + # also run multi twice more to see run-to-run stability |
| 64 | + for k in (2,3): |
| 65 | + again=snap(",".join(times),"multi%d"%k) |
| 66 | + print("MULTI-RUN",k,[h(p)==h(multi[i]) for i,p in enumerate(again)]) |
0 commit comments