Skip to content

视频片段倒放、定格和曲线变速 - #84

Open
devin-ai-integration[bot] wants to merge 10 commits into
devin/1796515998-image-backgroundfrom
devin/1796516442-speed-effects
Open

devin-ai-integration[bot] wants to merge 10 commits into
devin/1796515998-image-backgroundfrom
devin/1796516442-speed-effects

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

叠在 #83 上。视频片段新增倒放、定格、曲线变速,预览、MP4 导出、工程保存、剪映草稿和 MCP 都支持。

时间映射集中到 src/render/speed.ts:时间轴帧到素材帧的换算都经过 sourceFrameAt / timelineFrameAt,VideoTrack.sourceTime、关键帧(keyframeFrame)、导出取帧共用。片段长度改用平均速度 effectiveSpeed = speed × curveMean(speedCurve),timeline-kit 的裁剪换算、setSpeed、MCP 也一样。

VideoTrack.speedCurve?: { x: number, y: number }[] // x 为片段进度 0-1,y 为相对 speed 的倍数,线性过渡
VideoTrack.reversed: boolean
  • 曲线变速:属性面板「曲线变速」下拉选预设(蒙太奇、英雄时刻、子弹时间、跳接、闪进、闪出)。曲线铺满片段当前的可见区间,分割时用 sliceCurve 切成两段,切开后显示为「自定义」。导出音频按映射逐采样重采样(curvedBuffer),音调随速度变化;预览每帧把 playbackRate 设为当前速度。
  • 倒放:属性面板开关,从可见区间最后一帧往前播。倒放片段不出声(预览和导出都静音),分割时前半段取素材靠后的部分。
  • 定格:时间轴工具栏「定格」按钮(freezeFrame)。在播放头处分割片段,中间插入一个只播 1 个素材帧、speed = 1/时长 的静音视频片段(默认 3 秒),同轨后面的片段后移。不生成新素材,所以预览、导出、工程保存都直接复用视频片段的逻辑。
  • 工程格式:PackedClip.sc(曲线点列)、rv(倒放)。
  • 剪映:曲线写入 materials.speeds[].curve_speed.speed_points(mode: 1,y 换算成相对平均速度),倒放没有对应字段,记入 skipped。
  • MCP:update_clip 新增 speedCurve(预设名、none 或点列)和 reversed;新增 freeze_frame({ clipId, time, duration })。
  • 曲线变速或倒放的片段不能分离音频。

测试:speed.test.ts、speedEffects.test.ts 单测;MCP e2e 覆盖倒放、曲线、定格、MP4 导出时长、剪映 curve_speed、保存刷新后恢复。

Link to Devin session: https://app.devin.ai/sessions/a882af08b80c444280600c6cdc988c2e
Open in Devin Desktop: https://app.devin.ai/desktop/session/a882af08b80c444280600c6cdc988c2e?variant=devin
Requested by: @x007xyz


🟢 Devin fixed all 9 findings · Follow Devin's work

Devin Review

Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
fly-cut Ready Ready Preview Dec 6, 2026 12:53am UTC

devin-ai-integration Bot and others added 4 commits December 6, 2026 00:37
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
devin-ai-integration Bot and others added 3 commits December 6, 2026 00:42
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>
Co-Authored-By: zhangxiang chen <x007xyzabc@gmail.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 9 findings. Devin automatically fixed all 9 findings.

Fixed by Devin (9)
  • Shortened freeze frames in Jianying — JianYing target duration now uses the timeline length directly; it is only recomputed from the source when the source runs out.
  • Trimmed footage in reverse exports — VideoTrack.sourceTime clamps to offsetL so sub-frame samples never reach trimmed footage; unit test added.
  • Frozen picture changes after trimming — Trim conversion only snaps to whole frames within 1 ms of rounding error, so freeze clips keep their fractional source frame; unit test added.
  • Unreadable projects after custom-curve saves — Curve y values are saved unrounded so tiny valid speeds survive reload.
  • Reversed trims remove the wrong end — Reversed clips map timeline left trim to offsetR and right trim to offsetL.
  • Freeze frames advance to another image — Freeze clips now span 0.001 source frames so they stay on one decoded image at any fps.
  • Shifted footage after reversed-curve splits — Reversed mapping is offsetL + F(end) - F(f+1), independent of average speed; split boundary uses the same forward integral. Unit test covers continuity.
  • Trimmed video starts on the previous frame — Trim drags now shift the source offset by the rounded timeline-frame delta times speed, matching the rounded clip edge; a 1x clip keeps whole-frame offsets. Unit test added.
  • Full clip extension leaves frames trimmed — Dragging a trim to 0 ms or the full media length now clears that side's offset instead of applying a rounded shift; unit test added.

View findings in Devin Review · Follow Devin's work

Devin Review

This branch was successfully deployed

1 active deployment
Preview — 50b9733a Deployed Dec 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant