@@ -85,11 +85,13 @@ export async function visionAnalyze(c,media,analysis,signal,progress){
// 规划提示词:只发送经过筛选的高价值片段(按评分排序),并严格控制数据体量,
// 避免超出本地模型上下文导致报错;明确选材规则,减少"乱选素材"。
const PLACEHOLDER = /尚未|等待|采样窗口|时间采样|语义或动作/ ;
const TITLE _CARD = /标题画面|演职员|职员表|片头|片尾|字幕卡|制作人员/ ;
const SEG _CAP = 60 , PER _MEDIA _CAP = 8 , DESC _MAX = 90 ;
const round2 = n => Math . round ( n * 100 ) / 100 ;
function buildProjectData ( p , budget ) {
const media = p . media . map ( m => {
const all = ( m . analysis ? . segments || [ ] ) . filter ( s => s && Number . isFinite ( s . score ) && s . score !== null && typeof s . description === 'string' && s . description && ! PLACEHOLDER . test ( s . description ) )
const seen = new Set ( ) ;
const all = ( m . analysis ? . segments || [ ] ) . filter ( s => s && Number . isFinite ( s . score ) && s . score !== null && typeof s . description === 'string' && s . description && ! PLACEHOLDER . test ( s . description ) && ! TITLE _CARD . test ( s . description ) && ! seen . has ( s . description ) && ( seen . add ( s . description ) , true ) )
. map ( s => ( { start : round2 ( s . start ) , end : round2 ( s . end ) , score : round2 ( s . score ) , description : String ( s . description ) . slice ( 0 , DESC _MAX ) , ... ( s . reason ? { reason : String ( s . reason ) . slice ( 0 , 50 ) } : { } ) } ) )
. sort ( ( a , b ) => b . score - a . score ) ;
return { id : m . id , name : String ( m . name || '' ) . slice ( 0 , 60 ) , type : m . type , duration : round2 ( m . duration ) , ... ( m . tags && m . tags . length ? { tags : m . tags . slice ( 0 , 6 ) } : { } ) , segments : all , hint : all . length ? '' : '未分析,必要时可从全片取用' } ;
@@ -102,11 +104,11 @@ function buildProjectData(p,budget){
... ( c . brightness !== undefined ? { brightness : c . brightness } : { } ) , ... ( c . contrast !== undefined ? { contrast : c . contrast } : { } ) , ... ( c . saturation !== undefined ? { saturation : c . saturation } : { } ) , ... ( c . fit ? { fit : c . fit } : { } ) } ) ) ;
const data = { settings : p . settings , timelineDuration : round2 ( Math . max ( 0 , ... p . clips . map ( c => c . start + ( c . out - c . in ) / ( c . speed || 1 ) ) ) ) , media , clips } ;
const steps = [
d => { for ( const m of d . media ) m . segments = m . segments . slice ( 0 , 4 ) ; } ,
d => { for ( const m of d . media ) m . segments = m . segments . slice ( 0 , 6 ) ; } ,
d => { for ( const m of d . media ) for ( const s of m . segments ) s . description = s . description . slice ( 0 , 60 ) ; } ,
d => { for ( const m of d . media ) for ( const s of m . segments ) delete s . reason ; } ,
d => { for ( const m of d . media ) for ( const s of m . segments ) s . description = s . description . slice ( 0 , 30 ) ; } ,
d => { for ( const m of d . media ) if ( m . segments . length ) m . segments = m . segments . slice ( 0 , 2 ) ; } ,
d => { for ( const m of d . media ) if ( m . segments . length ) m . segments = m . segments . slice ( 0 , 3 ) ; } ,
d => { for ( const c of d . clips ) for ( const k of [ 'brightness' , 'contrast' , 'saturation' , 'fit' , 'color' , 'fontSize' , 'fade' , 'volume' , 'speed' ] ) delete c [ k ] ; } ,
d => { d . clips = d . clips . slice ( 0 , 120 ) . map ( c => ( { id : c . id , mediaId : c . mediaId , track : c . track , start : c . start } ) ) ; } ,
d => { for ( const m of d . media ) delete m . tags ; } ,
@@ -154,7 +156,7 @@ remove {"type":"remove","id":"已有片段 ID"}。
1. 只能引用素材列表中的素材 ID,禁止编造;视频/图片放入 video 轨,音频放入 audio 轨,音频素材不能放入 video 轨。
2. 视频/音频的 in≥0 且 out≤素材 duration,且 out>in;图片素材 in=0, out 最长 60 秒。
3. 视频轨片段不允许重叠;新片段一般接在时间轴末尾(start 等于 timelineDuration),除非用户要求插入特定位置。片段在时间轴上的时长=(out-in)/speed。
4. 素材选择:优先使用 score 高的片段;根据用户主题、关键词与片段的 description、reason、tags 匹配内容;尽量使用多个不同素材,避免同一素材连续堆砌;不要使用与主题明显无关的素材;未分析的素材只作补充。
4. 素材选择:优先使用 score 高的片段;根据用户主题、关键词与片段的 description、reason、tags 匹配内容;尽量使用多个不同素材,避免同一素材连续堆砌;不要使用与主题明显无关的素材;未分析的素材只作补充。含蓄镜头(背影、牵手、表情特写、物品特写)同样可以表达人物关系,不必要求两人同框或正脸。
5. ${ mode }
6. 不要声称添加了不存在的音乐;音频素材列表为空时不要添加 audio 轨。若素材列表中有音频素材且用户要求配乐 / 配音,应添加 audio 轨并按需要调整 volume。
7. 数值范围:speed 0.25– 4, volume 0– 4, fade 0– 10, brightness -1– 1, contrast 0– 2, saturation 0– 3, fontSize 12– 160, color 为 #rrggbb。