Is there any way to get WebCamTexture to get images at 240fps on Android? I am trying to get the slow-motion camera feed being pulled in to my game, but I have only been able to get at most 30FPS from the camera (not even 60).
Here is my super quick script I have used to attempt to get it working. It is showing that the WebCamTexture is updating at around 30fps, and the game is running at 60fps.
using UnityEngine;
using UnityEngine.UI;
public class WebcamTest : MonoBehaviour
{
public RawImage m_RawImage;
public TMPro.TMP_Text m_Text;
private WebCamTexture m_WebCamTexture;
private int m_NumCamUpdates;
private int m_NumFrames;
// Start is called before the first frame update
void Start()
{
Application.targetFrameRate = 240;
m_WebCamTexture = new WebCamTexture();
m_WebCamTexture.requestedWidth = 1920;
m_WebCamTexture.requestedHeight = 1080;
m_WebCamTexture.requestedFPS = 240;
m_WebCamTexture.Play();
m_RawImage.texture = m_WebCamTexture;
InvokeRepeating("TestCamFrameRate", 1f, 1f);
}
void TestCamFrameRate()
{
string _Debug = "Num frames processed this second: [" + m_NumCamUpdates + "] from frames [" + m_NumFrames + "] at [" + m_WebCamTexture.width + " x " + m_WebCamTexture.height + "]";
m_Text.text = _Debug;
Debug.LogError(_Debug);
m_NumCamUpdates = 0;
m_NumFrames = 0;
}
// Update is called once per frame
void Update()
{
m_NumFrames++;
if(m_WebCamTexture.didUpdateThisFrame)
{
m_NumCamUpdates++;
}
}
}
Is there something I can do to get the WebCamTexture to run higher than 30fps, ideally up at 240fps? I have tested this running on Galaxy S6, S8 and S20, and they all run at around 30fps, never any higher.