Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
feat(creator): add audio language selection to downloads
Joshua975a3ead6266
diff --git a/apps/daemon/src/creator/download/executor.ts b/apps/daemon/src/creator/download/executor.tsindex c140e5f6..f6b6e5f9 100644--- a/apps/daemon/src/creator/download/executor.ts+++ b/apps/daemon/src/creator/download/executor.ts@@ -498,6 +498,9 @@ async function outputMetadata(optionId: option.id,mediaType: option.mediaType,container: option.container,+ ...(option.audioLanguage === undefined+ ? {}+ : { audioLanguage: option.audioLanguage }),...(playback.videoCodec === null ? {} : { videoCodec: playback.videoCodec }),...(playback.audioCodec === null ? {} : { audioCodec: playback.audioCodec }),...(playback.pixelFormat === null ? {} : { pixelFormat: playback.pixelFormat }),diff --git a/apps/daemon/src/creator/download/probe-parser.ts b/apps/daemon/src/creator/download/probe-parser.tsindex 6245ffc8..e401564b 100644--- a/apps/daemon/src/creator/download/probe-parser.ts+++ b/apps/daemon/src/creator/download/probe-parser.ts@@ -16,7 +16,9 @@ const formatSchema = z.object({filesize: z.number().nullish(),filesize_approx: z.number().nullish(),vcodec: z.string().nullish(),- acodec: z.string().nullish()+ acodec: z.string().nullish(),+ language: z.string().nullish(),+ language_preference: z.number().nullish()}).passthrough();const probeSchema = z.object({@@ -30,6 +32,7 @@ const probeSchema = z.object({duration: z.number().nonnegative().nullish(),width: z.number().nullish(),height: z.number().nullish(),+ language: z.string().nullish(),formats: z.array(formatSchema).default([])}).passthrough();@@ -49,6 +52,8 @@ export function parseDownloadProbe(fps: format.fps ?? null,bitrateKbps: format.tbr ?? format.abr ?? null,bytes: format.filesize ?? format.filesize_approx ?? null,+ language: normalizeLanguage(format.language ?? parsed.language),+ languagePreference: format.language_preference ?? null,hasVideo: hasCodec(format.vcodec),hasAudio: hasCodec(format.acodec)}));@@ -72,59 +77,96 @@ function createDownloadOptions(formats: DownloadProbeFormat[],duration: number | null): DownloadOption[] {- const audioOnly = formats- .filter(format => format.hasAudio && !format.hasVideo)- .sort(compareAudioFormats)[0];- const audioSource = audioOnly ?? formats- .filter(format => format.hasAudio)- .sort(compareAudioFormats)[0];+ const audioOnly = formats.filter(format => format.hasAudio && !format.hasVideo);+ const audioSources = bestAudioFormatsByLanguage(+ audioOnly.length > 0+ ? audioOnly+ : formats.filter(format => format.hasAudio)+ );const videosByHeight = new Map<string, DownloadProbeFormat>();for (const format of formats.filter(candidate => candidate.hasVideo)) {const key = `${format.width ?? 0}x${format.height ?? 0}`;const current = videosByHeight.get(key);- if (current === undefined || compareVideoFormats(format, current) < 0) {+ const preferSeparateAudio = audioSources.length > 1+ && current !== undefined+ && current.hasAudio !== format.hasAudio;+ if (+ current === undefined+ || (preferSeparateAudio+ ? !format.hasAudio+ : compareVideoFormats(format, current) < 0)+ ) {videosByHeight.set(key, format);}}const videoOptions = [...videosByHeight.values()].sort(compareVideoFormats)- .map((video, index): DownloadOption => {- const estimatedBytes = estimatedVideoBytes(- video,- video.hasAudio ? undefined : audioOnly,- duration- );- return {- id: `video-${video.height ?? 'source'}-${index + 1}`,- mediaType: 'video',- container: 'mp4',- ...(video.width === null ? {} : { width: video.width }),- ...(video.height === null ? {} : { height: video.height }),- ...(video.fps === null ? {} : { fps: video.fps }),- ...(video.bitrateKbps === null ? {} : { bitrateKbps: video.bitrateKbps }),- ...(estimatedBytes === undefined ? {} : { estimatedBytes }),- videoFormatId: video.id,- ...(video.hasAudio || audioOnly === undefined- ? {}- : { audioFormatId: audioOnly.id })- };+ .flatMap((video, index): DownloadOption[] => {+ const selectedAudioSources = video.hasAudio+ ? [undefined]+ : audioSources.length > 0+ ? audioSources+ : [undefined];+ return selectedAudioSources.map(audio => {+ const estimatedBytes = estimatedVideoBytes(video, audio, duration);+ const audioLanguage = video.hasAudio+ ? video.language ?? 'und'+ : audio === undefined+ ? undefined+ : audio.language ?? 'und';+ const baseId = `video-${video.height ?? 'source'}-${index + 1}`;+ return {+ id: audioSources.length > 1 && audio !== undefined+ ? `${baseId}-${encodeURIComponent(audio.id)}`+ : baseId,+ mediaType: 'video',+ container: 'mp4',+ ...(audioLanguage === undefined ? {} : { audioLanguage }),+ ...(video.width === null ? {} : { width: video.width }),+ ...(video.height === null ? {} : { height: video.height }),+ ...(video.fps === null ? {} : { fps: video.fps }),+ ...(video.bitrateKbps === null ? {} : { bitrateKbps: video.bitrateKbps }),+ ...(estimatedBytes === undefined ? {} : { estimatedBytes }),+ videoFormatId: video.id,+ ...(video.hasAudio || audio === undefined+ ? {}+ : { audioFormatId: audio.id })+ };+ });});- const audioOptions = audioSource === undefined- ? []- : [320, 192, 128].map((bitrateKbps): DownloadOption => ({- id: `audio-mp3-${bitrateKbps}`,- mediaType: 'audio',- container: 'mp3',- bitrateKbps,- ...(duration === null- ? {}- : { estimatedBytes: Math.round(duration * bitrateKbps * 1_000 / 8) }),- audioFormatId: audioSource.id,- transcode: 'mp3'- }));+ const audioOptions = [320, 192, 128].flatMap(bitrateKbps => (+ audioSources.map((audio): DownloadOption => ({+ id: audioSources.length > 1+ ? `audio-mp3-${bitrateKbps}-${encodeURIComponent(audio.id)}`+ : `audio-mp3-${bitrateKbps}`,+ mediaType: 'audio',+ container: 'mp3',+ audioLanguage: audio.language ?? 'und',+ bitrateKbps,+ ...(duration === null+ ? {}+ : { estimatedBytes: Math.round(duration * bitrateKbps * 1_000 / 8) }),+ audioFormatId: audio.id,+ transcode: 'mp3'+ }))+ ));return [...videoOptions, ...audioOptions];}+function bestAudioFormatsByLanguage(+ formats: DownloadProbeFormat[]+): DownloadProbeFormat[] {+ const byLanguage = new Map<string, DownloadProbeFormat>();+ for (const format of formats) {+ const key = format.language?.toLocaleLowerCase() ?? 'und';+ const current = byLanguage.get(key);+ if (current === undefined || compareAudioFormats(format, current) < 0) {+ byLanguage.set(key, format);+ }+ }+ return [...byLanguage.values()].sort(compareAudioFormats);+}+function compareVideoFormats(left: DownloadProbeFormat,right: DownloadProbeFormat@@ -145,13 +187,18 @@ function compareAudioFormats(right: DownloadProbeFormat): number {return (- Number(right.ext === 'm4a' || right.ext === 'mp4')+ languagePreferenceScore(right) - languagePreferenceScore(left)+ || Number(right.ext === 'm4a' || right.ext === 'mp4')- Number(left.ext === 'm4a' || left.ext === 'mp4')|| (right.bitrateKbps ?? 0) - (left.bitrateKbps ?? 0)|| (right.bytes ?? 0) - (left.bytes ?? 0));}+function languagePreferenceScore(format: DownloadProbeFormat): number {+ return format.languagePreference ?? -1_000_000;+}+function estimatedVideoBytes(video: DownloadProbeFormat,audio: DownloadProbeFormat | undefined,@@ -193,6 +240,16 @@ function hasCodec(value: string | null | undefined): boolean {return value !== null && value !== undefined && value !== 'none';}+function normalizeLanguage(value: string | null | undefined): string | null {+ const normalized = value?.trim().replaceAll('_', '-') ?? '';+ if (!normalized) return null;+ try {+ return Intl.getCanonicalLocales(normalized)[0] ?? normalized;+ } catch {+ return normalized;+ }+}+function isH264Codec(value: string | null | undefined): boolean {const normalized = value?.trim().toLowerCase() ?? '';return normalized === 'h264'diff --git a/apps/daemon/test/unit/creator-download-executor.test.ts b/apps/daemon/test/unit/creator-download-executor.test.tsindex bbfe215a..bb69224a 100644--- a/apps/daemon/test/unit/creator-download-executor.test.ts+++ b/apps/daemon/test/unit/creator-download-executor.test.ts@@ -45,6 +45,7 @@ describe('creator download executor', () => {container: 'mp4',videoFormatId: '137',audioFormatId: '140',+ audioLanguage: 'und',estimatedBytes: 120}),expect.objectContaining({@@ -57,6 +58,7 @@ describe('creator download executor', () => {mediaType: 'audio',bitrateKbps: 320,audioFormatId: '140',+ audioLanguage: 'und',transcode: 'mp3'}),expect.objectContaining({ id: 'audio-mp3-192' }),@@ -64,6 +66,50 @@ describe('creator download executor', () => {]);});+ it('creates video and MP3 choices for each detected audio language', () => {+ const probe = multilingualParsedProbe();++ expect(probe.formats).toEqual(expect.arrayContaining([+ expect.objectContaining({+ id: 'audio-en',+ language: 'en',+ languagePreference: 10+ }),+ expect.objectContaining({+ id: 'audio-es',+ language: 'es',+ languagePreference: 5+ })+ ]));+ expect(probe.options.filter(option => option.mediaType === 'video')).toEqual([+ expect.objectContaining({+ id: 'video-1080-1-audio-en',+ videoFormatId: 'video-1080',+ audioFormatId: 'audio-en',+ audioLanguage: 'en'+ }),+ expect.objectContaining({+ id: 'video-1080-1-audio-es',+ videoFormatId: 'video-1080',+ audioFormatId: 'audio-es',+ audioLanguage: 'es'+ })+ ]);+ expect(probe.options.filter(option => option.mediaType === 'audio')).toHaveLength(6);+ expect(probe.options).toEqual(expect.arrayContaining([+ expect.objectContaining({+ id: 'audio-mp3-192-audio-en',+ audioFormatId: 'audio-en',+ audioLanguage: 'en'+ }),+ expect.objectContaining({+ id: 'audio-mp3-192-audio-es',+ audioFormatId: 'audio-es',+ audioLanguage: 'es'+ })+ ]));+ });+it('offers MP3 extraction when the source only has a combined media format', () => {const probe = parseDownloadProbe({id: 'progressive-only',@@ -258,6 +304,43 @@ describe('creator download executor', () => {}));});+ it('downloads the audio track bound to the selected video language', async () => {+ const binaries = await fakeBinaries();+ const workdir = join(tempDir, 'multilingual-video-work');+ await mkdir(workdir, { recursive: true });+ const probe = multilingualParsedProbe();+ const option = probe.options.find(candidate => (+ candidate.mediaType === 'video'+ && candidate.audioLanguage === 'es'+ ));+ expect(option).toBeDefined();+ const probeArtifact = await writeProbeArtifact(workdir, probe);+ const executor = createDownloadExecutor(binaries);++ const result = await executor.run(stageInput({+ workdir,+ stageId: 'download',+ state: {+ sourceUrl: probe.requestedUrl,+ mediaType: 'video',+ selectedOptionId: option!.id+ },+ inputArtifacts: [probeArtifact]+ }));++ const args = JSON.parse(+ await readFile(join(workdir, 'args.json'), 'utf8')+ ) as string[];+ expect(args).toEqual(expect.arrayContaining([+ '-f',+ 'video-1080+audio-es'+ ]));+ expect(result.outputs[0]?.metadata).toEqual(expect.objectContaining({+ optionId: option!.id,+ audioLanguage: 'es'+ }));+ });+it('converts VP9 MP4 downloads to H.264 for local playback', async () => {const binaries = await fakeBinaries({ videoCodec: 'vp9' });const workdir = join(tempDir, 'vp9-video-work');@@ -588,6 +671,59 @@ function parsedProbe(): DownloadProbe {}, 'https://www.youtube.com/watch?v=demo');}+function multilingualParsedProbe(): DownloadProbe {+ return parseDownloadProbe({+ id: 'multilingual-demo',+ title: 'Multilingual Download',+ webpage_url: 'https://www.youtube.com/watch?v=multilingual-demo',+ extractor_key: 'Youtube',+ duration: 30,+ formats: [+ {+ format_id: 'video-1080',+ ext: 'mp4',+ width: 1920,+ height: 1080,+ fps: 30,+ tbr: 4_500,+ filesize: 100,+ vcodec: 'avc1',+ acodec: 'none'+ },+ {+ format_id: 'audio-en-webm',+ ext: 'webm',+ abr: 96,+ filesize: 15,+ vcodec: 'none',+ acodec: 'opus',+ language: 'en',+ language_preference: 10+ },+ {+ format_id: 'audio-en',+ ext: 'm4a',+ abr: 128,+ filesize: 20,+ vcodec: 'none',+ acodec: 'mp4a',+ language: 'en',+ language_preference: 10+ },+ {+ format_id: 'audio-es',+ ext: 'm4a',+ abr: 128,+ filesize: 20,+ vcodec: 'none',+ acodec: 'mp4a',+ language: 'es',+ language_preference: 5+ }+ ]+ }, 'https://www.youtube.com/watch?v=multilingual-demo');+}+async function fakeBinaries(input?: {failure?: string;videoCodec?: string;diff --git a/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx b/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsxindex 8985427a..11715698 100644--- a/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx+++ b/apps/web/src/features/dashboard/VideoDownloadWorkspace.test.tsx@@ -121,7 +121,7 @@ describe('VideoDownloadWorkspace', () => {expect(screen.queryByText('OpenCreator 视频示例')).not.toBeInTheDocument();expect(screen.queryByText(/Vimeo/)).not.toBeInTheDocument();- fireEvent.click(screen.getByRole('tab', { name: '项目文件' }));+ fireEvent.click(screen.getByRole('tab', { name: '生成物' }));expect(screen.getByText('Creator Download.mp4')).toBeInTheDocument();expect(screen.getByRole('button', {name: '保存到本机 Creator Download.mp4'@@ -134,6 +134,43 @@ describe('VideoDownloadWorkspace', () => {})).not.toBeInTheDocument();});+ it('selects the real audio track when the video language changes', async () => {+ const current = job({+ state: {+ sourceUrl: 'https://www.youtube.com/watch?v=demo',+ mediaType: 'video',+ selectedOptionId: 'video-1080-1-audio-en'+ },+ artifacts: [multilingualProbeArtifact()]+ });+ const applyAction = vi.fn();+ renderWorkspace(current, { applyAction });++ const language = await screen.findByRole('combobox', {+ name: '音频语言'+ });+ expect(language).toHaveValue('en');+ expect(screen.getByText(/音频: .*\(en\)/)).toBeInTheDocument();++ fireEvent.change(language, { target: { value: 'es' } });++ expect(language).toHaveValue('es');+ expect(screen.getByText(/音频: .*\(es\)/)).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: '下载 1080p' }));+ await waitFor(() => expect(applyAction).toHaveBeenCalledWith(+ current.id,+ expect.objectContaining({+ action: 'run-stage',+ input: {+ stageId: 'download',+ optionId: 'video-1080-1-audio-es',+ mediaType: 'video',+ sourceUrl: 'https://www.youtube.com/watch?v=demo'+ }+ })+ ));+ });+it('previews video and audio project files and releases object URLs', async () => {createObjectURL.mockReturnValueOnce('blob:video-preview')@@ -161,7 +198,7 @@ describe('VideoDownloadWorkspace', () => {openArtifact});- fireEvent.click(await screen.findByRole('tab', { name: '项目文件' }));+ fireEvent.click(await screen.findByRole('tab', { name: '生成物' }));fireEvent.click(screen.getByRole('button', {name: '预览视频 Creator Download.mp4'}));@@ -227,7 +264,7 @@ describe('VideoDownloadWorkspace', () => {openArtifact});- fireEvent.click(await screen.findByRole('tab', { name: '项目文件' }));+ fireEvent.click(await screen.findByRole('tab', { name: '生成物' }));fireEvent.click(screen.getByRole('button', {name: '预览视频 Creator Download.mp4'}));@@ -346,7 +383,7 @@ describe('VideoDownloadWorkspace', () => {});renderWorkspace(current, { applyAction: vi.fn() });- fireEvent.click(await screen.findByRole('tab', { name: '项目文件' }));+ fireEvent.click(await screen.findByRole('tab', { name: '生成物' }));expect(screen.getByText('准备中')).toBeInTheDocument();expect(screen.queryByText('2%')).not.toBeInTheDocument();@@ -650,6 +687,39 @@ function probeArtifact(): CreatorArtifact {};}+function multilingualProbeArtifact(): CreatorArtifact {+ const base = probeArtifact();+ return {+ ...base,+ metadata: {+ ...base.metadata,+ options: [{+ id: 'video-1080-1-audio-en',+ mediaType: 'video',+ container: 'mp4',+ audioLanguage: 'en',+ width: 1920,+ height: 1080,+ fps: 30,+ estimatedBytes: 88_080_384,+ videoFormatId: '399',+ audioFormatId: 'audio-en'+ }, {+ id: 'video-1080-1-audio-es',+ mediaType: 'video',+ container: 'mp4',+ audioLanguage: 'es',+ width: 1920,+ height: 1080,+ fps: 30,+ estimatedBytes: 88_080_384,+ videoFormatId: '399',+ audioFormatId: 'audio-es'+ }]+ }+ };+}+function downloadStage(id: string,optionId: string,diff --git a/apps/web/src/features/dashboard/VideoDownloadWorkspace.tsx b/apps/web/src/features/dashboard/VideoDownloadWorkspace.tsxindex 2681a594..ab6a5c35 100644--- a/apps/web/src/features/dashboard/VideoDownloadWorkspace.tsx+++ b/apps/web/src/features/dashboard/VideoDownloadWorkspace.tsx@@ -18,6 +18,7 @@ import {Link2,LoaderCircle,Music2,+ PackageOpen,Play,RefreshCw,Settings2,@@ -32,7 +33,7 @@ import { useOptionalCreatorSession } from './creator-session-store.js';import type { RuntimeDependenciesController } from '../../app/use-runtime-dependencies.js';type DownloadStep = 0 | 1;-type DownloadResultTab = 'info' | 'formats' | 'history';+type DownloadResultTab = 'info' | 'formats' | 'outputs';type DownloadHistoryItem = {option?: DownloadOption;stage?: CreatorStageRun;@@ -91,8 +92,17 @@ export default function VideoDownloadWorkspace(props: {const options = useMemo(() => ((probe?.options ?? []).filter(option => !legacy || option.mediaType === 'video')), [legacy, probe?.options]);- const visibleOptions = options.filter(option => option.mediaType === mediaType);const selectedOption = options.find(option => option.id === selectedOptionId);+ const mediaOptions = options.filter(option => option.mediaType === mediaType);+ const audioLanguages = availableAudioLanguages(mediaOptions);+ const selectedAudioLanguage = selectedOption?.mediaType === mediaType+ && selectedOption.audioLanguage !== undefined+ && audioLanguages.includes(selectedOption.audioLanguage)+ ? selectedOption.audioLanguage+ : audioLanguages[0];+ const visibleOptions = selectedAudioLanguage === undefined+ ? mediaOptions+ : mediaOptions.filter(option => option.audioLanguage === selectedAudioLanguage);const downloadArtifacts = useMemo(() => (session?.job.artifacts ?? []).filter(artifact => (@@ -213,7 +223,7 @@ export default function VideoDownloadWorkspace(props: {]);useEffect(() => {- if (resultTab === 'history') return;+ if (resultTab === 'outputs') return;artifactPreviewRequestRef.current += 1;releaseArtifactPreviewUrl();setArtifactPreview(undefined);@@ -291,6 +301,18 @@ export default function VideoDownloadWorkspace(props: {selectOption(preferred);}+ function selectAudioLanguage(next: string) {+ const candidates = options.filter(option => (+ option.mediaType === mediaType+ && option.audioLanguage === next+ ));+ const preferred = candidates.find(option => sameDownloadProfile(+ option,+ selectedOption+ )) ?? candidates[0];+ if (preferred !== undefined) selectOption(preferred);+ }+function selectOption(option: DownloadOption) {setMediaType(option.mediaType);setSelectedOptionId(option.id);@@ -338,7 +360,7 @@ export default function VideoDownloadWorkspace(props: {sourceUrl}});- setResultTab('history');+ setResultTab('outputs');setNotice(l('下载任务已加入队列,完成后文件会保存到当前项目','Download queued. The file will be saved to this project.'@@ -531,7 +553,7 @@ export default function VideoDownloadWorkspace(props: {sourceUrl}});- setResultTab('history');+ setResultTab('outputs');}return (@@ -715,11 +737,11 @@ export default function VideoDownloadWorkspace(props: {<buttontype="button"role="tab"- aria-selected={resultTab === 'history'}- onClick={() => setResultTab('history')}+ aria-selected={resultTab === 'outputs'}+ onClick={() => setResultTab('outputs')}>- <CheckCircle2 size={15} strokeWidth={1.8} aria-hidden="true" />- {l('项目文件', 'Project files')}+ <PackageOpen size={15} strokeWidth={1.8} aria-hidden="true" />+ {l('生成物', 'Outputs')}</button></div></div>@@ -799,6 +821,22 @@ export default function VideoDownloadWorkspace(props: {</button>) : null}</div>+ {audioLanguages.length > 1 && selectedAudioLanguage !== undefined ? (+ <label className="creator-tool-field video-download-language-field">+ <span>{l('音频语言', 'Audio language')}</span>+ <select+ aria-label={l('音频语言', 'Audio language')}+ value={selectedAudioLanguage}+ onChange={event => selectAudioLanguage(event.target.value)}+ >+ {audioLanguages.map(language => (+ <option key={language} value={language}>+ {audioLanguageLabel(language, l)}+ </option>+ ))}+ </select>+ </label>+ ) : null}{visibleOptions.length > 0 ? (<div className="video-download-options">{visibleOptions.map((option, index) => {@@ -828,7 +866,7 @@ export default function VideoDownloadWorkspace(props: {/><span><strong>{optionLabel(option, l)}</strong>- <small>{optionDetail(option)}</small>+ <small>{optionDetail(option, l)}</small></span>{index === 0? <small>{l('推荐', 'Recommended')}</small>@@ -876,11 +914,11 @@ export default function VideoDownloadWorkspace(props: {</div>) : null}- {resultTab === 'history' ? (+ {resultTab === 'outputs' ? (<div className="video-result-pane"><header className="video-result-pane-heading"><div>- <h2>{l('项目文件', 'Project files')}</h2>+ <h2>{l('生成物', 'Outputs')}</h2><p>{hasActiveDownloads? l('各规格会按队列依次下载,并在这里显示进度', 'Formats download in order and show progress here')@@ -1065,7 +1103,7 @@ export default function VideoDownloadWorkspace(props: {) : (<div className="video-result-empty"><Download size={26} strokeWidth={1.5} aria-hidden="true" />- <strong>{l('还没有项目文件', 'No project files yet')}</strong>+ <strong>{l('还没有生成物', 'No outputs yet')}</strong><button type="button" onClick={() => setResultTab('formats')}>{l('选择下载规格', 'Choose a format')}</button>@@ -1091,7 +1129,7 @@ export default function VideoDownloadWorkspace(props: {: optionLabel(selectedOption, l)},{- label: l('项目文件', 'Project files'),+ label: l('生成物', 'Outputs'),value: String(downloadArtifacts.length)}]}@@ -1180,6 +1218,9 @@ function readDownloadOption(value: CreatorJson): DownloadOption | undefined {id: value.id,mediaType: value.mediaType,container: value.container as DownloadOption['container'],+ ...(readString(value.audioLanguage) === undefined+ ? {}+ : { audioLanguage: readString(value.audioLanguage) }),...(readNumber(value.width) === undefined ? {} : { width: readNumber(value.width) }),...(readNumber(value.height) === undefined ? {} : { height: readNumber(value.height) }),...(readNumber(value.fps) === undefined ? {} : { fps: readNumber(value.fps) }),@@ -1342,7 +1383,7 @@ function downloadStageDescription(option: DownloadOption | undefined,l: ReturnType<typeof useLocalizedCopy>): string {- const detail = option === undefined ? undefined : optionDetail(option);+ const detail = option === undefined ? undefined : optionDetail(option, l);const status = stage === undefined || stage.status === 'queued'? l('等待前面的规格下载完成', 'Waiting for earlier formats'): stage.status === 'running'@@ -1412,12 +1453,18 @@ function optionLabel(return l('原始画质', 'Source quality');}-function optionDetail(option: DownloadOption): string {+function optionDetail(+ option: DownloadOption,+ l: ReturnType<typeof useLocalizedCopy>+): string {const parts = [option.container.toUpperCase()];if (option.width !== undefined && option.height !== undefined) {parts.push(`${option.width} x ${option.height}`);}if (option.fps !== undefined) parts.push(`${Math.round(option.fps)} FPS`);+ if (option.audioLanguage !== undefined) {+ parts.push(`${l('音频', 'Audio')}: ${audioLanguageLabel(option.audioLanguage, l)}`);+ }if (option.estimatedBytes !== undefined) parts.push(formatBytes(option.estimatedBytes));return parts.join(' · ');}@@ -1435,11 +1482,56 @@ function artifactDescription(readNumber(artifact.metadata.width) ?? null,readNumber(artifact.metadata.height) ?? null),+ readString(artifact.metadata.audioLanguage) === undefined+ ? undefined+ : `${l('音频', 'Audio')}: ${audioLanguageLabel(+ readString(artifact.metadata.audioLanguage)!,+ l+ )}`,l('已保存到项目', 'Saved to project')];return parts.filter(Boolean).join(' · ');}+function availableAudioLanguages(options: DownloadOption[]): string[] {+ const languages = new Map<string, string>();+ for (const option of options) {+ const language = option.audioLanguage?.trim();+ if (!language) continue;+ const key = language.toLocaleLowerCase();+ if (!languages.has(key)) languages.set(key, language);+ }+ return [...languages.values()];+}++function sameDownloadProfile(+ left: DownloadOption,+ right: DownloadOption | undefined+): boolean {+ if (right === undefined || left.mediaType !== right.mediaType) return false;+ return left.mediaType === 'video'+ ? left.videoFormatId === right.videoFormatId+ : left.bitrateKbps === right.bitrateKbps;+}++function audioLanguageLabel(+ language: string,+ l: ReturnType<typeof useLocalizedCopy>+): string {+ const normalized = language.trim();+ if (!normalized || normalized.toLocaleLowerCase() === 'und') {+ return l('未知', 'Unknown');+ }+ try {+ const name = new Intl.DisplayNames([l('zh-CN', 'en-US')], {+ type: 'language'+ }).of(normalized);+ return name === undefined ? normalized : `${name} (${normalized})`;+ } catch {+ return normalized;+ }+}+function artifactFileName(artifact: CreatorArtifact): string {return readString(artifact.metadata.fileName)?? `OpenCreator-${artifact.kind}-${artifact.version}`;diff --git a/apps/web/src/features/dashboard/dashboard.css b/apps/web/src/features/dashboard/dashboard.cssindex 7bb40789..cc44e5dc 100644--- a/apps/web/src/features/dashboard/dashboard.css+++ b/apps/web/src/features/dashboard/dashboard.css@@ -3382,6 +3382,11 @@border-radius: 8px;}+.video-download-language-field {+ width: min(100%, 280px);+ margin: -4px 0 16px;+}+.video-download-options > label {min-height: 56px;display: grid;diff --git a/packages/protocol/src/creator-download.ts b/packages/protocol/src/creator-download.tsindex 242e550f..be7aca8b 100644--- a/packages/protocol/src/creator-download.ts+++ b/packages/protocol/src/creator-download.ts@@ -8,6 +8,7 @@ export type DownloadOption = {id: string;mediaType: DownloadMediaType;container: DownloadContainer;+ audioLanguage?: string;width?: number;height?: number;fps?: number;@@ -28,6 +29,8 @@ export type DownloadProbeFormat = {fps: number | null;bitrateKbps: number | null;bytes: number | null;+ language?: string | null;+ languagePreference?: number | null;hasVideo: boolean;hasAudio: boolean;};