diff --git a/schemas/videoasset.yaml b/schemas/videoasset.yaml index 1bc353a..bc1e94f 100644 --- a/schemas/videoasset.yaml +++ b/schemas/videoasset.yaml @@ -109,16 +109,27 @@ type: string speed: description: >- - Adjust the playback speed of the video clip between 0 (paused) and 10 (10x normal speed) where 1 is normal - speed (defaults to 1). Adjusting the speed will also adjust the duration of the clip and may require you to - adjust the Clip length. For example, if you set speed to 0.5, the clip will need to be 2x as long to play - the entire video (i.e. original length / 0.5). If you set speed to 2, the clip will need to be half as long - to play the entire video (i.e. original length / 2). - type: number - format: float - minimum: 0 - maximum: 10 - example: 1 + Adjust the playback speed of the video clip. Use a number for a constant speed or an array of + [Tween](./#tocs_tween) objects to change speed over time, for example easing from normal speed up to 3x. + oneOf: + - type: number + description: >- + The playback speed between 0 (paused) and 10 (10x normal speed) where 1 is normal speed (defaults to + 1). Adjusting the speed will also adjust the duration of the clip and may require you to adjust the + Clip length. For example, if you set speed to 0.5, the clip will need to be 2x as long to play the + entire video (i.e. original length / 0.5). If you set speed to 2, the clip will need to be half as + long to play the entire video (i.e. original length / 2). + format: float + minimum: 0 + maximum: 10 + example: 1 + - type: array + description: >- + An array of [Tween](./#tocs_tween) objects that change the playback speed over time. A speed of 0 + holds the current frame. The clip length is not adjusted, so set it to cover the footage you want to + play. + items: + $ref: "./tween.yaml#/Tween" crop: $ref: "./crop.yaml#/Crop" chromaKey: diff --git a/tests/smoke.cjs b/tests/smoke.cjs index 81e3eb4..fee16cf 100644 --- a/tests/smoke.cjs +++ b/tests/smoke.cjs @@ -206,6 +206,20 @@ async function run() { assert.strictEqual(result.src, "https://example.com/video.mp4"); }); + check("Parse videoAsset with animated speed", () => { + const result = zodCjs.videoAssetSchema.parse({ + type: "video", + src: "https://example.com/video.mp4", + speed: [{ from: 1, to: 3, start: 0, length: 1, interpolation: "bezier", easing: "easeInOut" }], + }); + assert.strictEqual(result.speed.length, 1); + }); + + check("Parse videoAsset with numeric speed (existing shape)", () => { + const result = zodCjs.videoAssetSchema.parse({ type: "video", src: "https://example.com/video.mp4", speed: 2 }); + assert.strictEqual(result.speed, 2); + }); + check("Parse audioAsset with src only (existing shape)", () => { const result = zodCjs.audioAssetSchema.parse({ type: "audio",