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

[Question] How to increase FPS when recording with CaptureFromCamera offline? #442

Closed
cihadturhan opened this issue Dec 5, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@cihadturhan
Copy link

cihadturhan commented Dec 5, 2024

AVPro Movie Capture Version

5.3.2-MOBILE

Which platform is your question for?

iOS, Android

Your question

As far as I understand from the code, when I use CaptureFromCamera and make it offline, a camera renders to two things

  • Screen (which is the render you're seeing)
  • A render texture for video recording

So, doing two works per frame slows down by half.
Is there a way to disable the default render and show the render texture created by CaptureFromCamera? I assume this will speed up rendering by almost 2x?

@cihadturhan cihadturhan added the question Further information is requested label Dec 5, 2024
@cihadturhan
Copy link
Author

So, my workaround is to create a Render Texture and use CaptureFromTexture component.
This way, AVProMovieCapture only uses rendertexture without the need of bliting or else. So it's faster.
I had to make some functions public, but it does the job.

        RenderTextureFormat textureFormat = Utils.GetBestRenderTextureFormat(false, false, false);
        int aaLevel = capture.GetCameraAntiAliasingLevel(Camera.main);
        var renderTexture =
            RenderTexture.GetTemporary(res.x, res.y, 24, textureFormat, RenderTextureReadWrite.Default, aaLevel);
        renderTexture.name = "[AVProMovieCapture] Camera Target";
        renderTexture.Create();
        Camera.main.targetTexture = renderTexture;
        WorldRuntimeRefs.I.renderTexture = renderTexture;
        WorldRuntimeRefs.I.renderPreviewContainer.SetActive(true);
        
        capture.SetSourceTexture(renderTexture);
        capture.FrameRate = 60;
        capture.IsRealTime = false;
        capture.AllowOfflineVSyncDisable = true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants