Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Tutorial entry, sound-led pictures in the editor, sound-request wording and two-GPU memory sizing

Bowen Xue06defdd2d1a6
diff --git a/MANIFEST.in b/MANIFEST.in
index c430037..f4dd048 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -68,5 +68,11 @@ include web/assets/tour/c9-s1.webp
include web/assets/tour/c10-person.webp
include web/assets/tour/c10-s1.mp4
include web/assets/tour/c10-s1.webp
+include web/assets/tour/c11-s1.mp4
+include web/assets/tour/c11-s1.webp
+include web/assets/tour/c12-s1.mp4
+include web/assets/tour/c12-s1.webp
+include web/assets/tour/c13-s1.mp4
+include web/assets/tour/c13-s1.webp
include web/assets/tour/c10-source.webp
include web/assets/tour/fox-sheet.webp
diff --git a/freevideo_engine/generate.py b/freevideo_engine/generate.py
index b91e6f4..f470569 100644
--- a/freevideo_engine/generate.py
+++ b/freevideo_engine/generate.py
@@ -843,6 +843,9 @@ def _run(args):
from .continuation import first_frame_prompt
prompt_text = first_frame_prompt(prompt_text)
prompt_text = without_music(prompt_text)
+ # The model has no negative prompt: sound the user excluded is worded as the sounds the scene has.
+ from .sound_prompt import positive_sound
+ prompt_text = positive_sound(prompt_text)
encoding = {'prompt': prompt_text, 'encoder': args.encoder,
'comfy_root': str(args.comfy_root or comfy_root()),
'model_paths': str(args.model_paths.resolve()) if args.model_paths else None,
diff --git a/freevideo_engine/pool_resources.py b/freevideo_engine/pool_resources.py
index c90eff5..59c229c 100644
--- a/freevideo_engine/pool_resources.py
+++ b/freevideo_engine/pool_resources.py
@@ -231,4 +231,35 @@ class PromptEnvelope:
# Reserve the full device capacity for future WDDM allocation, following
# runtime.gpu_commit_reserve, with no credit for already reserved VRAM.
gpu_commit = max(device.total_bytes for device in self.devices) if windows() else 0
+ if len(self.devices) >= 2:
+ # The measured private peak is for the reference request; larger canvases,
+ # attached media and continuations add what the workspace estimate adds.
+ reference = geometry(1344, 768, frames=243)
+ reference_workspace = (HOST_WEIGHT_HEADROOM + ENCODER_HOST_BYTES + residual_host_headroom(reference)
+ + decoder_workspace(reference) + 3 * (1344 * 768 * 243 * 3)
+ + UPSCALER_HOST_BYTES + adaln_extra_bytes(reference))
+ return multi_gpu_envelope(self.devices, gpu_commit, max(0, workspace - reference_workspace))
return Envelope(host, host - pinned + gpu_commit, pinned)
+
+
+GIB = 1 << 30
+# Two or more GPUs: measured per-task host use of one resident worker. Private
+# anonymous memory peaked at 6.4 GiB on the largest admitted request; pinned
+# weights follow each card's placement, 16.9 GiB on 16 GB-class cards and
+# 8.9 GiB on 24 GB-class cards, and cards of 32 GB and above are bounded by the
+# 24 GB figure. Mapped weight files add 0.3-0.5 GiB of page cache once per machine.
+PRIVATE_TASK_BYTES = int(7.5 * GIB)
+MAPPED_ONCE_BYTES = GIB // 2
+PINNED_SMALL_CARD_BYTES = 17 * GIB
+PINNED_LARGE_CARD_BYTES = 9 * GIB
+SMALL_CARD_LIMIT_BYTES = 20 * GIB
+multi_gpu_calls = 0
+
+
+def multi_gpu_envelope(devices, gpu_commit, extra_private=0):
+ global multi_gpu_calls
+ multi_gpu_calls += 1
+ smallest = min(device.total_bytes for device in devices)
+ pinned = PINNED_SMALL_CARD_BYTES if smallest < SMALL_CARD_LIMIT_BYTES else PINNED_LARGE_CARD_BYTES
+ host = PRIVATE_TASK_BYTES + extra_private + MAPPED_ONCE_BYTES + pinned
+ return Envelope(host, host - pinned + gpu_commit, pinned)
diff --git a/freevideo_engine/sound_prompt.py b/freevideo_engine/sound_prompt.py
new file mode 100644
index 0000000..8fb8c31
--- /dev/null
+++ b/freevideo_engine/sound_prompt.py
@@ -0,0 +1,78 @@
+"""Positive sound wording for the text encoder.
+
+The model has no negative prompt, so "no music" only draws attention to music. Sound requests that
+exclude something are replaced by the sounds the scene actually has. A prompt that asks for music
+is returned unchanged, and quoted or tagged speech is never edited. A prompt with spoken lines, quoted or described, gets no added
+sentence either: it only lost the excluded sound words, because the sentence made the spoken lines less accurate.
+"""
+import re
+
+from .prompt_vlm.rules import QUOTED, QUOTES
+
+MUSIC = (r'(?:background\s+music|music|soundtrack|BGM|cinematic\s+(?:orchestral\s+)?score|orchestral\s+score|song|'
+ r'背景音乐|音乐|配乐|歌曲|歌声)')
+PERFORMED = (r'(?:\b(?:sings?|singing|singers?|bands?|DJ|whistl(?:e|es|ed|ing)|choir)\b|'
+ r'\b(?:plays?|playing|played)\s+(?:an?\s+|the\s+)?(?:\w+\s+)?(?:guitar|piano|violin|cello|drums?|saxophone|trumpet|flute|keyboard|harp|accordion|ukulele|bass)\b|'
+ r'唱歌|歌手|乐队|演奏|弹(?:吉他|钢琴)|拉(?:小提琴|大提琴)|吹(?:口哨|笛子|萨克斯)|口哨|打鼓|合唱)')
+ANY_MUSIC = r'(?:' + MUSIC + '|' + PERFORMED + ')'
+NEGATION = (r'(?:\b(?:no|without|avoid|exclude)\b|\bdo\s+not\s+(?:add|include|use|play)\b|'
+ r'请?(?:不要|别|不用|不需要|无需|不加|没有|去掉|去除|禁止|无)(?:任何|有|放|加|使用|出现)?)')
+SOUND_WORD = (r'(?:background\s+music|music|soundtrack|BGM|subtitles?|captions?|narration|voiceover|singing|audio|sound|'
+ r'背景音乐|音乐|配乐|歌曲|歌声|字幕|旁白|解说|声音|音效)')
+# An exclusion is cut out only when it ends the clause; "no music at all" or "没有音乐的派对" would be left broken.
+NEGATED = re.compile(r'(?:(?:[,,]\s*)|\b(?:with|and|but|plus)\s+)?' + NEGATION + r'\s*(?:any\s+)?' + SOUND_WORD +
+ r'(?:\s+(?:or|and)\s+(?:music|subtitles?|captions?|narration|voiceover)|[和或及、]\s*(?:音乐|背景音乐|字幕|旁白|解说|音效))*'
+ r'(?:\s+of\s+[^,.;,。]*)?(?=\s*(?:[,,;;.。!?!?]|$))', re.I)
+SILENT = re.compile(r'\bsilent\b|\bmute\b|\bno\s+(?:sound|audio)\b(?!\s+of)|无声|静音', re.I)
+TAGGED = re.compile(r'<(d|en|zh|ja|ko|cn)>.*?</\1>', re.S)
+SOUNDSCAPE = re.compile(r'(?m)^[ \t]*overall_soundscape[ \t]*:')
+CLAUSE_EN = 'The sounds in the scene are the natural sounds of what is happening and its surroundings.'
+CLAUSE_ZH = '画面里的声音是正在发生的动作和周围环境自然发出的声音。'
+SPEECH = re.compile(r'\b(?:says?|said|speaks?|speaking|talks?|talking|whispers?|shouts?|asks?|replies|tells?|announces?)\b|'
+ r'说|讲|喊|问|答|念|朗读|台词|对白', re.I)
+CHINESE = re.compile(r'[一-鿿]')
+
+
+def _protect(prompt):
+ """Prompt with quoted and tagged speech swapped for placeholders, and the saved pieces."""
+ kept = []
+
+ def save(match):
+ kept.append(match.group())
+ return '\x00%d\x00' % (len(kept) - 1)
+
+ return QUOTED.sub(save, TAGGED.sub(save, prompt)), kept
+
+
+def _restore(text, kept):
+ return re.sub('\x00(\\d+)\x00', lambda m: kept[int(m.group(1))], text)
+
+
+def wants_music(prompt):
+ """True when music is requested. Negated mentions and the visual 'music video' style are not requests."""
+ body, _ = _protect(prompt)
+ excluded = any(re.search(MUSIC, m.group(), re.I) for m in NEGATED.finditer(body))
+ body = NEGATED.sub('', body)
+ body = re.sub(r'\bmusic\s+video\b|\bMV\b|音乐视频', '', body, flags=re.I)
+ # Music that was explicitly excluded is not requested back by someone who sings or plays in the scene.
+ return bool(re.search(MUSIC if excluded else ANY_MUSIC, body, re.I))
+
+
+def positive_sound(prompt):
+ if not prompt.strip() or SOUNDSCAPE.search(prompt) or wants_music(prompt):
+ return prompt
+ body, kept = _protect(prompt.strip())
+ if SILENT.search(body):
+ return prompt
+ chinese = bool(CHINESE.search(body))
+ body = re.sub(r'\bmusic\s+video\b', '\x01', body, flags=re.I)
+ body = NEGATED.sub('', body)
+ body = re.sub(r'\s+([,.;!?])', r'\1', body)
+ body = re.sub(r'[,,;;]\s*(?=[,,;;.。!?!?]|$)', '', body)
+ body = re.sub(r'([.。!?!?])(?:\s*[.。])+', r'\1', body).strip(' ,,;;').lstrip('.。 ').replace('\x01', 'music video')
+ clause = CLAUSE_ZH if chinese else CLAUSE_EN
+ if kept or SPEECH.search(body) or clause in _restore(body, kept):
+ return _restore(body, kept)
+ if body and _restore(body, kept)[-1] not in '.。!?!?' + ''.join(QUOTES.values()):
+ body += '。' if chinese else '.'
+ return (_restore(body, kept) + ' ' + clause).strip()
diff --git a/freevideo_source_bootstrap.py b/freevideo_source_bootstrap.py
index fcc4c46..0a5cd05 100644
--- a/freevideo_source_bootstrap.py
+++ b/freevideo_source_bootstrap.py
@@ -105,6 +105,12 @@ TOUR_FILES = frozenset((
'web/assets/tour/c10-person.webp',
'web/assets/tour/c10-s1.mp4',
'web/assets/tour/c10-s1.webp',
+ 'web/assets/tour/c11-s1.mp4',
+ 'web/assets/tour/c11-s1.webp',
+ 'web/assets/tour/c12-s1.mp4',
+ 'web/assets/tour/c12-s1.webp',
+ 'web/assets/tour/c13-s1.mp4',
+ 'web/assets/tour/c13-s1.webp',
'web/assets/tour/c10-source.webp',
'web/assets/tour/fox-sheet.webp',
))
diff --git a/web/agent_connect.css b/web/agent_connect.css
index 5e78fdc..73d6538 100644
--- a/web/agent_connect.css
+++ b/web/agent_connect.css
@@ -41,6 +41,7 @@
.fv-header:has(.fv-autopilot-now:not([hidden])) .fv-header-actions>button{flex:none}
/* Compact spacing only once the column is short of room, so wide headers keep their idle rhythm. */
@container fv-autopilot-actions (max-width:671px){.fv-header:has(.fv-autopilot-now:not([hidden])) .fv-header-actions>button{padding-inline:5px}}
+@container fv-autopilot-actions (max-width:632px){.fv-autopilot .fv-header:has(.fv-autopilot-now:not([hidden])) .fv-autopilot-lamp:lang(zh){width:30px;height:30px;padding:0;justify-content:center}.fv-autopilot .fv-header:has(.fv-autopilot-now:not([hidden])) .fv-autopilot-lamp:lang(zh)>span{display:none}}
.fv-header:has(.fv-autopilot-now:not([hidden])) .fv-autopilot-now{flex:0 1 auto;min-width:0}
.fv-studio .fv-header:has(.fv-autopilot-now:not([hidden])) .fv-autopilot-now-go{flex:0 1 auto;min-width:0;gap:5px;padding-left:8px}
.fv-header:has(.fv-autopilot-now:not([hidden])) .fv-autopilot-now-go>:not(.fv-autopilot-now-name){flex:none}
diff --git a/web/assets/tour/c11-s1.mp4 b/web/assets/tour/c11-s1.mp4
new file mode 100644
index 0000000..60506e4
Binary files /dev/null and b/web/assets/tour/c11-s1.mp4 differ
diff --git a/web/assets/tour/c11-s1.webp b/web/assets/tour/c11-s1.webp
new file mode 100644
index 0000000..ef5c009
Binary files /dev/null and b/web/assets/tour/c11-s1.webp differ
diff --git a/web/assets/tour/c12-s1.mp4 b/web/assets/tour/c12-s1.mp4
new file mode 100644
index 0000000..61abd00
Binary files /dev/null and b/web/assets/tour/c12-s1.mp4 differ
diff --git a/web/assets/tour/c12-s1.webp b/web/assets/tour/c12-s1.webp
new file mode 100644
index 0000000..ca90cf2
Binary files /dev/null and b/web/assets/tour/c12-s1.webp differ
diff --git a/web/assets/tour/c13-s1.mp4 b/web/assets/tour/c13-s1.mp4
new file mode 100644
index 0000000..6d847e3
Binary files /dev/null and b/web/assets/tour/c13-s1.mp4 differ
diff --git a/web/assets/tour/c13-s1.webp b/web/assets/tour/c13-s1.webp
new file mode 100644
index 0000000..338bb14
Binary files /dev/null and b/web/assets/tour/c13-s1.webp differ
diff --git a/web/autopilot.js b/web/autopilot.js
index 7fe1155..9eb380e 100644
--- a/web/autopilot.js
+++ b/web/autopilot.js
@@ -8,7 +8,7 @@ import { openEditorView } from './editor_loader.js';
import { closeDialog } from './motion.js';
import { productVersion } from './updates.js';
import { openSetup } from './setup.js';
-import { feedbackButton } from './feedback.js';
+import { feedbackButton, guideButton } from './feedback.js';
import { openExtendEditor, openStudio, showNodes } from './studio.js';
import { agentTabReady, viewChanged, viewSwitch } from './view_navigation.js';
import { wordmark } from './wordmark.js';
@@ -37,7 +37,7 @@ export function openAutopilotView(node, {studio = null, initialPrompt = '', init
halt.title = t('Stop all', '全部停止'); halt.setAttribute('aria-label', halt.title);
const line = el('i', 'fv-autopilot-line');
const phoneAccess = createLanAccess(t, api);
- tools.append(now, lamp, phoneAccess.element, feedbackButton(t), settings);
+ tools.append(now, lamp, phoneAccess.element, guideButton(t), feedbackButton(t), settings);
// The view chosen next takes over once this page has closed; Escape goes back to what is underneath.
let next = () => studio?.open ? viewChanged('studio', node) : viewChanged('nodes', node);
const leave = action => { next = action; closeDialog(dialog); };
diff --git a/web/cast_library.js b/web/cast_library.js
index 0f21f51..d06ebb6 100644
--- a/web/cast_library.js
+++ b/web/cast_library.js
@@ -42,7 +42,7 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()
const avatars = el('div', 'fv-cast-avatars');
const skipped = el('div', 'fv-cast-unreadable'); skipped.hidden = true;
const add = button('fv-cast-add', '+', () => openDialog());
- add.setAttribute('aria-label', word(text('New character', '新建角色'), text('New scene', '新建场景')));
+ add.setAttribute('aria-label', word(text('New character', '新建角色'), text('New scene', '新建场景'))); add.dataset.tourId = 'cast-add';
element.append(heading, avatars, add, skipped);
async function value(response) {
diff --git a/web/editor.css b/web/editor.css
index 9bb0997..667f5c4 100644
--- a/web/editor.css
+++ b/web/editor.css
@@ -253,7 +253,8 @@
.fv-studio.fv-editor .fv-header[data-fit~=wrap]>.fv-view-switch{grid-column:1/-1;grid-row:2;justify-self:center}
.fv-studio.fv-editor .fv-header[data-fit~=wrap]>.fv-header-actions{grid-column:2;grid-row:1}
.fv-studio.fv-editor .fv-header[data-fit~=wrap] .fv-ed-name{max-width:320px}
-.fv-studio.fv-editor .fv-header[data-fit~=lean] .fv-feedback-entry{display:none}
+.fv-studio.fv-editor .fv-header[data-fit~=lean] .fv-feedback-entry:not(.fv-guide-entry){display:none}
+.fv-studio.fv-editor .fv-header[data-fit~=least] .fv-guide-entry{display:none}
.fv-ed-volume-popover{position:absolute;top:calc(100% + 8px);left:0;display:flex;align-items:center;gap:8px;padding:10px 12px;border:1px solid var(--fv-border);border-radius:8px;background:var(--fv-card);white-space:nowrap;z-index:8}
.fv-ed-volume{width:90px}.fv-ed-volume-value{font-variant-numeric:tabular-nums;font-size:12px;min-width:34px}
diff --git a/web/editor.js b/web/editor.js
index b64a124..fd7cfb1 100644
--- a/web/editor.js
+++ b/web/editor.js
@@ -6,13 +6,15 @@ import {isText} from './editor_text_model.js';
import {viewSwitch, viewChanged} from './view_navigation.js';
import {wordmark} from './wordmark.js';
import {openSetup} from './setup.js';
-import {feedbackButton} from './feedback.js';
+import {feedbackButton, guideButton} from './feedback.js';
import {issueButton} from './issue_button.js';
import * as model from './editor_model.js';
import {discardEmptyEdit, hiddenEmptyEdit, deleteEditText} from './editor_lifecycle.js';
import {createEditorState} from './editor_state.js';
import {createEditorStore, sourceKey, mediaURL} from './editor_store.js';
import {generationSize, continuedSize} from './editor_generation.js';
+import {uploadMedia} from './media_upload.js';
+import {checkOriginal} from './audio_original.js';
import {createEditorLibrary} from './editor_library.js';
import {createEditorPlayer} from './editor_player.js';
import {createEditorTransport, registerEditorShortcuts} from './editor_transport.js';
@@ -209,7 +211,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
const top = el('header', 'fv-header fv-ed-top'), libraryHost = el('aside', 'fv-ed-library'), preview = el('section', 'fv-ed-preview'),
transport = el('div', 'fv-ed-transport'), genHost = el('div', 'fv-ed-genbar'), tracksHost = el('div', 'fv-ed-tracks'), zoomHost = el('div', 'fv-ed-zoom');
const adjustHost = el('aside', 'fv-ed-adjust-host');
- tracksHost.dataset.fvGuide = 'editor-timeline';
+ tracksHost.dataset.fvGuide = 'editor-timeline'; tracksHost.dataset.tourId = 'editor-timeline';
const button = (label, action, cls = '') => { const value = el('button', cls, label); value.type = 'button'; value.onclick = action; return value; };
const navigation = viewSwitch('editor', () => handle.switchView('studio'), () => handle.switchView('nodes'), () => {}, () => handle.switchView('autopilot'));
for (const control of navigation.querySelectorAll('button')) control.removeAttribute('title');
@@ -230,7 +232,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
exportBox.append(exportHint, exportButton, exportCancel); brand.append(wordmark(), title);
const phoneAccess = createLanAccess(t, api);
listeners.push(phoneAccess.dispose);
- headerActions.append(exportBox, phoneAccess.element, feedbackButton(t), button(t('Settings', '设置'), openSetup, 'fv-quiet'));
+ headerActions.append(exportBox, phoneAccess.element, guideButton(t), feedbackButton(t), button(t('Settings', '设置'), openSetup, 'fv-quiet'));
top.append(brand, navigation, headerActions);
const headerFit = fitEditorHeader(top, brand, title, navigation, headerActions);
const menu = el('div', 'fv-ed-name-menu'); menu.hidden = true; menu.setAttribute('role', 'menu');
@@ -259,7 +261,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
let stems = null, disposed = false, suppressSave = false, savedContent = '', initializing = true, tracks = null, genbar = null, adjustPanel = null, exportStatus = null, pointerEditing = false, deferredStamp = null;
let capability = {maxSeconds: 15, maxFollowSeconds: 15, maxRequestFrames: null, estimate: () => null}, generationBusy = false, switching = false, generationDone = null, finishGeneration = null;
let noticeTimer = null, stopExport = null, mostRecentJob = null, exportPreparing = false, guide = null;
- const jobWatchers = new Map(), progress = new Map(), jobStatuses = new Map(), runProgress = new Map();
+ const jobWatchers = new Map(), progress = new Map(), jobStatuses = new Map(), runProgress = new Map(), startPlayheads = new Map(), soundJobs = new Set(), shownJobs = new Set();
const failures = createEditorFailures({api, state, jobStatuses, reasonText: value => editorErrorText(value, t)});
let submissionFailure = null;
let blockStates = null, progressObserver = null, progressConnection = null;
@@ -586,6 +588,28 @@ export function openEditor({api, app, from = null, panel = {}, components: given
delete inputs.continue_from; delete inputs.continue_to;
return {node: String(value.node), prompt: value.prompt, ...(value.extra_data ? {extra_data: value.extra_data} : {}), ...(api.clientId ? {client_id: api.clientId} : {})};
}
+ // A part drawn over imported sound follows that sound as it is: the picture is made for the range of the file the
+ // parts cover, and the sound itself is kept.
+ async function followSound(frozen, record, ids) {
+ const videos = ids.map(id => model.find(record, id)).filter(Boolean).sort((a, b) => a.start - b.start);
+ const sound = videos.map(clip => model.find(record, clip.link));
+ if (!videos.length || sound.some(clip => clip?.source?.kind !== 'import' || store.sources.get(sourceKey(clip.source))?.has_video !== false)) return;
+ const source = sound[0].source, metadata = store.sources.get(sourceKey(source));
+ const blob = await (await fetch(metadata.audio)).blob(), extension = /\.[a-z0-9]{1,5}$/i.exec(String(metadata.name || metadata.path || ''))?.[0] || '.wav';
+ const {file} = await uploadMedia(api, new File([blob], `editor-${source.id}${extension}`, {type: blob.type}));
+ const rate = (await checkOriginal(api, {file})).sample_rate;
+ if (!(rate > 0)) throw new Error('audio_unusable');
+ const first = Math.round(sound[0].in * rate / model.FPS), frames = videos.reduce((sum, clip) => sum + clip.frames, 0);
+ const row = {file, role: 'reference', use: 'original', range: {start_sample: first, end_sample: first + Math.round(frames * rate / model.FPS)}};
+ const inputs = frozen.prompt[frozen.node].inputs, held = frozen.prompt[String(inputs.media?.[0])];
+ if (held?.class_type === 'FreeVideoMedia') {
+ const rows = JSON.parse(held.inputs.assets || '[]').filter(item => item.use !== 'original');
+ held.inputs.assets = JSON.stringify([...rows, row]);
+ } else {
+ const id = String(1 + Math.max(0, ...Object.keys(frozen.prompt).map(Number).filter(Number.isFinite)));
+ frozen.prompt[id] = {class_type: 'FreeVideoMedia', inputs: {assets: JSON.stringify([row])}}; inputs.media = [id, 0];
+ }
+ }
function pinStoppedJob(record, ids, job) {
return model.settle(record, ids.filter(id => model.attemptClip(record, id)?.job === job), 'stopped');
}
@@ -596,6 +620,10 @@ export function openEditor({api, app, from = null, panel = {}, components: given
return ['queued', 'running', 'cancelling'].includes(previous.state);
failures.reconcile(job, previous);
mostRecentJob = job.id; jobStatuses.set(job.id, job); paintJob(job);
+ if (!startPlayheads.has(job.id)) startPlayheads.set(job.id, state.playhead);
+ // Whether the job follows imported sound is read before a result replaces the sound's link target.
+ if (!soundJobs.has(job.id) && (job.blocks || []).some(block => { const heard = model.find(state.record, model.attemptClip(state.record, block.id)?.link);
+ return heard?.source?.kind === 'import' && store.sources.get(sourceKey(heard.source))?.has_video === false; })) soundJobs.add(job.id);
genbar?.update(barJob(job));
const completed = new Set();
for (const block of job.blocks || []) {
@@ -616,6 +644,13 @@ export function openEditor({api, app, from = null, panel = {}, components: given
// Validate the current clip first so a bad receipt is visible.
model.fill(state.record, block.id, result);
state.settle(record => model.fill(record, block.id, result));
+ // A sound-led result the playhead has not reached is shown from its first frame, once per job and unless the viewer moved on meanwhile.
+ const done = model.find(state.record, block.id), picked = state.selection;
+ if (done && soundJobs.has(job.id) && !shownJobs.has(job.id)) {
+ shownJobs.add(job.id);
+ if (picked?.kind === 'clip' && picked.ids.includes(block.id) && !player.playing && state.playhead === startPlayheads.get(job.id)
+ && !(state.playhead >= done.start && state.playhead < done.start + done.frames)) state.seek(done.start);
+ }
} catch (value) {
if (!(value instanceof model.EditError)) throw value;
state.settle(record => model.fail(record, block.id, 'result_mismatch', job.id));
@@ -904,6 +939,11 @@ export function openEditor({api, app, from = null, panel = {}, components: given
}
catch (value) { if (value instanceof model.EditError) return value.code === 'busy'; throw value; }
},
+ // A range with no picture over imported sound: the picture is made to follow that sound.
+ soundLed(selection = state.selection) {
+ const range = selection?.kind === 'range' && selectionRange(selection);
+ return !!range && !!model.soundRange(state.record, range.start, range.frames);
+ },
// Another part generating is no reason: the server runs parts one after another.
canGenerate(text, selection = state.selection) {
return store.generationAvailable && actions.supportedSelection(selection) && (!!text.trim() || !actions.needsText(selection));
@@ -1077,6 +1117,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
if ('preview' in inputs || previewing) inputs.preview = previewing && alone;
if ('refine_from' in inputs) inputs.refine_from = '';
}
+ await followSound(frozen, prepared, ids);
if (allowEmpty === true && [text, ...Object.values(texts ?? {})].some(value => !value.trim())) allowEmptyPrompt({output: frozen.prompt}, frozen.node);
// Parts made at another size than the edit's have that size's limit.
const limit = (follow && (follow.width !== edit.width || follow.height !== edit.height)
diff --git a/web/editor_adjust.js b/web/editor_adjust.js
index ed90610..206fc4f 100644
--- a/web/editor_adjust.js
+++ b/web/editor_adjust.js
@@ -48,7 +48,7 @@ function selectedContext(state, t, actions) {
export function createAdjustPanel(host, {state, t, actions}) {
const shell = host.closest('.fv-editor'), uid = `fv-ed-adjust-${++serial}`;
host.classList.add('fv-ed-adjust-host');
- const element = el('section', 'fv-ed-adjust'); element.id = uid;
+ const element = el('section', 'fv-ed-adjust'); element.id = uid; element.dataset.tourId = 'editor-inspector';
element.setAttribute('aria-label', t('Adjust', '调整'));
const tabs = el('div', 'fv-ed-tabs fv-pass-mode'); tabs.setAttribute('role', 'tablist');
tabs.setAttribute('aria-label', t('Adjust', '调整'));
@@ -56,7 +56,7 @@ export function createAdjustPanel(host, {state, t, actions}) {
const buttons = new Map(), panes = new Map(), entries = new Map();
const toggleButton = button('', {onClick: () => overlay ? close({restoreFocus: true}) : open()});
toggleButton.append(editorIcon('adjust')); toggleButton.setAttribute('aria-label', t('Adjust', '调整')); toggleButton.title = t('Adjust', '调整');
- toggleButton.classList.add('fv-ed-adjust-toggle'); toggleButton.setAttribute('aria-controls', uid);
+ toggleButton.classList.add('fv-ed-adjust-toggle'); toggleButton.dataset.tourToggle = 'editor-inspector'; toggleButton.setAttribute('aria-controls', uid);
const labels = {video: t('Video', '画面'), audio: t('Audio', '声音'), speed: t('Speed', '速度'), text: t('Text', '文字'), subtitle: t('Subtitles', '字幕')};
for (const kind of kinds) {
const tab = button(labels[kind], {onClick: () => activate(kind)});
diff --git a/web/editor_audio.css b/web/editor_audio.css
index 0a64fc8..f92cf08 100644
--- a/web/editor_audio.css
+++ b/web/editor_audio.css
@@ -12,8 +12,9 @@
.fv-ed-track-row[data-locked=true],.fv-ed-track-row[data-locked=true] *{cursor:not-allowed!important}
.fv-ed-audio-fades{position:absolute;inset:3px 0;width:100%;height:calc(100% - 6px);fill:none;stroke:var(--fv-ink);stroke-width:1.5;pointer-events:none;z-index:2}
.fv-ed-audio-fades path{vector-effect:non-scaling-stroke}
-.fv-ed-track-view .fv-ed-audio-junction{position:absolute;top:50%;width:10px;height:10px;transform:translate(-50%,-50%) rotate(45deg);padding:0;background:var(--fv-card);border:1px solid var(--fv-accent);border-radius:1px;z-index:7;opacity:0;cursor:pointer}
+.fv-ed-track-view .fv-ed-audio-junction{position:absolute;top:50%;box-sizing:border-box;width:10px;height:10px;min-width:0;min-height:0;transform:translate(-50%,-50%) rotate(45deg);padding:0;background:var(--fv-card);border:1px solid var(--fv-accent);border-radius:1px;z-index:7;opacity:0;cursor:pointer}
.fv-ed-audio-junction:hover,.fv-ed-audio-junction:focus-visible,.fv-ed-audio-junction[data-active=true]{opacity:1!important}
+.fv-ed-track-view .fv-ed-audio-junction:disabled{opacity:0!important;pointer-events:none}
.fv-ed-audio-junction[data-active=true]{background:var(--fv-accent)!important}
.fv-ed-audio-junction[aria-pressed=true]{box-shadow:0 0 0 2px var(--fv-card),0 0 0 3px var(--fv-accent)}
.fv-ed-audio-notice{position:absolute;z-index:12;padding:5px 8px;border:1px solid var(--fv-border);border-radius:6px;background:var(--fv-card);color:var(--fv-ink);font-size:12px;pointer-events:none}
diff --git a/web/editor_first_frame.js b/web/editor_first_frame.js
index f2ae48a..6701ca5 100644
--- a/web/editor_first_frame.js
+++ b/web/editor_first_frame.js
@@ -7,7 +7,7 @@ export const firstFrameOn = record => record.settings?.[FIRST_FRAME_KEY] === tru
// actions.setFirstFrame(value): saves the choice with the project.
export function createFirstFrameSwitch(host, {state, t, actions}) {
const {row, input, setDisabled} = firstFrameRow(t, 'fv-ed-first-frame');
- host.append(row);
+ row.dataset.tourId = 'editor-first-frame'; host.append(row);
let shown = false;
// While generating the row stays as it was and cannot be changed.
function update(busy = false) {
diff --git a/web/editor_genbar.js b/web/editor_genbar.js
index 5bb35ff..2ba29e2 100644
--- a/web/editor_genbar.js
+++ b/web/editor_genbar.js
@@ -195,7 +195,9 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
// A choice that will move to an empty spot can still be described first.
const writable = selected || !previewSelection && !!selection && !!actions.selectionMovable?.();
input.disabled = !writable || busy;
- input.placeholder = !writable ? '' : musical ? t('Describe the music', '描述配乐') : t('Describe this part', '描述这一段');
+ const sound = writable && !musical && !!actions.soundLed?.();
+ input.placeholder = !writable ? '' : musical ? t('Describe the music', '描述配乐') : sound ? t('Describe the picture', '描述画面') : t('Describe this part', '描述这一段');
+ if (sound) host.dataset.tourId = 'video-empty-range'; else delete host.dataset.tourId;
input.setAttribute('aria-label', t('Description', '描述'));
generate.classList.toggle('fv-primary', selected && !busy);
// A cancel already accepted is not offered again; the bar says it is stopping until the run ends.
diff --git a/web/editor_header_fit.js b/web/editor_header_fit.js
index b446821..c708306 100644
--- a/web/editor_header_fit.js
+++ b/web/editor_header_fit.js
@@ -1,6 +1,7 @@
// The view switch stays centred in the editor's header while the project name next to the logo stays readable.
// When it would not, the logo first takes its phone size, then gives its place to the name; if that is still too tight, the switch moves to a second row.
// The feedback entry leaves before the switch moves down, and on two rows when the name is still tight.
+// The Tutorial entry stays on two rows, and leaves after the feedback entry only to keep the switch on one row.
// About six Chinese characters or ten Latin letters of the name itself, without the menu arrow.
const READABLE = 120, COMPACT_MARK = 90;
@@ -25,14 +26,18 @@ export function fitEditorHeader(header, brand, title, navigation, actions) {
// On two rows the name shares the first row with the actions only; the logo shrinks too when that is still tight.
const row = markWidth => inner - need - gap - markWidth - spacing;
// The feedback entry is the first action to leave this header (it stays in the other views).
- const feedback = actions.querySelector('.fv-feedback-entry'), spare = feedback ? feedback.offsetWidth + apart : 0;
+ const feedback = actions.querySelector('.fv-feedback-entry:not(.fv-guide-entry)'), spare = feedback ? feedback.offsetWidth + apart : 0;
// From 681 px up the switch has one place in every view, so the logo, then the feedback entry, leave before the switch moves down.
const wide = !matchMedia('(max-width:680px)').matches, bare = room => wide && side >= room && side >= wanted;
// Before the feedback entry, the phone entry steps aside.
+ // The Tutorial entry leaves last, only where the switch would otherwise drop to a second row (it stays in the other views).
+ const guide = actions.querySelector('.fv-guide-entry'), room = guide ? guide.offsetWidth + apart : 0;
const lan = actions.querySelector('.fv-lan'), away = lan ? lan.offsetWidth + apart : 0;
// The phone entry also steps aside rather than let the view switch drop to a second row.
const fitsWithout = markWidth => side >= need - away && side - markWidth - spacing >= wanted;
- const fit = fits(mark.offsetWidth) ? '' : fits(compact) ? 'compact' : away && fitsWithout(mark.offsetWidth) ? 'tight' : away && fitsWithout(compact) ? 'compact tight' : bare(need) ? 'bare' : away && bare(need - away) ? 'bare tight' : away && spare && bare(need - away - spare) ? 'bare tight lean' : spare && bare(need - spare) ? 'bare lean'
+ // Then the feedback entry steps aside too, rather than let the switch drop to a second row.
+ const fitsLean = markWidth => spare && side >= need - away - spare && side - markWidth - spacing >= wanted;
+ const fit = fits(mark.offsetWidth) ? '' : fits(compact) ? 'compact' : away && fitsWithout(mark.offsetWidth) ? 'tight' : away && fitsWithout(compact) ? 'compact tight' : away && fitsLean(mark.offsetWidth) ? 'tight lean' : away && fitsLean(compact) ? 'compact tight lean' : bare(need) ? 'bare' : away && bare(need - away) ? 'bare tight' : away && spare && bare(need - away - spare) ? 'bare tight lean' : away && spare && room && bare(need - away - spare - room) ? 'bare tight lean least' : spare && bare(need - spare) ? 'bare lean'
: row(mark.offsetWidth) >= wanted ? 'wrap' : row(compact) >= wanted || !spare ? 'wrap compact' : 'wrap compact lean';
if (fit) header.dataset.fit = fit;
}
diff --git a/web/editor_model.js b/web/editor_model.js
index 3838930..18216e1 100644
--- a/web/editor_model.js
+++ b/web/editor_model.js
@@ -663,11 +663,30 @@ export function split(record, id, frame, {by = 'user'} = {}) {
if (rights.length === 2) { rights[0].link = rights[1].id; rights[1].link = rights[0].id; }
return finish(next);
}
+// The sound under a picture planned to follow it: the imported sound, not a clip of its own.
+const soundMate = (record, clip) => {
+ // A placeholder of a replacement is held by its transaction; this one has none and borrows the sound's source.
+ const mate = clip.pending && clip.link && !(record.replacements || []).some(tx => [...tx.originals, ...tx.clips].some(t => t.clips.some(c => c.id === clip.id))) ? find(record, clip.link) : null;
+ return mate?.source?.kind === 'import' && mate.pending && clip.source && key(clip.source) === key(mate.source) && trackBy(record, 'a1').clips.includes(mate) ? mate : null;
+};
export function remove(record, ids) {
assertUnlocked(record, ids);
check(Array.isArray(ids), 'id'); const selected = linkedIds(record, ids);
busy(all(record).filter(clip => selected.has(clip.id)));
- const next = copy(record); for (const track of next.tracks) track.clips = track.clips.filter(clip => !selected.has(clip.id));
+ // Discarding a planned picture that follows imported sound leaves the sound as it was before the plan.
+ const kept = new Set(trackBy(record, 'v1').clips.filter(clip => selected.has(clip.id)).map(clip => soundMate(record, clip)?.id).filter(Boolean));
+ const next = copy(record);
+ for (const track of next.tracks) track.clips = track.clips.filter(clip => !selected.has(clip.id) || kept.has(clip.id));
+ if (kept.size) {
+ for (const id of kept) Object.assign(find(next, id), {link: null, part: null, text: '', pending: null, reason: null, job: null});
+ const a1 = trackBy(next, 'a1'), plain = clip => kept.has(clip.id) || isSound(clip);
+ a1.clips.sort((a, b) => a.start - b.start);
+ for (let i = a1.clips.length - 1; i > 0; i--) {
+ const [a, b] = [a1.clips[i - 1], a1.clips[i]];
+ if ((kept.has(a.id) || kept.has(b.id)) && plain(a) && plain(b) && end(a) === b.start && key(a.source) === key(b.source)
+ && a.in + a.frames === b.in && a.volume === b.volume && a.length === b.length) { a.frames += b.frames; a1.clips.splice(i, 1); }
+ }
+ }
return finish(next);
}
export function closeGap(record, trackId, frame) {
@@ -987,6 +1006,23 @@ function layoutPlanned(record, id, edge, frame, limits = {}) {
}
return next;
}
+// Imported sound with no picture of its own, on the first sound row.
+const isSound = clip => clip.source?.kind === 'import' && !clip.link && !clip.pending;
+// Whether [start, start + frames) is empty on the picture row and lies within one piece of imported sound.
+export function soundRange(record, start, frames) {
+ if (!whole(start) || !whole(frames, 1) || trackBy(record, 'v1').clips.some(clip => overlaps(clip, start, frames))) return null;
+ const clips = trackBy(record, 'a1').clips.filter(clip => overlaps(clip, start, frames));
+ if (!clips.length || !clips.every(isSound) || record.tracks.find(track => track.id === 'a2')?.clips.some(clip => overlaps(clip, start, frames))) return null;
+ return clips.length === 1 && clips[0].start <= start && end(clips[0]) >= start + frames ? clips[0] : null;
+}
+function cutSound(record, start, frames) {
+ let next = record;
+ for (const frame of [start, start + frames]) {
+ const clip = trackBy(next, 'a1').clips.find(item => item.start < frame && end(item) > frame);
+ if (clip) next = split(next, clip.id, frame);
+ }
+ return next;
+}
export function planRange(record, {start, frames, parts, target = 'both', text = '', by = 'user', maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds}) {
check(TEXT_BY.includes(by), 'text');
check(whole(start) && whole(frames, 1), 'range'); check(['both', 'video', 'audio'].includes(target), 'target');
@@ -994,14 +1030,21 @@ export function planRange(record, {start, frames, parts, target = 'both', text =
check(typeof maxSeconds === 'number' && Number.isFinite(maxSeconds) && maxSeconds >= RULES.minSeconds, 'range');
check(target === 'both', 'unsupported');
if (!record.tracks.some(track => track.clips.some(clip => overlaps(clip, start, frames)))) frames = Math.max(RULES.minSeconds, Math.round(frames / FPS)) * FPS;
+ // A range with no picture over imported sound is drawn to follow that sound: the sound is cut at the range.
+ const ledBySound = !!soundRange(record, start, frames);
+ if (ledBySound) record = cutSound(record, start, frames);
const videoHits = trackBy(record, 'v1').clips.filter(clip => overlaps(clip, start, frames));
const audioHits = trackBy(record, 'a1').clips.filter(clip => overlaps(clip, start, frames));
const otherHits = record.tracks.filter(track => track.id === 'a2' || track.id === 'a3').flatMap(track => track.clips.filter(clip => overlaps(clip, start, frames)));
const hits = [...videoHits, ...audioHits];
+ const followsSound = ledBySound && !videoHits.length && audioHits.length > 0 && audioHits.every(isSound);
if (hits.length || otherHits.length) {
check(hits.length > 0, 'unsupported');
- check(videoHits.length && audioHits.length === videoHits.length, 'unsupported');
+ check(followsSound || videoHits.length && audioHits.length === videoHits.length, 'unsupported');
let boundary = start;
+ if (followsSound) {
+ for (const clip of audioHits) { check(clip.start === boundary && end(clip) <= start + frames && !otherHits.length, 'unsupported'); boundary = end(clip); }
+ }
for (const clip of videoHits) {
const mate = find(record, clip.link);
check(clip.start === boundary && end(clip) <= start + frames && mate && audioHits.includes(mate)
diff --git a/web/editor_tracks.js b/web/editor_tracks.js
index 3bd9334..5ab3c8a 100644
--- a/web/editor_tracks.js
+++ b/web/editor_tracks.js
@@ -576,7 +576,8 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
`${name},第 ${index + 1} 段,${seconds} 秒,${status}${seamText}`));
// Pending replacements can retain their old media; state styling
// overlays it until the model reports that the new media is done.
- item.media.hidden = visual !== 'done';
+ // The imported sound under a sound-led range is kept as it is, so its waveform stays in view while the picture is made.
+ item.media.hidden = visual !== 'done' && !(track.kind === 'audio' && clip.source?.kind === 'import' && key);
if (track.kind === 'video') {
updatePictureBadge(item.element, clip, record, clipPictureSize(clip, sources), t);
actions.blockNote?.(item, {noted, index, record});
diff --git a/web/feature_tour.css b/web/feature_tour.css
index fc646aa..c586682 100644
--- a/web/feature_tour.css
+++ b/web/feature_tour.css
@@ -43,3 +43,5 @@
.fv-feature-tour .fv-tour-close{position:relative;font-size:0}
.fv-tour-close::before,.fv-tour-close::after{content:'';position:absolute;left:10px;top:17px;width:16px;height:1px;background:currentColor;transform:rotate(45deg)}
.fv-tour-close::after{transform:rotate(-45deg)}
+.fv-tour-book{background:none;border:0;padding:6px 4px;color:inherit;font:inherit;text-decoration:underline;opacity:.75;cursor:pointer;flex:none;margin-right:auto;margin-left:12px}.fv-tour-book:hover,.fv-tour-book:focus-visible{opacity:1}
+@media (max-width:680px){.fv-tour-book{margin:0;align-self:center}}
diff --git a/web/feature_tour.js b/web/feature_tour.js
index b54fcec..cf65dce 100644
--- a/web/feature_tour.js
+++ b/web/feature_tour.js
@@ -3,9 +3,12 @@ import {readGuideRecord, saveGuideRecord, guideRecord} from './first_run_guide.j
import {isolateDialogKeys, listenDialogKey, routeDialogKey} from './dialog_keys.js';
export const TOUR_TEXT = {
- en: {examples: 'Feature examples', use: 'Use this example', next: 'Next', done: 'Done', close: 'Close'},
- zh: {examples: '功能示例', use: '用这个示例', next: '下一张', done: '完成', close: '关闭'},
+ en: {examples: 'Feature examples', use: 'Use this example', next: 'Next', goto: 'Take me there', book: 'Read the tutorial', done: 'Done', close: 'Close'},
+ zh: {examples: '功能示例', use: '用这个示例', next: '下一张', goto: '带我去', book: '看教程', done: '完成', close: '关闭'},
};
+// The chapter of the tutorial book that teaches the same thing as the card.
+const BOOK_CHAPTER = {'first-video': 'quick-start', 'text-to-video': 'text-to-video', 'first-last-frame': 'first-last-frame', 'quality-tiers': 'quality-tiers',
+ 'reference-image': 'reference-video', 'replace-person': 'replace-person', character: 'cast-sheet', 'edit-view': 'editor', extend: 'extend-video', 'two-pass': 'refine', autopilot: 'autopilot'};
const asset = name => new URL(`./assets/tour/${name}`, import.meta.url).href;
const el = (tag, cls, text) => { const node = document.createElement(tag); if (cls) node.className = cls; if (text != null) node.textContent = text; return node; };
const contexts = new Map();
@@ -160,7 +163,14 @@ export async function openFeatureTour({api = contextFor()?.api, cn = contextFor(
const use = el('button', 'fv-tour-use fv-primary', text.use);
const usable = card.tryit.status !== 'pending-assets' && contextFor()?.canTry?.(card.tryit) !== false;
use.onclick = async () => { await end(); await tryIt(card.id); };
- usable ? actions.append(next, use) : actions.append(next); footer.append(dots, actions); content.append(footer);
+ if (card.goto?.length) {
+ const go = el('button', 'fv-tour-goto', text.goto);
+ go.onclick = async () => { await end(); const {guideTo} = await import('./tour_goto.js'); for (const id of card.goto) if (await guideTo(id)) break; };
+ actions.append(go);
+ }
+ const chapter = BOOK_CHAPTER[card.id], read = chapter ? el('button', 'fv-tour-book', text.book) : null;
+ if (read) read.onclick = async () => { await end(); const {openTutorialBook} = await import('./tutorial_book.js'); openTutorialBook({chapter}); };
+ usable ? actions.append(next, use) : actions.append(next); footer.append(dots, actions); if (read) dots.after(read); content.append(footer);
for (const video of videos) video.onerror = () => {
stop(); const failed = loaded.splice(index, 1); release(failed);
if (!loaded.length) { end(); return; }
diff --git a/web/feature_tour_content.js b/web/feature_tour_content.js
index 2502541..d0e5a14 100644
--- a/web/feature_tour_content.js
+++ b/web/feature_tour_content.js
@@ -18,6 +18,12 @@ export const FEATURE_TOUR = [
{assets: [{file: 'fox-sheet.webp', role: 'reference'}], prompt: ['The fox in {image1} walks through a sunlit forest.', '{image1} 中的狐狸走过洒满阳光的森林。'], settings: {}}, {sequence: [clip('c5-forest-s1'), clip('c5-snow-s1')]}),
card('replace-person', copy('Replace person', '替换人物'), copy('Put the person from an image into a video.', '把视频里的人换成图中的人物。'),
[{src: 'c10-source.webp'}, {src: 'c10-person.webp'}], clip('c10-s1'), {status: 'pending-assets'}, {trigger: 'media', added: '0.4.28'}),
+ card('first-video', copy('Make your first video', '做出第一条视频'), copy('Write a description, generate, and find the video in Creations.', '写一段描述,生成,再到作品中找到它。'),
+ [{text: copy(...CASTLE_PROMPT)}], clip('c11-s1'), {assets: [], prompt: CASTLE_PROMPT, settings: {}}, {added: '0.5.0', goto: ['prompt-box', 'generate-btn', 'works-entry']}),
+ card('character', copy('Characters', '角色'), copy('Save a character once, then mention it with @ in any description.', '角色保存一次,之后在任意描述中用 @ 引用。'),
+ [{text: copy('@Leo walks along the shore.', '@小林 走在海边。')}], clip('c12-s1'), {status: 'pending-assets'}, {trigger: 'media', added: '0.5.0', goto: ['cast-add', 'prompt-box']}),
+ card('edit-view', copy('Edit view', '剪辑视图'), copy('Arrange clips on the timeline and adjust picture, sound and speed.', '在时间线上排列片段,调整画面、声音和速度。'),
+ [{src: 'c12-s1.webp'}], clip('c13-s1'), {status: 'pending-assets', view: 'editor'}, {trigger: 'editor', added: '0.5.0', goto: ['editor-timeline', 'editor-inspector']}),
card('extend', copy('Extend', '接着生成'), copy('Continue from where the last clip ends.', '从上一段的结尾接着生成下一段。'),
[{src: 'c6-s1.webp'}], clip('c6-s1'), {status: 'pending-assets', view: 'editor'}, {trigger: 'editor', previewRange: [2, 8]}),
card('two-pass', copy('Two-pass', '二次采样'), copy('The first pass sets the composition; the second adds detail.', '第一遍定构图,第二遍补细节。'),
diff --git a/web/feedback.css b/web/feedback.css
index effd5e4..7890c83 100644
--- a/web/feedback.css
+++ b/web/feedback.css
@@ -9,8 +9,11 @@
/* Keep the entry beside Settings; compact headers use the same labelled button with a line icon. */
.fv-header-actions>button{white-space:nowrap}
.fv-feedback-entry>svg{display:none;flex:none;width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}
+@media(max-width:1500px){.fv-autopilot .fv-header:has(.fv-autopilot-now:not([hidden])) .fv-feedback-entry>svg{display:block}.fv-autopilot .fv-header:has(.fv-autopilot-now:not([hidden])) .fv-feedback-label{display:none}}
+@media(max-width:1040px){.fv-autopilot .fv-header:has(.fv-autopilot-now:not([hidden])) .fv-lan{display:none}}
@media(max-width:1040px){.fv-autopilot .fv-feedback-entry>svg{display:block}.fv-autopilot .fv-feedback-label{display:none}}
+@media(max-width:1040px){.fv-editor .fv-guide-entry>svg{display:block}.fv-editor .fv-guide-entry .fv-feedback-label{display:none}}
@media(max-width:800px){.fv-editor .fv-feedback-entry>svg{display:block}.fv-editor .fv-feedback-label{display:none}}
-@media(max-width:680px){.fv-studio .fv-feedback-entry>svg{display:block}.fv-studio .fv-feedback-label{display:none}}
+@media(max-width:680px){.fv-studio .fv-feedback-entry>svg,.fv-view-navigation .fv-feedback-entry>svg{display:block}.fv-studio .fv-feedback-label,.fv-view-navigation .fv-feedback-label{display:none}}
/* On a narrow screen the line gets the whole width above the button. */
@media(max-width:480px){.fv-feedback .fv-feedback-actions{flex-wrap:wrap;row-gap:10px}.fv-feedback .fv-feedback-status{flex:1 0 100%}.fv-feedback .fv-feedback-status:empty{display:none}}
diff --git a/web/feedback.js b/web/feedback.js
index b4aba8f..32c5ebe 100644
--- a/web/feedback.js
+++ b/web/feedback.js
@@ -228,3 +228,17 @@ export function feedbackButton(t, className = 'fv-quiet') {
button.onclick = () => openFeedback(t);
return button;
}
+
+// The tutorial entry, left of Feedback: same style, icon only where Feedback is.
+export function guideButton(t, className = 'fv-quiet') {
+ const label = t('Tutorial', '教程');
+ const button = el('button', `${className} fv-feedback-entry fv-guide-entry`); button.type = 'button';
+ button.setAttribute('aria-label', label); button.title = label;
+ const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ icon.setAttribute('viewBox', '0 0 16 16'); icon.setAttribute('aria-hidden', 'true'); icon.setAttribute('focusable', 'false');
+ const path = document.createElementNS(icon.namespaceURI, 'path');
+ path.setAttribute('d', 'M2.5 3.2c1.9-.5 3.7-.3 5.5.8v9c-1.8-1.1-3.6-1.3-5.5-.8ZM13.5 3.2c-1.9-.5-3.7-.3-5.5.8v9c1.8-1.1 3.6-1.3 5.5-.8Z');
+ icon.append(path); button.append(icon, el('span', 'fv-feedback-label', label));
+ button.onclick = () => import('./tutorial_book.js').then(({openTutorialBook}) => openTutorialBook({chapter: 'quick-start'})).catch(() => {});
+ return button;
+}
diff --git a/web/health.js b/web/health.js
index 1e25a64..2f7337a 100644
--- a/web/health.js
+++ b/web/health.js
@@ -19,7 +19,7 @@ export const MODULES = ['audio_original.js', 'chat_data.js', 'phone_model.js', '
'progress_connection.js', 'prompt_draft.js', 'prompt_enhance.js', 'prompt_references.js', 'prompt_sections.js', 'prompt_terms.js', 'request_assets.js', 'repair_hint.js', 'report_issue.js', 'issue_button.js', 'studio_recent.js', 'task_groups.js',
'result_actions.js', 'result_reuse.js', 'sampling_effort.js', 'pass_mode.js','setup.js', 'share.js', 'share_layout.js', 'studio.js', 'studio_chain.js', 'studio_extend.js', 'studio_length.js', 'first_frame_row.js', 'replace_person.js', 'replace_state.js', 'optional_inputs.js', 'other_usage.js', 'studio_queue.js', 'studio_size.js',
'toolbar_position.js', 'updates.js', 'view_navigation.js', 'wordmark.js', 'workspace_restore.js', 'cast_library.js', 'media_upload.js', 'whitebox_encode.js', 'whitebox_mp4.js', 'whitebox_recording.js', 'whitebox_render.js', 'whitebox_scenes.js', 'whitebox_worker.js',
- 'empty_prompt_notice.js', 'feature_tour.js', 'feature_tour_content.js', 'howto.js', 'swap_lora.js', 'tour_try.js', 'tutorial_book.js', 'tutorial_book_content.js'];
+ 'empty_prompt_notice.js', 'feature_tour.js', 'feature_tour_content.js', 'howto.js', 'swap_lora.js', 'tour_goto.js', 'tour_try.js', 'tutorial_book.js', 'tutorial_book_content.js'];
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
let visibleAt = 0;
async function waitForVisible() {
diff --git a/web/studio.js b/web/studio.js
index 93ff5ba..6b29f7d 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -6,7 +6,7 @@ import {showEmptyPrompt, dismissEmptyPrompt} from './empty_prompt_notice.js';
import { app } from '../../scripts/app.js';
import { api } from '../../scripts/api.js';
import { openSetup } from './setup.js';
-import { feedbackButton, feedbackIssueURL } from './feedback.js';
+import { feedbackButton, guideButton, feedbackIssueURL } from './feedback.js';
import { wordmark } from './wordmark.js';
import { createGenerationProgress, referenceTrimText, thermalText, sharedGpuText, keepSoundText, encoderFileText, encoderFilePath } from './generation_progress.js';
import { viewSwitch, viewChanged, agentTabReady, openAutopilot } from './view_navigation.js';
@@ -667,7 +667,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
const agents = createAgentActivity(t, api, dialog); tools.append(agents.element); cleanup.push(agents.dispose);
const phoneAccess = createLanAccess(t, api); tools.append(phoneAccess.element); cleanup.push(phoneAccess.dispose);
const versionInfo = createVersionInfo(cn); tools.append(versionInfo.element); cleanup.push(versionInfo.dispose);
- tools.append(feedbackButton(t), button(t('Settings', '设置'), openSetup, 'fv-quiet'));
+ tools.append(guideButton(t), feedbackButton(t), button(t('Settings', '设置'), openSetup, 'fv-quiet'));
// The Agent's page is the fourth tab, shown where the Agent interface is on; the guide's last step circles it.
agentTabReady(agentInterfaceState(api), () => agentInterfaceState(api));
// The length hint links to the same two views, through the same actions.
@@ -695,7 +695,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
const untouched = () => Boolean(starter) && value(node, 'text') === starter;
const shown = text => starter && text === starter ? '' : String(text || '');
const prompt = el('textarea'); prompt.value = shown(value(node, 'text')); prompt.setAttribute('aria-label', t('Prompt', '提示词'));
- prompt.dataset.fvGuide = 'describe';
+ prompt.dataset.fvGuide = 'describe'; prompt.dataset.tourId = 'prompt-box';
const placeholder = () => { prompt.placeholder = extension.source ? extendText(t, 'prompt') : untouched() ? starterShown : t('Describe the scene… Type @ to reference media', '描述画面… 输入 @ 引用素材'); };
placeholder();
prompt.disabled = linked(node, 'text'); prompt.oninput = () => { set(node, 'text', prompt.value); placeholder(); };
@@ -1270,10 +1270,10 @@ export function openStudio(node, {extendFrom = null} = {}) {
seedFields.append(field(t('Seed', '种子'), seed), field(t('After generation', '生成后'), mode)); advanced.append(seedFields);
const previewHead = el('div', null, 'fv-preview-head'); previewHead.append(el('strong', t('Preview', '预览')));
const previewTools = el('div', null, 'fv-preview-tools');
- previewTools.append(button(t('Creations', '作品'), () => {
+ const worksButton = button(t('Creations', '作品'), () => {
stage.querySelector('video')?.pause(); openLibrary(t, {upscale: value => node.freevideoUpscaleResult(value),
extend: (saved, options) => openExtendEditor(saved, node, {studio: dialog, ...options})});
- })); previewHead.append(previewTools); output.append(previewHead);
+ }); worksButton.dataset.tourId = 'works-entry'; previewTools.append(worksButton); previewHead.append(previewTools); output.append(previewHead);
const previewSpace = el('div', null, 'fv-preview-space'); output.append(previewSpace);
// The preview keeps the size it has once the list is in; an opened part grows the column, which scrolls.
const partList = createChainPartList(t, (block, text) => chainController.setText(block, composePartText(chainController.state, block, text)), {
@@ -1653,7 +1653,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
};
runOptions.append(optionsToggle, optionsPanel);
const generate = button('', submitDraft, 'fv-primary');
- generate.dataset.fvGuide = 'generate';
+ generate.dataset.fvGuide = 'generate'; generate.dataset.tourId = 'generate-btn';
runrow.append(generate, runOptions);
runButtonReady = true;
const queueActions = el('div', null, 'fv-queue-actions');
diff --git a/web/tour_goto.css b/web/tour_goto.css
new file mode 100644
index 0000000..d2b1b8e
--- /dev/null
+++ b/web/tour_goto.css
@@ -0,0 +1,4 @@
+.fv-tour-ring{position:fixed;z-index:2147483000;box-sizing:border-box;border:2px solid var(--fv-accent,#6db8fa);border-radius:var(--fv-r-md,10px);pointer-events:none;box-shadow:0 0 0 0 color-mix(in srgb,var(--fv-accent,#6db8fa) 25%,transparent);animation:fv-tour-ring-pulse .4s ease-out 1 forwards;transition:opacity .3s}
+.fv-tour-ring-out{opacity:0}
+@keyframes fv-tour-ring-pulse{to{box-shadow:0 0 0 6px color-mix(in srgb,var(--fv-accent,#6db8fa) 25%,transparent)}}
+@media(prefers-reduced-motion:reduce){.fv-tour-ring{animation:none;box-shadow:0 0 0 6px color-mix(in srgb,var(--fv-accent,#6db8fa) 25%,transparent);transition:none}}
diff --git a/web/tour_goto.js b/web/tour_goto.js
new file mode 100644
index 0000000..d1e5056
--- /dev/null
+++ b/web/tour_goto.js
@@ -0,0 +1,60 @@
+// "Take me there": ring the real control a tutorial scene is about. Targets carry data-tour-id;
+// a collapsed section or a hidden panel is opened first, and a missing target only opens the view.
+if (!document.head.querySelector('link[href$="tour_goto.css"]')) {
+ const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = new URL('./tour_goto.css', import.meta.url).href;
+ document.head.append(link);
+}
+const RING_MS = 3000, FADE_MS = 300;
+let current = null;
+const visible = node => { const r = node?.getBoundingClientRect(); return !!r && r.width > 0 && r.height > 0; };
+const find = id => document.querySelector(`[data-tour-id="${CSS.escape(id)}"]`);
+function reveal(node) {
+ for (let parent = node.parentElement; parent; parent = parent.parentElement) if (parent.tagName === 'DETAILS' && !parent.open) parent.open = true;
+}
+export function clearTourRing() { current?.(); }
+/** Resolve with true when the ring was drawn, false when the target is absent or hidden. */
+export async function guideTo(id) {
+ clearTourRing();
+ let node = find(id);
+ if (!node) return false;
+ reveal(node);
+ if (!visible(node)) {
+ // A narrow layout keeps some panels behind a toggle that names the panel it opens.
+ document.querySelector(`[data-tour-toggle="${CSS.escape(id)}"]`)?.click();
+ await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ node = find(id);
+ if (!node || !visible(node)) return false;
+ }
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;
+ node.scrollIntoView({block: 'center', inline: 'nearest', behavior: reduced ? 'auto' : 'smooth'});
+ await new Promise(resolve => setTimeout(resolve, reduced ? 0 : 320));
+ if (!visible(node)) return false;
+ const ring = document.createElement('div'); ring.className = 'fv-tour-ring'; ring.setAttribute('aria-hidden', 'true');
+ // A transformed dialog becomes the containing block of fixed children, so the ring corrects by what it measures.
+ const place = () => {
+ const r = node.getBoundingClientRect();
+ Object.assign(ring.style, {left: `${r.left - 4}px`, top: `${r.top - 4}px`, width: `${r.width + 8}px`, height: `${r.height + 8}px`});
+ if (!ring.isConnected) return;
+ const g = ring.getBoundingClientRect();
+ Object.assign(ring.style, {left: `${r.left - 4 - (g.left - (r.left - 4))}px`, top: `${r.top - 4 - (g.top - (r.top - 4))}px`});
+ };
+ // Smooth scrolling and a section that just opened can still be moving: wait until the target holds still.
+ for (let last = null, i = 0; i < 30; i++) {
+ const r = node.getBoundingClientRect(), key = `${r.top}|${r.left}`;
+ if (key === last) break; last = key; await new Promise(resolve => requestAnimationFrame(resolve));
+ }
+ (node.closest('dialog[open]') || document.body).append(ring); place();
+ const follow = () => { if (node.isConnected) place(); else done(); };
+ addEventListener('scroll', follow, true); addEventListener('resize', follow);
+ let timer = 0, gone = false;
+ function done() {
+ if (gone) return; gone = true; clearTimeout(timer);
+ removeEventListener('scroll', follow, true); removeEventListener('resize', follow);
+ document.removeEventListener('pointerdown', done, true);
+ ring.classList.add('fv-tour-ring-out'); setTimeout(() => ring.remove(), reduced ? 0 : FADE_MS);
+ if (current === done) current = null;
+ }
+ current = done; timer = setTimeout(done, RING_MS);
+ document.addEventListener('pointerdown', done, true);
+ return true;
+}
diff --git a/web/tutorial_book.js b/web/tutorial_book.js
index 425f481..98cad79 100644
--- a/web/tutorial_book.js
+++ b/web/tutorial_book.js
@@ -1,8 +1,8 @@
import {TUTORIAL_CHAPTERS} from './tutorial_book_content.js';
const COPY = {
- zh: {book: '教程', contents: '目录', close: '关闭', limits: '限制', start: '开始演示', tryIt: '试一试'},
- en: {book: 'Tutorial', contents: 'Contents', close: 'Close', limits: 'Limits', start: 'Start walkthrough', tryIt: 'Try it'},
+ zh: {book: '教程', contents: '目录', close: '关闭', limits: '限制', start: '开始演示', tryIt: '试一试', goto: '带我去'},
+ en: {book: 'Tutorial', contents: 'Contents', close: 'Close', limits: 'Limits', start: 'Start walkthrough', tryIt: 'Try it', goto: 'Take me there'},
};
const el = (tag, cls, text) => {
const node = document.createElement(tag);
@@ -118,7 +118,16 @@ export function openTutorialBook({chapter = TUTORIAL_CHAPTERS[0].id} = {}) {
window.freevideoHowTo.tryIt(item.example, {chapter: item.id});
};
}
- article.append(steps, ...(tryButton ? [tryButton] : []), start, limits);
+ let gotoButton = null;
+ if (item.goto?.length) {
+ gotoButton = el('button', 'fv-book-start fv-book-goto', text.goto); gotoButton.type = 'button';
+ gotoButton.onclick = async () => {
+ dialog.close();
+ const {guideTo} = await import('./tour_goto.js');
+ for (const id of item.goto) if (await guideTo(id)) break;
+ };
+ }
+ article.append(steps, ...(tryButton ? [tryButton] : []), ...(gotoButton ? [gotoButton] : []), start, limits);
syncHowTo();
syncTry();
article.scrollTop = 0;
diff --git a/web/tutorial_book_content.js b/web/tutorial_book_content.js
index 2642c27..df730df 100644
--- a/web/tutorial_book_content.js
+++ b/web/tutorial_book_content.js
@@ -3,6 +3,7 @@
export const TUTORIAL_CHAPTERS = [
{
id: 'quick-start',
+ goto: ['prompt-box', 'generate-btn'],
title: {zh: '做出第一条视频', en: 'Make your first video'},
summary: {zh: '只写一句描述,其余使用默认设置。', en: 'Write one sentence and keep the default settings.'},
media: {
@@ -26,6 +27,7 @@ export const TUTORIAL_CHAPTERS = [
},
{
id: 'text-to-video',
+ goto: ['prompt-box'],
title: {zh: '文字生成视频', en: 'Make a video from text'},
summary: {zh: '用文字描述镜头,并选择画幅、清晰度和时长。', en: 'Describe the shot, then choose the shape, resolution and length.'},
media: {
@@ -118,6 +120,7 @@ export const TUTORIAL_CHAPTERS = [
},
{
id: 'cast-sheet',
+ goto: ['cast-add'],
title: {zh: '角色库和角色设定图', en: 'Characters and character sheets'},
summary: {zh: '把人物保存为角色,之后在描述中用 @ 引用。', en: 'Save a person as a character, then mention it with @ in later prompts.'},
media: {
@@ -274,6 +277,7 @@ export const TUTORIAL_CHAPTERS = [
},
{
id: 'editor',
+ goto: ['editor-timeline'],
title: {zh: '剪辑视图:裁剪、描述、接续', en: 'The Edit view: crop, describe, continue'},
summary: {zh: '在时间线上选中一段,描述它,并接着生成。', en: 'Select a part on the timeline, describe it and continue.'},
media: {
@@ -338,6 +342,7 @@ export const TUTORIAL_CHAPTERS = [
},
{
id: 'library-export',
+ goto: ['works-entry'],
title: {zh: '作品库和导出', en: 'Creations and export'},
summary: {zh: '查找生成过的视频,并导出为文件。', en: 'Find earlier videos and export them as files.'},
media: {
diff --git a/web/view_navigation.css b/web/view_navigation.css
index 1507acc..7f6632c 100644
--- a/web/view_navigation.css
+++ b/web/view_navigation.css
@@ -7,7 +7,7 @@
.fv-view-switch button[hidden],.fv-studio .fv-view-switch button[hidden]{display:none}
.fv-view-navigation .fv-view-settings{font-size:12px;padding:6px}
.fv-studio .fv-header:has(.fv-view-switch){grid-template-columns:1fr auto 1fr}.fv-studio .fv-header>.fv-header-actions{justify-self:end;min-width:0}.fv-studio .fv-view-switch button{padding:5px 14px;min-height:var(--fv-h-sm)}
-@media(max-width:680px){.fv-view-navigation{top:68px;max-width:calc(100vw - 16px)}.fv-view-row{gap:6px}.fv-view-row>.fv-wordmark{width:90px}.fv-view-switch button{padding:7px 10px}.fv-studio .fv-header:has(.fv-view-switch){grid-template-columns:1fr auto 1fr;gap:8px}.fv-studio .fv-header:has(.fv-view-switch) .fv-wordmark{width:90px}.fv-studio .fv-view-switch{justify-self:center}.fv-studio .fv-view-switch button{padding:6px 9px}}
+@media(max-width:680px){.fv-view-navigation{top:68px;max-width:calc(100vw - 16px)}.fv-view-navigation .fv-view-settings{padding:6px 3px}.fv-view-row{gap:4px}.fv-view-row>.fv-wordmark{width:90px}.fv-view-switch button{padding:7px 10px}.fv-studio .fv-header:has(.fv-view-switch){grid-template-columns:1fr auto 1fr;gap:8px}.fv-studio .fv-header:has(.fv-view-switch) .fv-wordmark{width:90px}.fv-studio .fv-view-switch{justify-self:center}.fv-studio .fv-view-switch button{padding:6px 9px}}
.fv-view-navigation{animation:fv-panel-enter .25s ease}
@media(max-width:380px){.fv-view-row>.fv-wordmark{width:76px}.fv-view-navigation .fv-view-switch button{font-size:12px;padding:7px 8px}}
diff --git a/web/view_navigation.js b/web/view_navigation.js
index 1d3f84f..344205a 100644
--- a/web/view_navigation.js
+++ b/web/view_navigation.js
@@ -2,7 +2,7 @@ import {createLanAccess} from './lan_access.js';
import {api} from '../../scripts/api.js';
import { app } from '../../scripts/app.js';
import { openSetup } from './setup.js';
-import { feedbackButton } from './feedback.js';
+import { feedbackButton, guideButton } from './feedback.js';
import { wordmark } from './wordmark.js';
import { createUpdateNotice, createVersionInfo } from './updates.js';
import { makeMovable } from './toolbar_position.js';
@@ -169,7 +169,7 @@ export function installNavigation(openStudio, agent = false, {openWorkflow = nul
const handle = await openEditorView(node);
if (created) handle?.notify(t('Created an editing project for you.', '已新建一个剪辑工程'));
return handle;
- }, true), () => choose(node => openAutopilot(node), true)), createLanAccess(t, api).element, createVersionInfo(cn).element, feedbackButton(t, 'fv-view-settings'), settings); toolbar.append(row);
+ }, true), () => choose(node => openAutopilot(node), true)), createLanAccess(t, api).element, createVersionInfo(cn).element, guideButton(t, 'fv-view-settings'), feedbackButton(t, 'fv-view-settings'), settings); toolbar.append(row);
toolbar.append(createUpdateNotice(cn).element);
document.body.append(toolbar); refreshNavigation();
makeMovable(toolbar);