Cuperino / QPrompt-Teleprompter

Teleprompter software for all video creators. Built with ease of use, productivity, control accuracy, and smooth performance in mind.
https://qprompt.app
GNU General Public License v3.0
361 stars 24 forks source link

Improve projection rendering processing speed #42

Closed Cuperino closed 1 year ago

Cuperino commented 2 years ago

Help wanted

QPrompt's UI is written in QML, which renders contents on screen in a very optimal way by moving through a graph of items to be layered together in compositing. Qt allows developers to take one of these layers, treat them as a texture and show them elsewhere in the graph. Unfortunately, Qt breaks apart when attempting to send the texture from one window to another. For this reason, QPrompt captures the layer every frame using the CPU and transfers it to other windows for screen projections, resulting in low performance of mirror instances on low end CPUs and high resolution source windows.

If you're an experienced Qt developer or you feel up to the challenge of decoupling Qt 2D from the root window, this is an area of QPrompt that could benefit from your help.

Cuperino commented 2 years ago

Videosmith writes at #34:

This approach of using both hdmi ports appears to affect the smoothness of animation, which did not exist in Imaginary on my RPi4 since only the external animated.

This happens because QPrompt's approach to copy every frame is much more expensive than Imaginary Teleprompter's, which is to keep two individual prompter instances in sync.

The disadvantage with Imaginary Teleprompter's approach is synchronization off by several pixels and jitter occurs with every re-sync, which happens once every 5 velocity changes. The faster text is scrolling, the more noticeable the jitter is. This jitter is also impossible to avoid, even if you use a super fast computer.

QPrompt's approach to copy frames means the image will not lag more than a frame behind the original. Unfortunately, due to limitations with the Qt framework, this process happens at the CPU level, and cannot yet be moved to the GPU. Since image processing time grows exponentially with screen resolution, this can be especially hard on low end hardware, causing frame rate variation.

As the Qt framework evolves, I keep looking for new ways to copy the frame from one window to the next without having it leave the GPU. It might take a few years before a different implementation is doable. After all, Imaginary Teleprompter's compromised sync took over a year to develop, and QPrompt's approach took several months to achieve.

What I've thought about doing is enable the user to manually force a frame rate. Using a lower but consistent frame rate would result in easier to read text, which could help low end devices.

If I provide a separate window for prompting, the separate window would animate in all its fluidity. Only the screen duplicates and countdown animations are expensive to process.

Cuperino commented 1 year ago

WIP: https://www.youtube.com/watch?v=90GiETmCYdU

Cuperino commented 1 year ago

Done on 0fed55bcd238aa698d4bb0af1006d195101d7bef.

Cuperino commented 1 year ago

Re-opening. Solution only works on MacOS. On Windows and Linux, Qt prevents the texture from being accessed, returning a null pointer and the following error: QQuickShaderEffectSource::textureProvider: can only be queried on the rendering thread of an exposed window.