Spaces:
Paused
Paused
Download src/mv/engine/timeline.ts from Ethscriptions/video: direct link, hf CLI and curl.
- Browser
- Download file 3.28 kB
-
https://huggingface.co/spaces/Ethscriptions/video/resolve/main/src/mv/engine/timeline.ts
- Command line
-
hf download hf://spaces/Ethscriptions/video/src/mv/engine/timeline.ts
-
curl -L -o timeline.ts https://huggingface.co/spaces/Ethscriptions/video/resolve/main/src/mv/engine/timeline.ts
3.28 kB
| import { BAR, BEAT, BREAK, DROP1, DROP2, DURATION } from './audio' | |
| import { sDrop1, sIgnite, sStreet, sTunnel } from './scenesA' | |
| import { sFinale, sHeartbeat } from './scenesB' | |
| import { sDuel, sJump } from './scenesCar' | |
| import { sMarket } from './scenesMarket' | |
| import type { SceneFn } from './types' | |
| export interface SceneDef { | |
| id: string | |
| name: string | |
| start: number | |
| end: number | |
| fn: SceneFn | |
| color: string | |
| } | |
| const b1 = (k: number) => DROP1 + k * BEAT | |
| const b2 = (k: number) => DROP2 + k * BEAT | |
| export const SCENES: SceneDef[] = [ | |
| { id: 'ignite', name: '开场·篝火与摩托', start: 0, end: b1(-51), fn: sIgnite, color: '#ff2d55' }, | |
| { id: 'street', name: '雨夜·骑车穿街', start: b1(-51), end: b1(-25), fn: sStreet, color: '#3de0ff' }, | |
| { id: 'tunnel', name: '蓄力·隧道', start: b1(-25), end: DROP1, fn: sTunnel, color: '#ffb35c' }, | |
| { id: 'drop1', name: 'Drop1·霓虹爆裂', start: DROP1, end: b1(10), fn: sDrop1, color: '#ff2d55' }, | |
| { id: 'duel', name: '公路·倒车闪灯', start: b1(10), end: BREAK, fn: sDuel, color: '#ff7a4a' }, | |
| { id: 'market', name: '夜市·烧烤糖水鱼蛋', start: BREAK, end: b2(-32), fn: sMarket, color: '#ffb35c' }, | |
| { id: 'heart', name: '月光·烧报纸', start: b2(-32), end: DROP2, fn: sHeartbeat, color: '#9b1530' }, | |
| { id: 'jump', name: 'Drop2·喷射飞越', start: DROP2, end: DROP2 + 8 * BAR, fn: sJump, color: '#3de0ff' }, | |
| { id: 'finale', name: '终章·星空与火车', start: DROP2 + 8 * BAR, end: DURATION, fn: sFinale, color: '#ff2d55' }, | |
| ] | |
| export function sceneAt(t: number): SceneDef { | |
| for (const s of SCENES) if (t < s.end) return s | |
| return SCENES[SCENES.length - 1] | |
| } | |
| export interface Caption { | |
| start: number | |
| end: number | |
| text: string | |
| } | |
| // Original subtitle lines (not the song lyrics). | |
| export const CAPTIONS: Caption[] = [ | |
| { start: 10.4, end: 13.9, text: '凌晨两点,他推着车走在雨里' }, | |
| { start: 14.4, end: 18.0, text: '霓虹替我记住每一条路' }, | |
| { start: 18.6, end: 23.2, text: '这条街,从不问你的来处' }, | |
| { start: 25.0, end: 28.6, text: '只问你——' }, | |
| { start: 29.0, end: 34.6, text: '敢不敢,走到尽头' }, | |
| { start: 57.0, end: 60.8, text: '城市睡了,红月醒着' }, | |
| { start: 61.5, end: 65.5, text: '风吹乱了他的卷发' }, | |
| { start: 66.0, end: 71.6, text: '灯海在脚下翻涌' }, | |
| { start: 74.5, end: 78.6, text: '穿过夜市的烟火' }, | |
| { start: 79.2, end: 83.4, text: '葱、姜、蒜,香气还热着' }, | |
| { start: 84.0, end: 89.5, text: '人间,就藏在这一碗里' }, | |
| { start: 92.4, end: 96.4, text: '那封信,他读了很多遍' }, | |
| { start: 97.0, end: 101.0, text: '只剩心跳' }, | |
| { start: 101.6, end: 106.6, text: '烧掉它,再出发' }, | |
| ] | |
| export function captionAt(t: number): Caption | null { | |
| for (const c of CAPTIONS) if (t >= c.start && t < c.end) return c | |
| return null | |
| } | |
| /** Hard cuts that get a flash + glitch accent. */ | |
| export const CUTS: number[] = (() => { | |
| const cuts = SCENES.slice(1).map((s) => s.start) | |
| cuts.push(b1(4), b1(8), b1(-25) + 2.5 * BAR) | |
| const duel = b1(10) | |
| for (const bar of [1, 2, 5, 6, 8, 10, 11]) cuts.push(duel + bar * BAR) | |
| for (const bar of [2, 3, 7]) cuts.push(DROP2 + bar * BAR) | |
| return cuts.sort((a, b) => a - b) | |
| })() | |