feature: implement freeze frame
Description
This PR implements a comprehensive freeze frame functionality that allows users to capture the current frame at the playhead position and insert it as a 5-second image element into the timeline. The feature includes intelligent placement logic that automatically splits videos when the playhead is positioned within an existing video element.
Key features implemented:
- High-quality frame capture at native video resolution
- Automatic video splitting and insertion at playhead position
- Smart placement algorithm for empty timeline areas
- Keyboard shortcut support (F key)
- Professional-quality output matching original video resolution
Type of change
- [x] New feature (non-breaking change which adds functionality)
- [x] Performance improvement
How Has This Been Tested?
The freeze frame functionality has been tested with the following scenarios:
- [x] Freeze frame creation while playhead is positioned within a video element (splits video and inserts freeze frame)
- [x] Freeze frame creation on empty timeline (uses smart placement algorithm)
- [x] Freeze frame creation with overlapping elements (automatically finds next available slot)
- [x] Keyboard shortcut functionality (F key)
- [x] High-quality capture from various video resolutions
- [x] Fallback capture for non-video elements (images, text)
Test Configuration:
- Node version: 18+
- Browser: Chrome/Safari/Firefox
- Operating System: macOS/Windows/Linux
Screenshots (if applicable)
https://github.com/user-attachments/assets/22043fb5-df8f-4346-aed6-5a868ee5725d
Implementation Details
Core Features
-
Frame Capture System: Implemented dual-tier capture system
- Primary: Direct video element capture at native resolution
- Fallback: Enhanced html2canvas with 2x scale for non-video content
-
Smart Placement Logic:
- Detects active video elements at playhead position
- Automatically splits videos and inserts freeze frame
- Falls back to intelligent gap-finding algorithm for empty areas
-
Video Splitting Algorithm:
- Calculates precise trim values for split segments
- Maintains original video quality and timing
- Creates seamless transitions between parts
Technical Implementation
- Added
createFreezeFrame()method to timeline store - Implemented
findNextAvailableTime()for smart placement - Enhanced frame capture with native video resolution support
- Integrated with existing action system and keyboard shortcuts
- Added proper error handling and user feedback
Files Modified
web/src/stores/timeline-store.ts- Core freeze frame logicweb/src/stores/media-store.ts- Enhanced media item creationweb/src/components/editor/timeline.tsx- UI integrationweb/src/components/editor/preview-panel.tsx- Preview panel data attributeweb/src/constants/actions.ts- Action type definitionweb/src/hooks/use-editor-actions.ts- Keyboard shortcut integrationweb/src/stores/keybindings-store.ts- F key bindingweb/src/hooks/use-keyboard-shortcuts-help.ts- Help documentation
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have added screenshots if ui has been changed
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [x] New and existing unit tests pass locally with my changes
- [x] The build completes successfully without errors
Additional context
The implementation follows the existing codebase patterns and integrates seamlessly with the current timeline and media management systems.
Summary by CodeRabbit
-
New Features
- Added the ability to create a freeze frame from the current preview, triggerable via the "f" key or editor action menu.
- Introduced a new action and keyboard shortcut for freeze frame creation, with an entry in the keyboard shortcuts guide.
-
Improvements
- Enhanced timeline to better distinguish horizontal scrolling from vertical zooming.
- Freeze frame creation now includes user feedback for success or error states.
-
Bug Fixes
- Improved error handling and feedback when adding media items.
-
Chores
- Updated dependencies to include html2canvas and its type definitions.
Deploy request for appcut pending review.
Visit the deploys page to approve it
| Name | Link |
|---|---|
| Latest commit | a6a4196da34f548521e2c53fe33fdc2949da06b4 |
@daniel-inderos is attempting to deploy a commit to the OpenCut OSS Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
This change introduces a freeze frame creation feature in the web application's editor. It adds new actions, keybindings, and UI integration for freeze frames, updates the timeline and media stores with supporting methods, and refines wheel event handling in the timeline for improved scrolling behavior. Supporting dependencies and type definitions are also added.
Changes
| File(s) | Change Summary |
|---|---|
| apps/web/package.json | Added "html2canvas" to dependencies and "@types/html2canvas" to devDependencies. |
| apps/web/src/components/editor/preview-panel.tsx | Added data-preview-panel attribute to preview panel root div. |
| apps/web/src/components/editor/timeline.tsx | Integrated freeze frame action, updated wheel event handling to distinguish horizontal scroll from vertical zoom. |
| apps/web/src/constants/actions.ts | Added "freeze-frame" to Action union type. |
| apps/web/src/hooks/use-editor-actions.ts | Added handler for "freeze-frame" action with async logic, error handling, and success/error toasts. |
| apps/web/src/hooks/use-keyboard-shortcuts-help.ts | Added description for "freeze-frame" action under "Editing" category. |
| apps/web/src/stores/keybindings-store.ts | Added default keybinding: key "f" mapped to "freeze-frame" action. |
| apps/web/src/stores/media-store.ts | Changed addMediaItem to return Promise |
| apps/web/src/stores/timeline-store.ts | Added multiple methods supporting freeze frame creation, including frame capture, media item creation, element splitting, and insertion logic. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant TimelineComponent
participant TimelineStore
participant MediaStore
participant PreviewPanel
User->>TimelineComponent: Press "f" or trigger freeze-frame action
TimelineComponent->>TimelineStore: createFreezeFrame()
TimelineStore->>PreviewPanel: Capture current frame (video or html2canvas)
PreviewPanel-->>TimelineStore: Return image blob
TimelineStore->>MediaStore: addMediaItem(projectId, image file)
MediaStore-->>TimelineStore: Return MediaItem
TimelineStore->>TimelineStore: Insert freeze frame element into timeline
TimelineStore->>TimelineComponent: Update timeline state
TimelineComponent->>User: Show toast notification (success or error)
Estimated code review effort
4 (~90 minutes)
Possibly related PRs
- OpenCut-app/OpenCut#395: Modifies the same
onWheelevent handlers in the Timeline component and ScrollArea usage, directly related to the scrolling logic updated here. - OpenCut-app/OpenCut#23: Adds freeze frame action handling in the Timeline component and store, closely related to the freeze frame creation logic introduced in this PR.
Poem
A bunny hopped by the timeline tracks,
With a freeze-frame trick right in its sack.
Press "f" and behold—a snapshot appears,
No more waiting, just joyful cheers!
Scroll left or right, the view’s refined,
With every frame, new art you’ll find.
🐰✨
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between c2886edae11c2ba3584aa41a200eaab40b449d85 and a6a4196da34f548521e2c53fe33fdc2949da06b4.
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
apps/web/package.json(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- apps/web/package.json
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Description
This PR implements a comprehensive freeze frame functionality that allows users to capture the current frame at the playhead position and insert it as a 5-second image element into the timeline. The feature includes intelligent placement logic that automatically splits videos when the playhead is positioned within an existing video element.
Key features implemented:
- High-quality frame capture at native video resolution
- Automatic video splitting and insertion at playhead position
- Smart placement algorithm for empty timeline areas
- Keyboard shortcut support (F key)
- Professional-quality output matching original video resolution
Type of change
- [x] New feature (non-breaking change which adds functionality)
- [x] Performance improvement
How Has This Been Tested?
The freeze frame functionality has been tested with the following scenarios:
- [x] Freeze frame creation while playhead is positioned within a video element (splits video and inserts freeze frame)
- [x] Freeze frame creation on empty timeline (uses smart placement algorithm)
- [x] Freeze frame creation with overlapping elements (automatically finds next available slot)
- [x] Keyboard shortcut functionality (F key)
- [x] High-quality capture from various video resolutions
- [x] Fallback capture for non-video elements (images, text)
Test Configuration:
- Node version: 18+
- Browser: Chrome/Safari/Firefox
- Operating System: macOS/Windows/Linux
Screenshots (if applicable)
Screen.Recording.2025-07-21.at.2.36.19.PM.mov
Implementation Details
Core Features
Frame Capture System: Implemented dual-tier capture system
- Primary: Direct video element capture at native resolution
- Fallback: Enhanced html2canvas with 2x scale for non-video content
Smart Placement Logic:
- Detects active video elements at playhead position
- Automatically splits videos and inserts freeze frame
- Falls back to intelligent gap-finding algorithm for empty areas
Video Splitting Algorithm:
- Calculates precise trim values for split segments
- Maintains original video quality and timing
- Creates seamless transitions between parts
Technical Implementation
- Added
createFreezeFrame()method to timeline store- Implemented
findNextAvailableTime()for smart placement- Enhanced frame capture with native video resolution support
- Integrated with existing action system and keyboard shortcuts
- Added proper error handling and user feedback
Files Modified
web/src/stores/timeline-store.ts- Core freeze frame logicweb/src/stores/media-store.ts- Enhanced media item creationweb/src/components/editor/timeline.tsx- UI integrationweb/src/components/editor/preview-panel.tsx- Preview panel data attributeweb/src/constants/actions.ts- Action type definitionweb/src/hooks/use-editor-actions.ts- Keyboard shortcut integrationweb/src/stores/keybindings-store.ts- F key bindingweb/src/hooks/use-keyboard-shortcuts-help.ts- Help documentationChecklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have added screenshots if ui has been changed
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [x] New and existing unit tests pass locally with my changes
- [x] The build completes successfully without errors
Additional context
The implementation follows the existing codebase patterns and integrates seamlessly with the current timeline and media management systems.
Summary by CodeRabbit
New Features
- Added the ability to create a freeze frame from the current preview, triggerable via the "f" key or editor action menu.
- Introduced a new action and keyboard shortcut for freeze frame creation, with an entry in the keyboard shortcuts guide.
Improvements
- Enhanced timeline to better distinguish horizontal scrolling from vertical zooming.
- Freeze frame creation now includes user feedback for success or error states.
Bug Fixes
- Improved error handling and feedback when adding media items.
Chores
- Updated dependencies to include html2canvas and its type definitions.
Looks quite AI
Description
This PR implements a comprehensive freeze frame functionality that allows users to capture the current frame at the playhead position and insert it as a 5-second image element into the timeline. The feature includes intelligent placement logic that automatically splits videos when the playhead is positioned within an existing video element. Key features implemented:
- High-quality frame capture at native video resolution
- Automatic video splitting and insertion at playhead position
- Smart placement algorithm for empty timeline areas
- Keyboard shortcut support (F key)
- Professional-quality output matching original video resolution
Type of change
- [x] New feature (non-breaking change which adds functionality)
- [x] Performance improvement
How Has This Been Tested?
The freeze frame functionality has been tested with the following scenarios:
- [x] Freeze frame creation while playhead is positioned within a video element (splits video and inserts freeze frame)
- [x] Freeze frame creation on empty timeline (uses smart placement algorithm)
- [x] Freeze frame creation with overlapping elements (automatically finds next available slot)
- [x] Keyboard shortcut functionality (F key)
- [x] High-quality capture from various video resolutions
- [x] Fallback capture for non-video elements (images, text)
Test Configuration:
- Node version: 18+
- Browser: Chrome/Safari/Firefox
- Operating System: macOS/Windows/Linux
Screenshots (if applicable)
Screen.Recording.2025-07-21.at.2.36.19.PM.mov
Implementation Details
Core Features
Frame Capture System: Implemented dual-tier capture system
- Primary: Direct video element capture at native resolution
- Fallback: Enhanced html2canvas with 2x scale for non-video content
Smart Placement Logic:
- Detects active video elements at playhead position
- Automatically splits videos and inserts freeze frame
- Falls back to intelligent gap-finding algorithm for empty areas
Video Splitting Algorithm:
- Calculates precise trim values for split segments
- Maintains original video quality and timing
- Creates seamless transitions between parts
Technical Implementation
- Added
createFreezeFrame()method to timeline store- Implemented
findNextAvailableTime()for smart placement- Enhanced frame capture with native video resolution support
- Integrated with existing action system and keyboard shortcuts
- Added proper error handling and user feedback
Files Modified
web/src/stores/timeline-store.ts- Core freeze frame logicweb/src/stores/media-store.ts- Enhanced media item creationweb/src/components/editor/timeline.tsx- UI integrationweb/src/components/editor/preview-panel.tsx- Preview panel data attributeweb/src/constants/actions.ts- Action type definitionweb/src/hooks/use-editor-actions.ts- Keyboard shortcut integrationweb/src/stores/keybindings-store.ts- F key bindingweb/src/hooks/use-keyboard-shortcuts-help.ts- Help documentationChecklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have added screenshots if ui has been changed
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [x] New and existing unit tests pass locally with my changes
- [x] The build completes successfully without errors
Additional context
The implementation follows the existing codebase patterns and integrates seamlessly with the current timeline and media management systems.
Summary by CodeRabbit
New Features
- Added the ability to create a freeze frame from the current preview, triggerable via the "f" key or editor action menu.
- Introduced a new action and keyboard shortcut for freeze frame creation, with an entry in the keyboard shortcuts guide.
Improvements
- Enhanced timeline to better distinguish horizontal scrolling from vertical zooming.
- Freeze frame creation now includes user feedback for success or error states.
Bug Fixes
- Improved error handling and feedback when adding media items.
Chores
- Updated dependencies to include html2canvas and its type definitions.
Looks quite AI
yeah i kinda generated this description with ai. after a ton of fixing errors on my code i kinda just gave up lol
@daniel-inderos your code also looks obviously AI...
@daniel-inderos your code also looks obviously AI...
Yeah but it works This was a pain to build...
@daniel-inderos your code also looks obviously AI...
Yeah but it works This was a pain to build...
alright, good