Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Chroma Key Effects Component with RGB Color Selection #4886

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

anksji
Copy link

@anksji anksji commented Feb 13, 2025

Fixes #4841

Overview

A lightweight, performant chroma key component for Remotion that enables video transparency with configurable RGB color removal.

Implementation

Location: packages/effects/src/ChromaKeyEffect.ts

Technical Details

  • Pure WebGL2 implementation using GLSL ES 3.00
  • Optimized shader with single-pass chroma keying
  • Efficient texture sampling and blending
  • Minimal WebGL state changes
  • Memory-efficient vertex buffer handling
  • Typescript support with full type definitions

Features

<ChromaKeyEffect
          src={videosource} //green screen source video url
          startTimeInSeconds={0} //video start time
          durationInSeconds={5} //for how much time it should play
          isChromaKeyEnabled={true} //is needed to use chroma key
          isPlaying={isPlaying} //for state management play/pause
          scale={0.8} // video scale
          chromaKeyConfig={{
            keyColor: [0.0, 1.0, 0.0],  // RGB values [0-1]
            similarity: 0.72,   // Color match threshold
            smoothness: 0.7, // Edge smoothing
            spill: 0.3,  // Color spill reduction
          }}
        />

Performance

  • Real-time processing optimization
  • Minimal GPU memory usage
  • Efficient shader compilation

Testing

Published package for review: @stackops/remotion-chroma-key-effects

Documentation and examples included. Happy to make any adjustments based on feedback.

@JonnyBurger Thanks for the feedback! I understand the concerns.
Let me know if you need any clarification or changes to better align with Remotion's standards.

Copy link

vercel bot commented Feb 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2025 3:17pm
remotion ❌ Failed (Inspect) Feb 13, 2025 3:17pm

@anksji
Copy link
Author

anksji commented Feb 15, 2025

@JonnyBurger
Thank you for addressing the previous feedback by creating a more focused PR! I've streamlined the implementation to include only the essential library-related code, which should align better with remotion's codebase structure. The changes are now more targeted and maintainable. Please let me know your thoughts.

Looking forward to contributing more to remotion!
Happy Coding :)

@JonnyBurger
Copy link
Member

Thanks a lot!

This seems to be an example Vite app, not a package that people would install to use in their own app.
For this reason, I think this would be more valuable either in the docs, or as a standalone repository.

Do you agree and would you also be willing to help converting it?

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.

Advanced Chroma Key
2 participants