feat(video-pipeline): 增强参考图自动上传与视频生成重试机制

- 在 `init-manifest` 阶段添加输入文件清理日志和 WARNING 提示
- `getReferences` 改为异步并自动将本地参考图上传至 OSS,减少手动操作
- `phase-videos` 支持 `pending`/`failed` 状态 item 的自动重试,自动清理旧视频引用
- 优化 `phase-assemble` 中字幕与配音开关的逻辑,根据实际内容动态判断
This commit is contained in:
2026-05-03 02:03:17 +08:00
parent 6e8d2b8baa
commit 0e3f0f7d0f
10 changed files with 713 additions and 12 deletions

View File

@@ -42,10 +42,24 @@ function loadAccountConfig(accountId) {
// 参考图解析
// ============================================================================
function getReferences(manifest, accountConfig) {
async function getReferences(manifest, accountConfig) {
const result = { localPaths: [], urls: [] }
const accountId = accountConfig.id || manifest.account || ''
// 自动上传本地文件到 OSS 的辅助函数
const ensureUrl = async (localPath, label) => {
try {
const { uploadFile } = require('../oss-upload')
const { url } = await uploadFile(localPath)
result.urls.push(url)
log('images', `参考图已自动上传 OSS: ${label}`)
return url
} catch (err) {
log('images', `参考图上传 OSS 失败: ${label} (${err.message}),仅本地使用`)
return null
}
}
// 优先读 manifest.referencesagent 创建时写入)
const refs = manifest.references || []
if (refs.length > 0) {
@@ -55,6 +69,10 @@ function getReferences(manifest, accountConfig) {
const localPath = path.isAbsolute(ref.file) ? ref.file : path.resolve(ref.file)
if (fs.existsSync(localPath)) {
result.localPaths.push(localPath)
// 有本地文件但没有 OSS URL → 自动上传,杜绝 agent 只用本地路径
if (!ref.url) {
ref.url = await ensureUrl(localPath, path.basename(localPath))
}
} else {
log('images', `参考图不存在: ${ref.file}`)
}
@@ -72,12 +90,15 @@ function getReferences(manifest, accountConfig) {
const localPath = path.join(ACCOUNTS_DIR, accountId, 'references', ref.file)
if (fs.existsSync(localPath)) {
result.localPaths.push(localPath)
if (!ref.url) {
ref.url = await ensureUrl(localPath, ref.file)
}
}
}
}
if (result.localPaths.length > 0 || result.urls.length > 0) return result
// Fallback 2: 扫描 account 的 references 目录
// Fallback 2: 扫描 account 的 references 目录(自动上传 OSS
if (accountId) {
const refDir = path.join(ACCOUNTS_DIR, accountId, 'references')
if (fs.existsSync(refDir)) {
@@ -85,10 +106,12 @@ function getReferences(manifest, accountConfig) {
/\.(png|jpg|jpeg|webp)$/i.test(f)
)
for (const f of files) {
result.localPaths.push(path.join(refDir, f))
const localPath = path.join(refDir, f)
result.localPaths.push(localPath)
await ensureUrl(localPath, f)
}
if (files.length > 0) {
log('images', `从 references 目录兜底扫描到 ${files.length} 个参考图`)
log('images', `从 references 目录兜底扫描到 ${files.length} 个参考图(已自动上传 OSS`)
}
}
}