Skip to content

Conversation

@ryanontheinside
Copy link
Collaborator

Rebase after merging #219

## Summary
Fix v2v streaming choppiness when using fast VAEs (LightVAE/TAE) by basing frame consumption rate on measured input FPS rather than pipeline production throughput. This fix is required to introduce faster VAEs and likely other performance enhancements.

## Problem
LightVAE and TAE produced choppy playback during v2v streaming, where the boundaries of the chunks are visible. The slower Wan VAE worked perfectly. Symptoms:
- Choppiness only with fast VAEs
- Test scripts produced smooth output
- Choppiness went away after ~45 seconds or when using more denoise steps
- Choppiness _sometimes_ went away upon updating the prompt
- Lightvae and Wan vae are virtually identical apart from processing speed. Tae is faster still

## Root Cause
The frame consumption rate (how fast WebRTC sends frames to the client) was calculated from **production throughput** (how fast the GPU produces frames) rather than **content temporal rate** (how fast frames should be played).

Eg, when a fast VAE produces 12 frames in 0.3s, the code calculated FPS=40 and sent frames to the client at 40fps. But the video content should maintain its original temporal rate for correct motion - playing it faster causes choppy/jerky appearance.

The test scripts worked because they export with a fixed FPS value, not the production rate.

## Solution
Measure the actual input video frame rate by tracking timestamps of incoming frames, then use that rate for consumption:
- Track timestamps of last 30 incoming frames in `input_loop()`
- Calculate input FPS from frame intervals
- Use input FPS when available (>=5 samples)
- Fall back to existing pipeline FPS calculation otherwise (for t2v mode or during warm-up)

## Tested
- [x] no regression with Wan VAE

Signed-off-by: RyanOnTheInside <7623207+ryanontheinside@users.noreply.github.com>
Signed-off-by: RyanOnTheInside <7623207+ryanontheinside@users.noreply.github.com>
@ryanontheinside ryanontheinside mentioned this pull request Dec 5, 2025
…t, pipeline) for output rate

Signed-off-by: RyanOnTheInside <7623207+ryanontheinside@users.noreply.github.com>
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.

2 participants