Skip to content

feat: implement Automated Smart-Trim via FFmpeg silencedetect#1553

Open
samalbishnupriya06-stack wants to merge 1 commit into
magic-peach:mainfrom
samalbishnupriya06-stack:feat/smart-trim-silence-detection
Open

feat: implement Automated Smart-Trim via FFmpeg silencedetect#1553
samalbishnupriya06-stack wants to merge 1 commit into
magic-peach:mainfrom
samalbishnupriya06-stack:feat/smart-trim-silence-detection

Conversation

@samalbishnupriya06-stack

Copy link
Copy Markdown

Summary

Implements Automated Smart-Trim (Phase 1 + Phase 2 + Phase 3 skeleton) as described in issue #<ISSUE_NUMBER>.

Uses the existing FFmpeg WASM pipeline to detect silent segments client-side — no data ever leaves the browser.


Changes

New Files

  • src/hooks/useSmartTrim.ts — state hook for silence detection, segment toggling, and keep-range computation
  • src/components/SmartTrimControl.tsx — UI panel with configurable threshold, segment list, Apply/Reset actions
  • src/components/SilenceTimeline.tsx — visual overlay on the video timeline showing silence intervals

Modified Files

  • src/lib/types.ts — added SilenceSegment and SmartTrimStatus types
  • src/lib/ffmpeg.ts — added detectSilence() using FFmpeg's silencedetect filter
  • src/components/VideoEditor.tsx — integrated useSmartTrim hook and new components

How It Works

  1. User clicks Detect Silence in the Smart Trim panel
  2. detectSilence() runs ffmpeg -af silencedetect=noise=XdB:duration=Ys -f null - on the uploaded file
  3. Stdout/stderr is parsed for silence_start / silence_end timestamps
  4. Segments appear as purple highlights on the timeline and a reviewable list in the sidebar
  5. User toggles individual segments, then clicks Apply Trim (N) to compute keep ranges


Testing Done

  • Tested with a video that has clear silence gaps
  • Tested with a video that has no silence (edge case: empty list shown)
  • Confirmed no network requests are made during analysis (DevTools → Network)
  • Tested Apply Trim logs correct keep ranges to console
  • No TypeScript errors (bun run build passes)
  • No ESLint errors

Notes for Reviewers

  • Phase 3 integration (feeding keepRanges into the export pipeline for multi-segment concat) is scaffolded in handleSmartTrimApply but left as a follow-up, as it requires changes to the FFmpeg filtergraph concat logic. See the TODO comment in VideoEditor.tsx.
  • The detectSilence function creates its own FFmpeg instance to avoid interfering with the main export pipeline. If the project later moves to a shared instance, this can be refactored.

Closes #1146

- Add SilenceSegment and SmartTrimStatus types to src/lib/types.ts
- Add detectSilence() function to src/lib/ffmpeg.ts using silencedetect filter
- Create useSmartTrim hook for silence state management
- Create SmartTrimControl component with detect/review/apply UI
- Create SilenceTimeline component for visual overlay on video timeline
- Wire all components into VideoEditor.tsx

Signed-off-by: Samal Bishnupriya <samalbishnupriya.06@gmail.com>
@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

@samalbishnupriya06-stack is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added level:advanced Advanced level - 55 pts type:design UI/UX design type:testing Testing labels Jun 7, 2026
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

✅ PR Format Check Passed — @samalbishnupriya06-stack

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @samalbishnupriya06-stack!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:advanced Advanced level - 55 pts type:design UI/UX design type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]

1 participant