44 mkdirSync ,
55 mkdtempSync ,
66 readFileSync ,
7+ readdirSync ,
78 rmSync ,
89 statSync ,
910 symlinkSync ,
@@ -58,6 +59,8 @@ function createV1Plan(
5859 videoId ?: string ;
5960 videoSrcPath ?: string ;
6061 framePattern ?: string ;
62+ videoStart ?: number ;
63+ videoEnd ?: number ;
6164 } ,
6265) : string {
6366 const {
@@ -70,6 +73,8 @@ function createV1Plan(
7073 videoId = "hero" ,
7174 videoSrcPath = "/fixture/hero.mp4" ,
7275 framePattern = "frame_%05d.jpg" ,
76+ videoStart = 0 ,
77+ videoEnd = 1 ,
7378 } = options ?? { } ;
7479 const planDir = join ( root , "v1" ) ;
7580 mkdirSync ( join ( planDir , "compiled" ) , { recursive : true } ) ;
@@ -98,8 +103,8 @@ function createV1Plan(
98103 {
99104 id : videoId ,
100105 src : "hero.mp4" ,
101- start : 0 ,
102- end : 1 ,
106+ start : videoStart ,
107+ end : videoEnd ,
103108 mediaStart : 0 ,
104109 loop : false ,
105110 hasAudio : false ,
@@ -328,6 +333,41 @@ describe("Plan v2 manifest", () => {
328333 ) ;
329334 } ) ;
330335
336+ it ( "materializes empty video directories for chunks where the video is inactive" , ( ) => {
337+ const root = tempPath ( "hf-plan-v2-inactive-video-directory-" ) ;
338+ const v1 = createV1Plan ( root , {
339+ video : true ,
340+ videoStart : 1 / 30 ,
341+ videoEnd : 1 ,
342+ } ) ;
343+ const result = createPlanV2FromV1 ( v1 , join ( root , "v2" ) ) ;
344+ const manifest = readPlanV2Manifest ( result . planDir ) ;
345+ const chunk0Artifacts = listPlanV2ArtifactsForTarget ( manifest , {
346+ role : "chunk" ,
347+ chunkIndex : 0 ,
348+ } ) ;
349+ const chunk1Artifacts = listPlanV2ArtifactsForTarget ( manifest , {
350+ role : "chunk" ,
351+ chunkIndex : 1 ,
352+ } ) ;
353+ const chunk0Dir = join ( root , "chunk-0" ) ;
354+ const chunk1Dir = join ( root , "chunk-1" ) ;
355+
356+ expect ( chunk0Artifacts . some ( ( artifact ) => artifact . path . startsWith ( "video-frames/hero/" ) ) ) . toBe (
357+ false ,
358+ ) ;
359+ expect (
360+ chunk1Artifacts . some ( ( artifact ) => artifact . path === "video-frames/hero/frame_00001.jpg" ) ,
361+ ) . toBe ( true ) ;
362+
363+ materializePlanV2Target ( result . planDir , { role : "chunk" , chunkIndex : 0 } , chunk0Dir ) ;
364+ materializePlanV2Target ( result . planDir , { role : "chunk" , chunkIndex : 1 } , chunk1Dir ) ;
365+
366+ expect ( existsSync ( join ( chunk0Dir , "video-frames" , "hero" ) ) ) . toBe ( true ) ;
367+ expect ( readdirSync ( join ( chunk0Dir , "video-frames" , "hero" ) ) ) . toEqual ( [ ] ) ;
368+ expect ( existsSync ( join ( chunk1Dir , "video-frames" , "hero" , "frame_00001.jpg" ) ) ) . toBe ( true ) ;
369+ } ) ;
370+
331371 const partialColorSpaceCases = [
332372 {
333373 name : "matrix-only" ,
@@ -438,6 +478,15 @@ describe("Plan v2 manifest", () => {
438478 } ) ;
439479 }
440480
481+ it ( "rejects an extracted video identifier that escapes the video-frame root" , ( ) => {
482+ const root = tempPath ( "hf-plan-v2-unsafe-video-id-" ) ;
483+ const v1 = createV1Plan ( root , { video : true , videoId : "../escape" } ) ;
484+
485+ expect ( ( ) => createPlanV2FromV1 ( v1 , join ( root , "v2" ) ) ) . toThrow (
486+ 'unsafe extracted video id: "../escape"' ,
487+ ) ;
488+ } ) ;
489+
441490 it ( "falls back to the full source frame pack when video metadata is absent" , ( ) => {
442491 const root = tempPath ( "hf-plan-v2-video-fallback-" ) ;
443492 const result = createPlanV2FromV1 (
0 commit comments