@lalalic/markcut 3.2.32 → 3.2.33

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalalic/markcut",
3
- "version": "3.2.32",
3
+ "version": "3.2.33",
4
4
  "description": "Markdown-to-video engine. Describe scenes in markdown, get a rendered video.",
5
5
  "bin": {
6
6
  "markcut": "bin/markcut"
@@ -10,6 +10,17 @@ export function findMapScenes(root){
10
10
  return (root?.children||[]).filter(x=>x?.type==="scene"&&x.visible!==false&&
11
11
  Array.isArray(x.children)&&x.children.some(child=>child.type==="map"));
12
12
  }
13
+ /** Render only the map visual. Keep independent narration, ambience and BGM in the live preview. */
14
+ export function mapVisualOnlyScene(scene){
15
+ return {...structuredClone(scene),children:structuredClone((scene.children||[]).filter(child=>child.type==="map"))};
16
+ }
17
+ export function replaceMapWithFootage(scene,src,duration,index){
18
+ const visual={id:"map-footage-"+index,type:"video",visible:true,start:0,end:duration,
19
+ durationInSeconds:duration,src,volume:0};
20
+ // Do not drop independent speech/audio siblings when replacing a map leaf.
21
+ scene.children=(scene.children||[]).flatMap(child=>child.type==="map"?[visual]:[child]);
22
+ return scene;
23
+ }
13
24
  export async function renderMapFootage(compiled,{generatedDir,key,onProgress=()=>{}}){
14
25
  const root=compiled.root||compiled;
15
26
  const scenes=findMapScenes(root);
@@ -28,7 +39,7 @@ export async function renderMapFootage(compiled,{generatedDir,key,onProgress=()=
28
39
  const destination=join(generatedDir,name);
29
40
  const temporary=await mkdtemp(join(tmpdir(),"markcut-map-render-"));
30
41
  try{
31
- const source=structuredClone(scene);
42
+ const source=mapVisualOnlyScene(scene);
32
43
  const isolated={...structuredClone(outputRoot),isSeries:true,children:[source],durationInSeconds:duration};
33
44
  delete isolated.subtitle; // Global captions belong to the final video, not map footage.
34
45
  const file=join(temporary,"props.json");
@@ -40,8 +51,7 @@ export async function renderMapFootage(compiled,{generatedDir,key,onProgress=()=
40
51
  ],{cwd:projectRoot,timeout:180000,maxBuffer:1024*1024*4,env:process.env});
41
52
  if((await stat(join(temporary,name))).size<1024)throw Error("Empty map footage");
42
53
  await rename(join(temporary,name),destination);
43
- scene.children=[{id:"map-footage-"+index,type:"video",visible:true,start:0,end:duration,
44
- durationInSeconds:duration,src:destination,volume:0}];
54
+ replaceMapWithFootage(scene,destination,duration,index);
45
55
  rendered++;
46
56
  }catch(error){
47
57
  skipped++;
@@ -205,7 +205,7 @@ export async function ensureVideoPreview(path, options = {}) {
205
205
  const hash=createHash("sha256").update(validatedPath).update("\0")
206
206
  .update(source).update("\0").update(JSON.stringify(referencedAssets)).update("\0").update(audio.audioSrc||"")
207
207
  .update("\0").update(process.env.GOOGLE_MAPS_API_KEY||"")
208
- .update("\0").update("map-footage-v2").digest("hex");
208
+ .update("\0").update("map-footage-v3-auto-viewport").digest("hex");
209
209
  const id=hash;
210
210
  let index={entries:[]};
211
211
  try {index=JSON.parse(await readFile(indexFile,"utf8"));} catch{}
@@ -1,5 +1,5 @@
1
1
  import {describe,it,expect} from "vitest";
2
- import {findMapScenes,renderMapFootage} from "../src/mcp/map-footage.mjs";
2
+ import {findMapScenes,renderMapFootage,mapVisualOnlyScene,replaceMapWithFootage} from "../src/mcp/map-footage.mjs";
3
3
 
4
4
  const root=()=>({type:"root",children:[
5
5
  {type:"scene",name:"Opening",visible:true,children:[{type:"component"}]},
@@ -22,3 +22,22 @@ describe("Remotion map-footage precompilation",()=>{
22
22
  expect(findMapScenes(compiled)).toHaveLength(2);
23
23
  });
24
24
  });
25
+
26
+
27
+ describe('map footage narration retention',()=>{
28
+ it('renders map pixels without baking a separate voice into video',()=>{
29
+ const scene={type:'scene',durationInSeconds:8,children:[{type:'map',view:'route',children:[{type:'image',src:'photo.jpg'}]},{type:'audio',src:'voice.mp3',volume:0.9},{type:'audio',src:'bgm.mp3',volume:0.2,isBackground:true}]};
30
+ const video=mapVisualOnlyScene(scene);
31
+ expect(video.children).toHaveLength(1);
32
+ expect(video.children[0].type).toBe('map');
33
+ expect(video.children[0].children[0].src).toBe('photo.jpg');
34
+ expect(scene.children).toHaveLength(3);
35
+ });
36
+ it('replaces the map only, retaining speech, BGM and source sound',()=>{
37
+ const scene={type:'scene',children:[{id:'map',type:'map',children:[]},{id:'narrator',type:'audio',src:'voice.mp3',volume:1},{id:'music',type:'audio',src:'bgm.mp3',isBackground:true,volume:0.2},{id:'ambience',type:'audio',src:'river.wav',volume:0.7}]};
38
+ replaceMapWithFootage(scene,'render.mp4',12,0);
39
+ expect(scene.children.map(c=>c.type)).toEqual(['video','audio','audio','audio']);
40
+ expect(scene.children.map(c=>c.src)).toEqual(['render.mp4','voice.mp3','bgm.mp3','river.wav']);
41
+ expect(scene.children[0].volume).toBe(0);
42
+ });
43
+ });