Set webcam image format to MJPG
Hi,
I have a webcam (Logitech C930e) that I want to use in a project (this will only run on a dedicated computer, with this exact webcam). I'm having some problems with the FPS. First of all, here's the script I'm running right now:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WebcamHandler : MonoBehaviour {
private WebCamTexture webCamTexture;
public RawImage webcamView;
public int selectedWebcam;
public int requestedWebcamWidth, requestedWebcamHeight,
requestedWebcamFPS;
void Start () {
PrintAvailableWebcams();
SetupWebcam();
}
private void SetupWebcam(){
webCamTexture = new WebCamTexture(WebCamTexture.devices[selectedWebcam].name, requestedWebcamWidth, requestedWebcamHeight, requestedWebcamFPS);
webCamTexture.Play();
webcamView.texture = webCamTexture;
}
private void PrintAvailableWebcams(){
WebCamDevice[] devices = WebCamTexture.devices;
for (int i = 0; i < devices.Length; i++){
Debug.Log("Webcam[" + i + "]: " + devices[i].name);
}
}
}
It works, I get the live image from the webcam, but the FPS is stuck at 5 FPS, no matter what I enter as requested frame rate (even if I enter something lower, like 1 fps).
I downloaded the free version of AVPro Live Camera, just to see what's going on. And I notice that the webcam format is initialized as YUV_YUV2, and when I select a resolution of 1920x1080, the fps is stuck at 5. BUT, when I change the video format to MJPG, I can select an FPS of 30, and everything is running smoothly.
So, my question is, how would I change the format setting of a webcam, using Unity's built-in WebCamTexture? Is it possible? Seems a bit silly to pay the full price of AVPro Live camera (€179) just for this single setting.
Thank you!
I have the exact same issue with the same webcam. Did you manage to find any solutions.
i have the same issue with an Axis IP camera... any progress in this?
Same problem right now with a Logitech C920 Pro. Trying to find a solution.
Your answer
Follow this Question
Related Questions
WebCamTexture nullpointerexception 1 Answer
Priview The Screenshot for User 0 Answers
Webcam on Multiple Objects 2 Answers
Unity webcam trouble 0 Answers
4K - WebCameTexture.Play() Could not connect pins - RenderStream() 0 Answers