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

@remotion/compositor: Faster <OffthreadVideo> concurrency model #4831

Merged
merged 39 commits into from
Feb 13, 2025

Conversation

JonnyBurger
Copy link
Member

@JonnyBurger JonnyBurger commented Jan 28, 2025

This re-architects the Rust binary that is being used for <OffthreadVideo> to properly multithread when using multiple streams are included.

This should by default improve the rendering speed of videos with picture-in-picture layouts or similar, and even makes it a bit faster when using 1 stream.

By default, 2 threads are allowed, but it can be increased or decreased using the new --offthreadvideo-video-threads option.

As always, it is not a good idea to set the concurrency too high, because FFmpeg already uses multiple cores for extracting frames already. Slowly ramp up the value and observe.

This option is designed for users with beefy machines such as high-core VPS-es. We encourage those to play around with the new offthreadVideoThreads option and find an ideal value.

Advanced, experimental option: Frames that are close to each other will still only cause 1 stream to be opened. That still makes sense, as otherwise using multiple threads is wasteful, because most frames in a video depend on other frames before and after.

However, one idea is that we can change the render so it does not render from start to end, but instead one tab renders the first half of the video and the second tab renders the second half of the video. Same idea with n > 2 tabs. This will force more streams to be opened concurrently.

To try out this idea, you can set the REMOTION_PARTITIONED_RENDERING=true environment variable.
We may remove this option in the future if it does turn out to make renders faster.

Copy link

vercel bot commented Jan 28, 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 4:30pm
remotion ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2025 4:30pm

@JonnyBurger JonnyBurger changed the title @remotion/compositor: Rework concurrency model @remotion/compositor: Faster <OffthreadVideo> concurrency model Feb 13, 2025
@JonnyBurger JonnyBurger merged commit e1a5815 into main Feb 13, 2025
13 checks passed
@JonnyBurger JonnyBurger deleted the rust-better-multithreadingx branch February 13, 2025 17:06
@tzvc
Copy link

tzvc commented Feb 14, 2025

Amazing work, I'll try that right away!

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.

Renderer not utilizing CPU cores even with concurrency 100%
2 participants