@lalalic/markcut 3.2.64 → 3.2.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -84,21 +84,63 @@ function mediaSrc(videoPath,edit){
|
|
|
84
84
|
if(candidates.length!==1)throw Error('EDL source_id '+JSON.stringify(id)+' does not uniquely resolve; specify source_src');
|
|
85
85
|
return confinedMediaSrc(videoPath,'input/media/'+candidates[0]);
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
// Escape JSX expression delimiters as well as HTML, since EDL strings are
|
|
88
|
+
// inserted into JSX children, not into an ordinary inert HTML document.
|
|
89
|
+
const html=s=>String(s??'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''').replace(/{/g,'{').replace(/}/g,'}').replace(/[\r\n]+/g,' ');
|
|
90
|
+
// Keep complete Editorial Decision text in the playable overlay: EDL is the
|
|
91
|
+
// source of truth and should never be silently ellipsized or drop fields.
|
|
92
|
+
// Prefer the large 1080x1920 typography, then decrease type only when the
|
|
93
|
+
// FULL caption needs the space. Unlike a scroll region, these sizes are
|
|
94
|
+
// deterministic Remotion frames and remain visible in exported video.
|
|
95
|
+
function shotTypography(edit,src,sections,width,height){
|
|
96
|
+
const canvasScale=Math.min(width/1080,height/1920);
|
|
97
|
+
// CSS percentage padding uses the container WIDTH on all four sides.
|
|
98
|
+
const usableWidth=width*0.90,usableHeight=height-width*0.10;
|
|
99
|
+
const glyphWidth=text=>[...String(text)].reduce((sum,ch)=>sum+(
|
|
100
|
+
/[\u2E80-\u9FFF\uAC00-\uD7AF\uFF01-\uFF60]/u.test(ch)?1:
|
|
101
|
+
/\s/.test(ch)?.36:/[iIl.,:;!|'`]/.test(ch)?.34:/[MW@#%&]/.test(ch)?.83:.61),0);
|
|
102
|
+
const estimateLines=(text,font)=>Math.max(1,Math.ceil(glyphWidth(text)*font*1.18/usableWidth));
|
|
103
|
+
const source=`SOURCE: ${src} [${edit.in_seconds.toFixed(2)}–${edit.out_seconds.toFixed(2)}s]`;
|
|
104
|
+
const desc=sections.map(([label,text])=>`${label}: ${text}`);
|
|
105
|
+
for(let n=20;n>=9;n--){
|
|
106
|
+
const shrink=n/20*canvasScale;
|
|
107
|
+
const title=68*shrink,sourceFont=38*shrink,body=46*shrink,gap=23*shrink;
|
|
108
|
+
const needed=estimateLines(edit.shot_id,title)*title*1.14+
|
|
109
|
+
estimateLines(source,sourceFont)*sourceFont*1.3+
|
|
110
|
+
desc.reduce((sum,text)=>sum+estimateLines(text,body)*body*1.28,0)+
|
|
111
|
+
(desc.length+1)*gap;
|
|
112
|
+
if(needed<=usableHeight*0.95)
|
|
113
|
+
return {title:Math.round(title*100)/100,source:Math.round(sourceFont*100)/100,body:Math.round(body*100)/100,label:Math.round(34*shrink*100)/100,gap:Math.round(gap*100)/100};
|
|
114
|
+
}
|
|
115
|
+
throw Error('EDL Shot '+edit.shot_id+' has too much decision text to fit on one frame; split the decision into separate shots instead of clipping it');
|
|
116
|
+
}
|
|
117
|
+
function overlay(edit,index,src,width,height){
|
|
118
|
+
const sections=[
|
|
119
|
+
['BEAT',edit.shot_purpose],
|
|
120
|
+
['STORY',edit.beat],
|
|
121
|
+
['STORY BEAT ID',edit.story_beat_id],
|
|
122
|
+
['EDITOR REASON',edit.editor_reason],
|
|
123
|
+
['CUT REASON',edit.cut_reason],
|
|
124
|
+
['VISUAL RELATIONSHIP',edit.visual_relationship],
|
|
125
|
+
['SOUND DECISION',edit.sound_decision],
|
|
126
|
+
['AUDIO INTENT',edit.audioIntent],
|
|
127
|
+
['TRANSITION',edit.transition],
|
|
128
|
+
['REVISION NOTE',edit.revision_note],
|
|
129
|
+
].filter(([,value])=>nonEmpty(value));
|
|
130
|
+
const size=shotTypography(edit,src,sections,width,height);
|
|
131
|
+
const heading=`<div style={{fontSize:${size.title},fontWeight:800,lineHeight:1.14,overflowWrap:'anywhere'}}>${html(edit.shot_id)}</div>`;
|
|
132
|
+
const source=`<div style={{fontSize:${size.source},fontWeight:600,lineHeight:1.3,opacity:.9,overflowWrap:'anywhere'}}>SOURCE: ${html(src)} [${edit.in_seconds.toFixed(2)}–${edit.out_seconds.toFixed(2)}s]</div>`;
|
|
133
|
+
const descriptions=sections.map(([label,value])=>`<div style={{fontSize:${size.body},lineHeight:1.28,overflowWrap:'anywhere',whiteSpace:'pre-wrap'}}><span style={{fontSize:${size.label},fontWeight:700,letterSpacing:1,color:'#a5d8ff'}}>${label}:</span> ${html(value)}</div>`).join('');
|
|
134
|
+
return `<div style={{boxSizing:'border-box',width:'100%',height:'100%',display:'flex',flexDirection:'column',justifyContent:'flex-start',alignItems:'stretch',gap:${size.gap},overflowY:'hidden',padding:'5%',color:'white',fontFamily:'Arial,sans-serif',textShadow:'0 2px 5px rgba(0,0,0,.85)',background:'linear-gradient(180deg,rgba(0,0,0,.94),rgba(0,0,0,.78) 62%,rgba(0,0,0,.34))'}}>${heading}${source}${descriptions}</div>`;
|
|
94
135
|
}
|
|
136
|
+
|
|
95
137
|
export function editorDecisionToMarkdown(videoPath,edl,markdown=readFileSync(videoPath,'utf8')){
|
|
96
138
|
validateEditorDecision(edl);
|
|
97
139
|
const width=Number(/\bwidth:(\d+)/.exec(markdown)?.[1]||1080),height=Number(/\bheight:(\d+)/.exec(markdown)?.[1]||1920);
|
|
98
140
|
const fps=Number(/\bfps:(\d+)/.exec(markdown)?.[1]||30);
|
|
99
141
|
const out=['# video','width:'+width+' height:'+height+' fps:'+fps+' layout:series'];
|
|
100
142
|
if(nonEmpty(edl.editorial_intent)){
|
|
101
|
-
const jsx="<div style={{boxSizing:'border-box',width:'100%',height:'100%',background:'#111827',color:'white',display:'flex',alignItems:'center',justifyContent:'center',padding:'10%',fontSize:46,textAlign:'center'}}>"+html(
|
|
143
|
+
const jsx="<div style={{boxSizing:'border-box',width:'100%',height:'100%',background:'#111827',color:'white',display:'flex',alignItems:'center',justifyContent:'center',padding:'10%',fontSize:46,textAlign:'center'}}>"+html(edl.editorial_intent)+'</div>';
|
|
102
144
|
out.push('','## EditorialIntent','layout:parallel','- component duration:3 jsx:'+JSON.stringify(jsx));
|
|
103
145
|
}
|
|
104
146
|
for(const [i,e] of edl.edits.entries()){
|
|
@@ -109,7 +151,7 @@ export function editorDecisionToMarkdown(videoPath,edl,markdown=readFileSync(vid
|
|
|
109
151
|
if(imageExts.has(ext))out.push('- image src:'+src+' duration:'+duration.toFixed(4)+' fit:cover');
|
|
110
152
|
else if(videoExts.has(ext))out.push('- video src:'+src+' startFrom:'+e.in_seconds+' endAt:'+e.out_seconds+' duration:'+duration.toFixed(4)+' playbackRate:'+speed+' volume:1 fit:cover');
|
|
111
153
|
else throw Error('Unsupported EDL media format: '+src);
|
|
112
|
-
out.push('- component duration:'+duration.toFixed(4)+' jsx:'+JSON.stringify(overlay(e,i,src)));
|
|
154
|
+
out.push('- component duration:'+duration.toFixed(4)+' jsx:'+JSON.stringify(overlay(e,i,src,width,height)));
|
|
113
155
|
}
|
|
114
156
|
return out.join('\n')+'\n';
|
|
115
157
|
}
|
|
@@ -40,6 +40,9 @@ test('converts decisions into playable Markcut Markdown with original source and
|
|
|
40
40
|
assert.match(md,/## EditorialIntent/);
|
|
41
41
|
assert.match(md,/## Shot1/);
|
|
42
42
|
assert.match(md,/## Shot2/);
|
|
43
|
+
const overlay2=JSON.parse(md.match(/## Shot2[\s\S]*?- component duration:[^\n]*?jsx:([^\n]+)/)[1]);
|
|
44
|
+
assert.match(overlay2,/>reaction<\/div>/);
|
|
45
|
+
assert.doesNotMatch(overlay2,/SHOT 2/);
|
|
43
46
|
assert.match(md,/startFrom:1 endAt:2 duration:1.0000/);
|
|
44
47
|
assert.match(md,/Set geography/);
|
|
45
48
|
assert.match(md,/retain source sound/);
|
|
@@ -49,6 +52,75 @@ test('converts decisions into playable Markcut Markdown with original source and
|
|
|
49
52
|
}finally{f.cleanup();}
|
|
50
53
|
});
|
|
51
54
|
|
|
55
|
+
test('Editor Decisions shot overlay begins at top with larger type and never truncates EDL text',()=>{
|
|
56
|
+
const f=setup();
|
|
57
|
+
try{
|
|
58
|
+
const marker='FULL_REASON_END_987654321';
|
|
59
|
+
const reason='Narrative continuity, source-grounded editorial intention. '.repeat(8)+marker;
|
|
60
|
+
const decision={...EDL,edits:[{
|
|
61
|
+
...EDL.edits[0],shot_purpose:'Purpose should not replace story beat',
|
|
62
|
+
editor_reason:reason,
|
|
63
|
+
visual_relationship:'wide shot to detailed close-up',
|
|
64
|
+
sound_decision:'preserve natural source audio',audioIntent:'do not duck the recording',
|
|
65
|
+
revision_note:'keep the original observation',story_beat_id:'story-beat-abc',
|
|
66
|
+
transition:'match cut from {shot} to <scene>',cut_reason:'Independent cut reason {not_an_expression}'
|
|
67
|
+
}]};
|
|
68
|
+
const md=editorDecisionToMarkdown(f.video,decision,'# video\nwidth:1080 height:1920 fps:30 layout:series');
|
|
69
|
+
const component=md.split('- component duration:1.0000 jsx:')[1];
|
|
70
|
+
const jsx=JSON.parse(component.trim());
|
|
71
|
+
assert.match(jsx,/>wide<\/div>/);
|
|
72
|
+
assert.doesNotMatch(jsx,/SHOT 1/);
|
|
73
|
+
assert.match(jsx,/justifyContent:'flex-start'/);
|
|
74
|
+
assert.doesNotMatch(jsx,/justifyContent:'flex-end'/);
|
|
75
|
+
const title=Number(jsx.match(/fontSize:([\d.]+)/)[1]);
|
|
76
|
+
const body=Number(jsx.match(/<div style=\{\{fontSize:([\d.]+),lineHeight:1\.28/)[1]);
|
|
77
|
+
assert.ok(title>33&&title<=68,`shot title must remain larger than prior 33px, got ${title}`);
|
|
78
|
+
assert.ok(body>24&&body<=46,`shot body must remain larger than prior 24px, got ${body}`);
|
|
79
|
+
assert.match(jsx,/overflowY:'hidden'/);
|
|
80
|
+
assert.match(jsx,/FULL_REASON_END_987654321/);
|
|
81
|
+
assert.match(jsx,/Independent cut reason/);
|
|
82
|
+
assert.match(jsx,/Purpose should not replace story beat/);
|
|
83
|
+
assert.match(jsx,/story-beat-abc/);
|
|
84
|
+
assert.match(jsx,/wide shot to detailed close-up/);
|
|
85
|
+
assert.match(jsx,/preserve natural source audio/);
|
|
86
|
+
assert.match(jsx,/do not duck the recording/);
|
|
87
|
+
assert.match(jsx,/keep the original observation/);
|
|
88
|
+
assert.match(jsx,/TRANSITION:/);
|
|
89
|
+
assert.match(jsx,/match cut from {shot} to <scene>/);
|
|
90
|
+
assert.match(jsx,/Independent cut reason {not_an_expression}/);
|
|
91
|
+
assert.doesNotMatch(jsx,/\{not_an_expression\}/);
|
|
92
|
+
assert.doesNotMatch(jsx,/…/);
|
|
93
|
+
assert.ok(jsx.indexOf('SHOT 1')<jsx.indexOf('SOURCE:')&&jsx.indexOf('SOURCE:')<jsx.indexOf('EDITOR REASON:'));
|
|
94
|
+
}finally{f.cleanup();}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('shot typography scales down if necessary and rejects impossible single-frame content',()=>{
|
|
98
|
+
const f=setup();
|
|
99
|
+
try{
|
|
100
|
+
const run=reason=>editorDecisionToMarkdown(f.video,{...EDL,edits:[{...EDL.edits[0],editor_reason:reason}]},'# video\nwidth:1080 height:1920 fps:30 layout:series');
|
|
101
|
+
const moderate='Long source-grounded explanation about the observed moments. '.repeat(22);
|
|
102
|
+
const md=run(moderate),jsx=JSON.parse(md.split('- component duration:1.0000 jsx:')[1].trim());
|
|
103
|
+
const size=Number(jsx.match(/fontSize:([\d.]+)/)[1]);
|
|
104
|
+
assert.ok(size<68&&size>=30,`expected fitted title, got ${size}`);
|
|
105
|
+
assert.ok(jsx.includes(moderate));
|
|
106
|
+
assert.match(jsx,/overflowY:'hidden'/);
|
|
107
|
+
assert.throws(()=>run('Very long reason. '.repeat(1500)),/too much decision text to fit on one frame/);
|
|
108
|
+
}finally{f.cleanup();}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('editorial intent text is safely escaped as inert JSX content',()=>{
|
|
112
|
+
const f=setup();
|
|
113
|
+
try{
|
|
114
|
+
const md=editorDecisionToMarkdown(f.video,{...EDL,editorial_intent:'Observe {globalThis.alert(1)} <picture> & keep it real'});
|
|
115
|
+
const first=md.match(/- component duration:3 jsx:([^\n]+)/);
|
|
116
|
+
assert.ok(first);
|
|
117
|
+
const jsx=JSON.parse(first[1]);
|
|
118
|
+
assert.match(jsx,/{globalThis\.alert\(1\)}/);
|
|
119
|
+
assert.match(jsx,/<picture> & keep it real/);
|
|
120
|
+
assert.doesNotMatch(jsx,/\{globalThis\.alert\(1\)\}/);
|
|
121
|
+
}finally{f.cleanup();}
|
|
122
|
+
});
|
|
123
|
+
|
|
52
124
|
test('refuses malformed timing, duplicate shots and path traversal rather than rendering invented footage',()=>{
|
|
53
125
|
const f=setup();
|
|
54
126
|
try{
|