Branchwell

Jotley / website · jotley.ai / scripts / video-refresh / stage-ipad-generation.py

Raw 1.1 KB on 9f5272c5f39b346af9e28d5fc68fe05aab70ce39
1from pathlib import Path
2import subprocess,re,json
3b=Path('/Volumes/Music/Jotley/Jotley-2.0-App-Store-Videos')
4s=b/'capture-2.2-20261023/ios/Jotley-2.2-iPad-Summary.mp4';a=b/'refresh-website-social-20261023/composition/tutorial-ipad-16x9/assets'
5subprocess.run(['ffmpeg','-v','error','-y','-i',str(s),'-filter_complex','[0:v]trim=start=5:end=8,setpts=PTS-STARTPTS[a];[0:v]trim=start=15.5:end=20,setpts=PTS-STARTPTS,tpad=stop_mode=clone:stop_duration=1.5[b];[a][b]concat=n=2:v=1:a=0,tpad=stop_mode=clone:stop_duration=5[v]','-map','[v]','-an','-c:v','libx264','-preset','fast','-crf','12','-pix_fmt','yuv420p','-movflags','+faststart',str(a/'ipad-summary-edit.mp4')],check=True)
6p=a.parent/'index.html';t=p.read_text()
7for ident,m in {'sv0':22.6,'sv2':0,'sv5':22.5}.items():
8 t,n=re.subn(r'(<video\b[^>]*\bid="'+ident+r'"[^>]*\bdata-media-start=")[^"]*',lambda x:x[1]+str(m),t);assert n==1
9# Only the generation shot uses a disclosed editorial cut through the waiting period.
10t=re.sub(r'(<video\b[^>]*\bid="sv2"[^>]*\bsrc=")[^"]*',r'\g<1>assets/ipad-summary-edit.mp4',t)
11p.write_text(t)
12print('iPad source offsets and generation-wait edit staged')