소리 크기 맞추기(노멀라이즈): 곡마다 유튜브가 잰 크기(영상 페이지 audioConfig LUFS)를 저장하고, 재생 볼륨 = 내 볼륨 × 곡 보정값으로 -18 LUFS에 맞춤(유튜브 IFrame이 -14로 줄이는 것 위에, 작은 곡은 최대). prepare·catchup에 gain, 안 잰 곡은 보통 곡 값(0.63). 영상이 바뀌면 다시 잼(loudness_video). cli loudness 작업(인기곡부터·차단 시 멈춤·--deadline)·관리자 수집 화면, heatmap도 같은 페이지에서 저장. 실제 유튜브 e2e로 플레이어 볼륨 확인

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-19 23:41:51 +09:00
parent 86bd2d8166
commit 37c1440892
17 changed files with 262 additions and 37 deletions

View File

@@ -13,6 +13,7 @@ import { join } from 'node:path';
import { loadConfig } from '../apps/server/src/config';
import { startServer } from '../apps/server/src/server';
import { Catalog } from '../apps/server/src/collector/catalog';
import { loudnessGain } from '../apps/server/src/songs/quiz';
const PORT = Number(process.env.E2E_PORT ?? 4621);
const ORIGIN = `http://localhost:${PORT}`;
@@ -43,15 +44,16 @@ const db = app.db;
db.query("UPDATE songs SET youtube_status = 'matched', embeddable = 1, youtube_id = ?, duration_sec = 200 WHERE id = ?").run(`fake${String(i).padStart(7, '0')}`, id!);
if (i <= 2) db.query('INSERT INTO lyrics (song_id, text, source, fetched_at) VALUES (?, ?, ?, 0)').run(id!, `첫 소절 곡${i}\n둘째 줄 ${i}\n셋째 줄\n넷째 줄\n다섯째 줄\n여섯째 줄\n후렴 곡${i}\n후렴 곡${i}`, 'e2e');
}
const real: [string, string, string, number][] = [
['광 (狂)', 'SG워너비', 'VO88htcm09E', 237],
['가져가', '홍경민', 'Q7Q_qavUPdM', 221],
['Be Natural', '에스이에스', 'YWP5K88l9G0', 282],
// loudness: 광 as YouTube measured it, 가져가 as if quiet (full volume), Be Natural not measured
const real: [string, string, string, number, number | null][] = [
['광 (狂)', 'SG워너비', 'VO88htcm09E', 237, -10.42],
['가져가', '홍경민', 'Q7Q_qavUPdM', 221, -20],
['Be Natural', '에스이에스', 'YWP5K88l9G0', 282, null],
];
for (const [title, artist, vid, dur] of real) {
for (const [title, artist, vid, dur, lufs] of real) {
const [id] = c.upsert({ title, artists: [{ name: artist }], year: 2000, genres: ['kpop'], source: 'e2e', ref: vid });
c.autoLevel(id!, 'all', 9);
db.query("UPDATE songs SET youtube_status = 'matched', embeddable = 1, youtube_id = ?, duration_sec = ? WHERE id = ?").run(vid, dur, id!);
db.query("UPDATE songs SET youtube_status = 'matched', embeddable = 1, youtube_id = ?, duration_sec = ?, loudness_lufs = ?, loudness_video = ? WHERE id = ?").run(vid, dur, lufs, lufs === null ? null : vid, id!);
}
}
const titleOf = (vid: string) => db.query<{ title: string; artist: string }, [string]>('SELECT title, artist FROM songs WHERE youtube_id = ?').get(vid)!;
@@ -388,6 +390,11 @@ try {
expect(st.every((s) => s.state === 1 && !s.muted), `재생 상태 ${JSON.stringify(st)}`);
expect(Math.abs(st[0]!.pos - st[1]!.pos) < 0.3, `두 사람 위치 차이 ${JSON.stringify(st)}`);
console.log(` 위치 ${st.map((s) => s.pos.toFixed(3)).join(' / ')}`);
// 소리 크기 맞추기: the YouTube player itself runs at volume (70 by default) × this song's gain
const lufs = db.query<{ v: number | null }, [string]>('SELECT loudness_lufs v FROM songs WHERE youtube_id = ?').get((await video(x))!)!.v;
const ytVol = await Promise.all([x, y].map((p) => p.frames().find((f) => f.url().includes('youtube.com/embed'))!.evaluate(() => (document.getElementById('movie_player') as any).getVolume() as number)));
console.log(` 유튜브 볼륨 ${ytVol.join(' / ')} (곡 ${lufs ?? '안 잼'} LUFS)`);
expect(ytVol.every((v) => v === Math.round(70 * loudnessGain(lufs))), `유튜브 볼륨 ${ytVol} ≠ 70 × ${loudnessGain(lufs)}`);
// 3s clip: stops by position
await x.locator('.stage .mode', { hasText: '재생이 끝났어요' }).waitFor({ timeout: 8000 });
const end = await Promise.all([x, y].map((p) => p.evaluate(() => ({ pos: (window as any).mqPlayer.pos(), state: (window as any).mqPlayer.state() }))));