Previews only; channel assets and the app unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
408 lines
22 KiB
Python
408 lines
22 KiB
Python
#!/usr/bin/env python3
|
|
"""Batch 4 block idents, previews for Paul's review (3 November 2026 brief): PPV Sunday, the Ring X weekly nights
|
|
and Sunday on Terra.
|
|
|
|
The 3D comes from blender/build_block_ident.py (blocks ppv, ringnight, terrasunday). This lays the 2D on top as the
|
|
other batches do. Two parts are drawn by the app, not baked into the video, and the previews show them exactly as the
|
|
app would draw them:
|
|
- PPV Sunday's "Tonight: <event>" lower third, from the committed booking's own title, only when the PPV is booked.
|
|
- The Ring X nights' rope colour and night name, over one shared clip. The clip's camera settles by 2.0 s, so the
|
|
overlay sits at fixed screen positions, timed from the clip's own clock (ring-x-nights-overlay.json): it is fully
|
|
drawn by 2.7 s, well before the held last frame, so nothing pops in at the hold.
|
|
|
|
build-batch4-blocks.py <blender-blocks folder> [ppv|ringnight|terrasunday] ...
|
|
"""
|
|
from pathlib import Path
|
|
import importlib.util, json, math, os, random, shutil, subprocess, sys
|
|
from PIL import Image, ImageChops, ImageDraw, ImageFilter, ImageFont
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
ROOT = HERE.parent.parent
|
|
ENV = dict(os.environ, XDG_DATA_HOME=str(ROOT / '.tooling/font-data'))
|
|
|
|
|
|
def load(name, file):
|
|
spec = importlib.util.spec_from_file_location(name, HERE / file)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
riot, dark, b3 = load('riot', 'build-riot-blocks.py'), load('dark', 'build-dark-blocks.py'), load('b3', 'build-batch3-blocks.py')
|
|
kf, ease_out, ease_in, ease_io, glow, fade = riot.kf, riot.ease_out, riot.ease_in, riot.ease_io, riot.glow, riot.fade
|
|
text_layer, place, scaled, font, fade_in = dark.text_layer, dark.place, dark.scaled, dark.font, dark.fade_in
|
|
DESIGNS, W, H, FPS, LENGTH, MOVE = dark.DESIGNS, dark.W, dark.H, dark.FPS, dark.LENGTH, dark.MOVE
|
|
WHITE, NAVY = (255, 255, 255), (7, 22, 50)
|
|
|
|
# Orbit's own names for the nights (approved 3 November), with each night's rope colour.
|
|
NIGHTS = [('MONDAY NIGHT WARS', (232, 28, 48)), ('TUESDAY TITLE FIGHT', (255, 194, 30)), ('WEDNESDAY MAIN EVENT', (56, 216, 255)),
|
|
('THURSDAY THROWDOWN', (168, 104, 255)), ('FRIDAY EXTREME', (255, 112, 26)), ('SATURDAY WORLD TOUR', (58, 224, 122))]
|
|
ROPE_STARTS, ROPE_REVEAL, BANNER_AT, BANNER_IN = (2.0, 2.12, 2.24), .3, 2.3, .4
|
|
|
|
BLOCKS = {
|
|
'ppv': dict(title='PPV Sunday', folder='orbit-ring-x-blocks/ppv-sunday', channel='orbit-ring-x'),
|
|
'ringnight': dict(title='Ring X weekly nights', folder='orbit-ring-x-blocks/weekly-nights', channel='orbit-ring-x'),
|
|
'terrasunday': dict(title='Sunday on Terra', folder='orbit-terra-blocks/sunday-on-terra', channel='orbit-terra'),
|
|
}
|
|
|
|
|
|
def plate_svg():
|
|
"""An original Orbit title plate: a gold centre plate carrying the Orbit crescent, two side plates, on a black strap.
|
|
Shaped as a broad shield with stepped edges, not modelled on any promotion's belt."""
|
|
crescent = 'M335 132C141 114 66 384 257 475C143 363 185 207 335 132Z'
|
|
gold = ('<linearGradient id="gold" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FFF1B8"/><stop offset=".35" stop-color="#F2C14E"/>'
|
|
'<stop offset=".55" stop-color="#9A6414"/><stop offset=".75" stop-color="#E2A93A"/><stop offset="1" stop-color="#FFE29A"/></linearGradient>'
|
|
'<linearGradient id="silver" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FFFFFF"/><stop offset=".5" stop-color="#B7CBE8"/><stop offset="1" stop-color="#F5F7FF"/></linearGradient>')
|
|
centre = 'M300 40L700 40L760 110L740 260L640 320L360 320L260 260L240 110Z'
|
|
side = lambda x: f'<path d="M{x} 120L{x + 150} 110L{x + 160} 230L{x} 240Z" fill="url(#gold)" stroke="#5A3A08" stroke-width="5"/><circle cx="{x + 80}" cy="175" r="22" fill="none" stroke="#7A5010" stroke-width="5"/>'
|
|
return (f'<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="360" viewBox="0 0 1000 360"><defs>{gold}</defs>'
|
|
'<rect x="0" y="130" width="1000" height="100" rx="20" fill="#0C0C10"/><rect x="0" y="138" width="1000" height="84" rx="16" fill="none" stroke="#2A2A32" stroke-width="3" stroke-dasharray="6 10"/>'
|
|
+ side(40) + side(810) +
|
|
f'<path d="{centre}" fill="url(#gold)" stroke="#5A3A08" stroke-width="7"/><path d="{centre}" fill="none" stroke="#FFF4C8" stroke-width="3" transform="translate(500 180) scale(.92) translate(-500 -180)"/>'
|
|
f'<g transform="translate(430,46) scale(.32)"><path d="{crescent}" fill="url(#silver)" stroke="#3A2408" stroke-width="14"/></g>'
|
|
'<text x="500" y="232" font-family="Anton" font-size="118" fill="#3A0A0E" text-anchor="middle" letter-spacing="10">PPV</text>'
|
|
'<text x="500" y="226" font-family="Anton" font-size="118" fill="#B4141E" text-anchor="middle" letter-spacing="10">PPV</text>'
|
|
'<text x="500" y="292" font-family="Anton" font-size="46" fill="#3A0A0E" text-anchor="middle" letter-spacing="14">SUNDAY</text></svg>')
|
|
|
|
|
|
def make_plate(folder):
|
|
src = folder / 'exports' / 'ppv_plate.svg'
|
|
src.write_text(plate_svg())
|
|
png = folder / 'exports' / 'ppv_plate.png'
|
|
subprocess.run(['vectorcraft-cli', 'convert', str(src), str(png)], env=ENV, check=True, stdout=subprocess.DEVNULL)
|
|
return Image.open(png).convert('RGBA')
|
|
|
|
|
|
def lower_third(event):
|
|
"""What the app draws over PPV Sunday's held frame when the event is booked: TONIGHT and the booked title."""
|
|
label = text_layer('TONIGHT', font('barlow-semibold.ttf', 18), (255, 210, 120, 255), 4)
|
|
title = text_layer(event, font('barlow-semibold.ttf', 34), WHITE + (255,), 1)
|
|
w, h = max(label.width, title.width) + 44, label.height + title.height + 30
|
|
card = Image.new('RGBA', (w, h))
|
|
d = ImageDraw.Draw(card)
|
|
d.rectangle((0, 0, w, h), fill=NAVY + (205,))
|
|
d.rectangle((0, 0, 5, h), fill=(226, 30, 48, 255))
|
|
card.alpha_composite(label, (22, 10)); card.alpha_composite(title, (22, 16 + label.height))
|
|
return card
|
|
|
|
|
|
def banner(name, colour, width, height):
|
|
"""The night's name as a printed banner for the ring apron, before it's set in perspective onto the apron's face."""
|
|
b = Image.new('RGBA', (width, height), (16, 4, 8, 230))
|
|
d = ImageDraw.Draw(b)
|
|
d.rectangle((0, 0, width, 6), fill=colour + (255,)); d.rectangle((0, height - 6, width, height), fill=colour + (255,))
|
|
words = text_layer(name, font('anton-regular.ttf', round(height * .62)), WHITE + (255,), round(height * .08))
|
|
words = scaled(words, min(1, width * .9 / words.width))
|
|
b.alpha_composite(words, (round((width - words.width) / 2), round((height - words.height) / 2)))
|
|
return b
|
|
|
|
|
|
|
|
def box_of(points):
|
|
xs, ys = [p[0] for p in points], [p[1] for p in points]
|
|
return min(xs), min(ys), max(xs), max(ys)
|
|
|
|
|
|
class Block(b3.Block):
|
|
BLOCKS = BLOCKS
|
|
|
|
def __init__(self, key, frames, night=0, event=None):
|
|
self.key, self.cfg, self.frames = key, BLOCKS[key], Path(frames) / key
|
|
self.points = json.loads((self.frames / 'points.json').read_text())
|
|
logo = Image.open(DESIGNS / self.cfg['channel'] / 'exports' / (('orbit_terra_realistic' if key == 'terrasunday' else 'orbit_ring_x_primary') + '.png')).convert('RGBA')
|
|
self.logo = logo.crop(logo.getbbox())
|
|
self.cache, self.night, self.event = {}, night, event
|
|
|
|
# ---- PPV Sunday --------------------------------------------------------------------------------------------
|
|
def draw_ppv(self, canvas, pts, t):
|
|
self.channel_logo(canvas, t, 1.6, 560, (40, 34))
|
|
plate = self.cache.get('plate')
|
|
if plate is None:
|
|
plate = scaled(make_plate(HERE / self.cfg['folder']), .52)
|
|
self.cache['plate'] = plate
|
|
a = kf(t, [(2.0, 0), (2.3, 1)], ease_io)
|
|
if a > 0:
|
|
s = kf(t, [(2.0, 1.25), (2.3, .97), (2.45, 1)], ease_out)
|
|
shown = b3.glint(scaled(plate, s), kf(t, [(2.55, 0), (3.0, 1)], ease_io), 60)
|
|
place(canvas, shown, (W - shown.width) / 2, 400 + (plate.height - shown.height) / 2, a)
|
|
# Drawn by the app, never baked in: only when this Sunday's PPV is the booked programme.
|
|
if self.event:
|
|
la = kf(t, [(2.7, 0), (3.05, 1)], ease_io)
|
|
card = self.cache.get('lower') or self.cache.setdefault('lower', lower_third(self.event))
|
|
place(canvas, card, 52, H - card.height - 40 + kf(t, [(2.7, 14), (3.05, 0)], ease_out), la)
|
|
|
|
# ---- The Ring X weekly nights: one clip, with the night's colour and name drawn over it ----------------------
|
|
def draw_ringnight(self, canvas, pts, t):
|
|
self.channel_logo(canvas, t, 1.4, 480, (40, 30))
|
|
name, colour = NIGHTS[self.night]
|
|
settled = self.points[str(MOVE)]
|
|
for j, start in enumerate(ROPE_STARTS):
|
|
u = kf(t, [(start, 0), (start + ROPE_REVEAL, 1)], ease_io)
|
|
if u <= 0:
|
|
continue
|
|
(x0, y0), (xm, ym), (x1, y1) = settled[f'rope{j}']
|
|
line = Image.new('RGBA', (W, H))
|
|
d = ImageDraw.Draw(line)
|
|
end = x0 + (x1 - x0) * u
|
|
path = [(x, y0 + (ym - y0) * (1 - ((x - xm) / (x1 - xm)) ** 2)) for x in [x0 + (end - x0) * k / 30 for k in range(31)]]
|
|
d.line(path, fill=colour + (255,), width=5)
|
|
canvas.alpha_composite(glow(line, 9, 1.6))
|
|
canvas.alpha_composite(line)
|
|
core = Image.new('RGBA', (W, H)); ImageDraw.Draw(core).line(path, fill=(255, 255, 255, 170), width=2)
|
|
canvas.alpha_composite(core)
|
|
b = kf(t, [(BANNER_AT, 0), (BANNER_AT + BANNER_IN, 1)], ease_io)
|
|
if b > 0:
|
|
x0, y0, x1, y1 = box_of(settled['apron'])
|
|
inset = 6
|
|
art = self.cache.get(('banner', self.night))
|
|
if art is None:
|
|
art = banner(name, colour, round(x1 - x0 - 2 * inset), round(y1 - y0 - 2 * inset))
|
|
self.cache[('banner', self.night)] = art
|
|
reveal = Image.new('L', art.size, 0)
|
|
ImageDraw.Draw(reveal).rectangle((0, 0, round(art.width * b), art.height), fill=255)
|
|
cut = art.copy(); cut.putalpha(ImageChops.multiply(art.getchannel('A'), reveal))
|
|
place(canvas, cut, x0 + inset, y0 + inset)
|
|
|
|
# ---- Sunday on Terra -----------------------------------------------------------------------------------------
|
|
def draw_terrasunday(self, canvas, pts, t):
|
|
self.birds(canvas, pts, t)
|
|
self.channel_logo(canvas, t, 1.5, 620, (50, 40))
|
|
title = self.cache.get('terra_title') or self.cache.setdefault('terra_title', text_layer('SUNDAY ON TERRA', font('barlow-regular.ttf', 36), (236, 242, 248, 255), 14))
|
|
a = kf(t, [(2.1, 0), (2.7, 1)], ease_io)
|
|
shade, pad = self.shadowed(title, .9, 8)
|
|
place(canvas, shade, 300 - pad, 300 - pad, a)
|
|
reach = kf(t, [(2.3, 0), (2.9, 1)], ease_io)
|
|
if reach > 0:
|
|
ImageDraw.Draw(canvas).line((300, 352, 300 + title.width * reach, 352), fill=(191, 227, 200, 210), width=2)
|
|
|
|
def shadowed(self, layer, amount=.8, blur=10):
|
|
shade = Image.new('RGBA', layer.size, (0, 0, 0, 0))
|
|
shade.putalpha(layer.getchannel('A').point(lambda v: round(v * amount)))
|
|
pad = blur * 3
|
|
out = Image.new('RGBA', (layer.width + 2 * pad, layer.height + 2 * pad))
|
|
out.alpha_composite(shade, (pad, pad))
|
|
out = out.filter(ImageFilter.GaussianBlur(blur))
|
|
out.alpha_composite(layer, (pad, pad))
|
|
return out, pad
|
|
|
|
def birds(self, canvas, pts, t):
|
|
"""A V of seven birds crossing the sunlit edge of the world, gone from the frame before the hold."""
|
|
if not .6 < t < 3.3:
|
|
return
|
|
sun = self.points[str(MOVE)]['sunrise']
|
|
v = (t - .6) / 2.7
|
|
lead = (sun['x'] + 420 - v * 1250, 170 - v * 60) # through the sunlit glow, clear of the frame's edge
|
|
for k, (dx, dy) in enumerate([(0, 0), (52, -24), (52, 24), (104, -46), (104, 46), (156, -68), (156, 68)]):
|
|
flap = math.sin(t * 13 + k * .9)
|
|
x, y = lead[0] + dx, lead[1] + dy + 3 * math.sin(t * 3 + k)
|
|
bird = Image.new('RGBA', (64, 40))
|
|
d = ImageDraw.Draw(bird)
|
|
lift = 11 * flap
|
|
d.line([(5, 20 - lift), (20, 16 - lift * .4), (32, 22), (44, 16 - lift * .4), (59, 20 - lift)], fill=(10, 14, 22, 245), width=6, joint='curve')
|
|
place(canvas, bird, x - 32, y - 20)
|
|
|
|
|
|
# ---- Sound ----------------------------------------------------------------------------------------------------
|
|
RATE = riot.RATE
|
|
|
|
|
|
def crowd(n_sec, seed=41):
|
|
"""A big room full of people, made from noise: a low roar band, swelling."""
|
|
rng, n = random.Random(seed), int(n_sec * RATE)
|
|
raw = [rng.uniform(-1, 1) for _ in range(n)]
|
|
low = riot.onepole(raw, .08)
|
|
band = [a - b for a, b in zip(low, riot.onepole(low, .01))]
|
|
return [s * 5 * (min(1, i / (n * .55)) ** 1.5) * riot.env(i, n, .05, .4) for i, s in enumerate(band)]
|
|
|
|
|
|
def crackle(n_sec, seed=42):
|
|
rng, n = random.Random(seed), int(n_sec * RATE)
|
|
out = [0.0] * n
|
|
for _ in range(int(n_sec * 70)):
|
|
at = rng.randrange(n - 400)
|
|
amp = rng.uniform(.2, 1) * math.exp(-3 * at / n)
|
|
for i in range(200):
|
|
out[at + i] += rng.uniform(-1, 1) * amp * math.exp(-i / 30)
|
|
return out
|
|
|
|
|
|
def twang(f=82.4, n_sec=.7):
|
|
"""A rope pulled taut and let go: a low pluck with a quick bright edge."""
|
|
n, out = int(n_sec * RATE), []
|
|
for i in range(n):
|
|
t = i / RATE
|
|
out.append(sum(math.sin(2 * math.pi * f * k * t) / k ** 1.3 * math.exp(-(2 + k) * t) for k in range(1, 9)) * min(1, t / .003))
|
|
return out
|
|
|
|
|
|
def pad_chord(n_sec=3.3):
|
|
"""A soft string-like chord (C, G, C, E, G, D), slowly swelling: detuned pairs of gentle saws."""
|
|
n, out = int(n_sec * RATE), []
|
|
notes = [130.8, 196.0, 261.6, 329.6, 392.0, 587.3]
|
|
for i in range(n):
|
|
t = i / RATE
|
|
s = 0.0
|
|
for f in notes:
|
|
for d in (-.6, .6):
|
|
s += sum(math.sin(2 * math.pi * (f + d) * k * t) / k for k in (1, 2, 3)) * .5
|
|
out.append(s * min(1, (t / 1.4) ** 2) * riot.env(i, n, .01, .9))
|
|
return out
|
|
|
|
|
|
def wind(n_sec, seed=43):
|
|
rng, n = random.Random(seed), int(n_sec * RATE)
|
|
raw, out, y = [rng.uniform(-1, 1) for _ in range(n)], [], 0.0
|
|
for i in range(n):
|
|
u = i / n
|
|
y += (.01 + .02 * math.sin(math.pi * u)) * (raw[i] - y)
|
|
out.append(y * 6 * math.sin(math.pi * u))
|
|
return out
|
|
|
|
|
|
SOUNDS = {
|
|
'ppv': lambda: riot.mix(LENGTH, [(0, crowd(3.9), .5), (.66, riot.thump(.5, 70, 30, .5, 44), .7), (.68, crackle(1.4), .25), (1.46, riot.thump(.45, 64, 30, .4, 45), .6), (1.48, crackle(1.2, 46), .2)]),
|
|
'ringnight': lambda: riot.mix(LENGTH, [(s, twang(82.4 * (1 + j * .12)), .5) for j, s in enumerate(ROPE_STARTS)] + [(BANNER_AT + BANNER_IN, b3.bell(1046.5, 1.4), .35)]),
|
|
'terrasunday': lambda: riot.mix(LENGTH, [(.3, pad_chord(), .5), (.2, wind(3.6), .6)]),
|
|
}
|
|
|
|
|
|
# ---- Build ----------------------------------------------------------------------------------------------------
|
|
|
|
def guide_card(key, d, stem, night=0):
|
|
channel = BLOCKS[key]['channel']
|
|
epg_path = (HERE / 'orbit-terra-v2/exports/orbit_terra_epg.png') if key == 'terrasunday' else DESIGNS / channel / 'exports' / f"{channel.replace('-', '_')}_epg.png"
|
|
epg = Image.open(epg_path).convert('RGBA')
|
|
epg = scaled(epg.crop(epg.getbbox()), .7)
|
|
card = Image.new('RGBA', (512, 160))
|
|
card.alpha_composite(epg, (10, round((160 - epg.height) / 2)))
|
|
if key == 'ppv':
|
|
plate = scaled(make_plate(HERE / BLOCKS['ppv']['folder']), .2)
|
|
card.alpha_composite(plate, (300, round((160 - plate.height) / 2)))
|
|
elif key == 'ringnight':
|
|
name, colour = NIGHTS[night]
|
|
words = name.split(' ', 1)
|
|
y = 30
|
|
for i, w in enumerate(words):
|
|
layer = text_layer(w, font('anton-regular.ttf', 36 if i else 30), (colour if i == 0 else WHITE) + (255,), 2)
|
|
layer = scaled(layer, min(1, 180 / layer.width))
|
|
card.alpha_composite(layer, (316, y)); y += layer.height + 6
|
|
else:
|
|
for i, w in enumerate(('SUNDAY', 'ON TERRA')):
|
|
layer = text_layer(w, font('barlow-regular.ttf', 28), (236, 242, 248, 255), 6)
|
|
card.alpha_composite(layer, (318, 46 + i * 38))
|
|
card.save(d / 'exports' / f'{stem}_guide.png')
|
|
card.resize((256, 80), Image.LANCZOS).save(d / 'exports' / f'{stem}_guide_app.webp', quality=90)
|
|
|
|
|
|
def render(block, tmp):
|
|
if tmp.exists():
|
|
shutil.rmtree(tmp)
|
|
tmp.mkdir()
|
|
out = []
|
|
for i in range(int(LENGTH * FPS)):
|
|
f = block.frame(i / FPS).convert('RGB')
|
|
f.save(tmp / f'{i:04d}.png')
|
|
out.append(f)
|
|
return out
|
|
|
|
|
|
ENCODE = ['-an', '-vf', 'fps=30', '-c:v', 'libx264', '-profile:v', 'main', '-pix_fmt', 'yuv420p', '-preset', 'veryslow', '-tune', 'animation', '-crf', riot.CRF, '-maxrate', '1400k', '-bufsize', '2800k', '-movflags', '+faststart']
|
|
|
|
|
|
def encode(tmp, out):
|
|
subprocess.run(['ffmpeg', '-y', '-v', 'error', '-framerate', str(FPS), '-i', str(tmp / '%04d.png'), *ENCODE, str(out)], check=True)
|
|
|
|
|
|
def sting_for(key, d, stem):
|
|
sting = d / 'exports' / f'{stem}_sting.wav'
|
|
samples = SOUNDS[key]()
|
|
riot.write_wav(sting, samples)
|
|
m = riot.loudness(sting)
|
|
riot.write_wav(sting, samples, -14.0 + min(riot.STING_LUFS - m['integratedLufs'], riot.STING_PEAK - m['truePeakDbfs']))
|
|
return sting
|
|
|
|
|
|
def with_sound(video, sting, out):
|
|
subprocess.run(['ffmpeg', '-y', '-v', 'error', '-i', str(video), '-i', str(sting), '-map', '0:v', '-map', '1:a', '-c:v', 'copy', '-c:a', 'aac', '-b:a', '96k', '-shortest', '-movflags', '+faststart', str(out)], check=True)
|
|
|
|
|
|
def sheet(frames, title, out):
|
|
picks = [0, .5, 1.0, 1.5, 2.0, 2.4, 2.8, 3.2, LENGTH - 1 / FPS]
|
|
s = Image.new('RGB', (1920, 1080 + 70), NAVY)
|
|
ImageDraw.Draw(s).text((20, 16), title, font=font('barlow-semibold.ttf', 32), fill='white')
|
|
for n, t in enumerate(picks):
|
|
tile = frames[min(len(frames) - 1, round(t * FPS))].resize((640, 360), Image.LANCZOS)
|
|
riot.label(tile, f'{t:.1f} s' if n < 8 else 'final hold', 22)
|
|
s.paste(tile, ((n % 3) * 640, 70 + (n // 3) * 360))
|
|
s.save(out)
|
|
|
|
|
|
def build(key, frames):
|
|
cfg = BLOCKS[key]
|
|
d = HERE / cfg['folder']
|
|
for sub in ('exports', 'review'):
|
|
(d / sub).mkdir(parents=True, exist_ok=True)
|
|
stem = Path(cfg['folder']).name.replace('-', '_')
|
|
tmp = d / 'review' / '.frames'
|
|
report = dict(status='preview-not-integrated', block=cfg['title'], seconds=LENGTH, fps=FPS, size=[W, H], crf=riot.CRF)
|
|
sting = sting_for(key, d, stem)
|
|
# The file the app would ship: PPV and the nights without anything the app draws; Terra complete.
|
|
base = render(Block(key, frames), tmp)
|
|
silent = d / 'exports' / f'{stem}_ident.mp4'
|
|
encode(tmp, silent)
|
|
report.update(identBytes=silent.stat().st_size, ssim=riot.ssim(silent, tmp), finalHoldStillForHalfSecond=riot.hold_check(base), flash=riot.flash_check(silent), sting=riot.loudness(sting))
|
|
if key == 'terrasunday':
|
|
base[-1].save(d / 'review' / f'{stem}_final_still.png')
|
|
shutil.copy(silent, d / 'review' / f'{stem}_preview_silent.mp4')
|
|
with_sound(silent, sting, d / 'review' / f'{stem}_preview_with_sound.mp4')
|
|
sheet(base, f"{cfg['title']} / block ident preview, {LENGTH:.0f} s", d / 'review' / f'{stem}_contact_sheet.png')
|
|
guide_card(key, d, stem)
|
|
elif key == 'ppv':
|
|
# As seen on air with a booked event: the app's lower third over the shipped clip.
|
|
shown = render(Block(key, frames, event='WWE WrestleMania III'), tmp)
|
|
preview = d / 'review' / f'{stem}_preview_silent.mp4'
|
|
encode(tmp, preview)
|
|
with_sound(preview, sting, d / 'review' / f'{stem}_preview_with_sound.mp4')
|
|
shown[-1].save(d / 'review' / f'{stem}_final_still.png')
|
|
base[-1].save(d / 'review' / f'{stem}_final_still_no_booking.png')
|
|
sheet(shown, f"{cfg['title']} / preview with a booked event (lower third drawn by the app)", d / 'review' / f'{stem}_contact_sheet.png')
|
|
report['heldFrameStillWithLowerThird'] = riot.hold_check(shown)
|
|
guide_card(key, d, stem)
|
|
else:
|
|
# The shared clip itself, then each night as the app would show it over that one file.
|
|
base[-1].save(d / 'review' / f'{stem}_shared_clip_final.png')
|
|
holds, stills = {}, []
|
|
for i, (name, colour) in enumerate(NIGHTS):
|
|
night = name.split(' ')[0].lower()
|
|
shown = render(Block(key, frames, night=i), tmp)
|
|
preview = d / 'review' / f'{stem}_{night}_preview_silent.mp4'
|
|
encode(tmp, preview)
|
|
with_sound(preview, sting, d / 'review' / f'{stem}_{night}_preview_with_sound.mp4')
|
|
shown[-1].save(d / 'review' / f'{stem}_{night}_final_still.png')
|
|
stills.append(shown[-1])
|
|
holds[night] = riot.hold_check(shown)
|
|
if i == 0:
|
|
sheet(shown, f"{cfg['title']} / Monday, as the app draws it over the shared clip", d / 'review' / f'{stem}_contact_sheet.png')
|
|
guide_card(key, d, f'{stem}_{night}', i)
|
|
grid = Image.new('RGB', (1920, 70 + 3 * 360), NAVY)
|
|
ImageDraw.Draw(grid).text((20, 16), 'Ring X nights: final hold of each night, one shared clip with the name and rope colour drawn by the app', font=font('barlow-semibold.ttf', 30), fill='white')
|
|
for i, s in enumerate(stills):
|
|
grid.paste(s.resize((640, 360), Image.LANCZOS), ((i % 3) * 640, 70 + (i // 3) * 360))
|
|
grid.save(d / 'review' / f'{stem}_all_nights.png')
|
|
report['heldFrameStillPerNight'] = holds
|
|
# The overlay the app would draw: fixed positions (the camera has settled by 2.0 s) and timings on the clip's clock.
|
|
settled = Block(key, frames).points[str(MOVE)]
|
|
spec = dict(clip=silent.name, cameraSettledSeconds=2.0, ropes=[dict(points=settled[f'rope{j}'], startSeconds=s, revealSeconds=ROPE_REVEAL, width=5, glowRadius=9) for j, s in enumerate(ROPE_STARTS)],
|
|
banner=dict(box=box_of(settled['apron']), inset=6, startSeconds=BANNER_AT, revealSeconds=BANNER_IN, wipe='left-to-right'),
|
|
nights=[dict(name=n, colour='#%02X%02X%02X' % c) for n, c in NIGHTS], completeBySeconds=BANNER_AT + BANNER_IN, holdFromSeconds=LENGTH - .5)
|
|
(d / 'exports' / 'ring-x-nights-overlay.json').write_text(json.dumps(spec, indent=1))
|
|
shutil.rmtree(tmp, ignore_errors=True)
|
|
(d / 'review' / 'checks.json').write_text(json.dumps(report, indent=1))
|
|
print(json.dumps(report))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
frames = sys.argv[1]
|
|
for key in sys.argv[2:] or list(BLOCKS):
|
|
build(key, frames)
|