Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

WebCamtexture low frame rate bug

Discussion in 'General Graphics' started by eco_bach, Mar 22, 2019.

  1. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Hi

    Having a huge problem using the WebCamtexture Class trying to get decent video playback.

    The problem is the I use just the default constructor

    Code (CSharp):
    1.   myWebcamtexture = new WebCamtexture();
    performance is great!

    However, I at the the very least need to supply the first argument, defining the webcam I want to use
    ie

    Code (CSharp):
    1. myWebcamtexture = new WebCamtexture(devices[0]);
    When I do this, I get the desired webcam but the performance is NOT acceptable, as video frame rate drops to about 5 fps and there is huge latency.

    Anyone have a solution?
     
    Last edited: Mar 22, 2019
  2. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
  3. JonasMumm

    JonasMumm

    Joined:
    Feb 22, 2019
    Posts:
    23
    Hi there, I'm fighting exactly the same issue. Did you find a solution?
     
  4. corbinyo

    corbinyo

    Joined:
    Aug 23, 2017
    Posts:
    25
    I was having huge issues with webcam texture, reverted my project to 2017.1.5 and it worked perfectly...
     
  5. jeffcrouse

    jeffcrouse

    Joined:
    Apr 30, 2010
    Posts:
    16
    I'm also having this issue in 2019.2.2f1. Has anyone found a solution?
     
  6. Nico20003

    Nico20003

    Joined:
    Apr 4, 2014
    Posts:
    31
    Same issue here : (
    Any soulution yet?
     
  7. opexu1986

    opexu1986

    Joined:
    Oct 26, 2018
    Posts:
    1
    Same issue(( (Four days i try to rewrite my code) I have Logitech C920 at desktop and USB 2.0 UVC HD at notebook. At notebook default constructor works great, at desktop - very slow.
     
  8. DVD93

    DVD93

    Joined:
    Mar 20, 2014
    Posts:
    1
    You probably fixed it already, but if not try use:
    Code (CSharp):
    1. myWebcamtexture.requestedFPS = 60;
     
  9. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    641
    Try setting a low resolution:

    Code (CSharp):
    1. myWebcamTexture = new WebCamTexture(devices[0], 320, 240, 30);
    Don't know why, but some of my students with Macs get frame rates of 1 fps (yes, one), by taking the default settings when using the nullary constructor.
     
    aaron-beauchamp likes this.
  10. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,879
    Also seen this issue - can Unity not set the webcams to use a reasonable frame rate by default (i.e. 24-30 fps)?
    Because it just looks like a bug when some devices show terrible stuttering cam views by default.
    You can not even read the default fps can you?
     
  11. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    641
    I am unaware of any Unity support for doing this. You might try a native call, but that would be Platform Specific, which we don't like, of course.

    Using a constructor with explicit parameters avoids the problem on Macs, at least to the extent that it is caused by some Macs trying to use insanely high resolutions when you use the nullary constructor. Providing a LOT of light to the scene viewed by the camera helps too.
     
  12. epyrix

    epyrix

    Joined:
    Mar 14, 2021
    Posts:
    1
    I had a similar issue, but only when using the webcam inside of unity. Once I built the project, it would interface fine with the webcam. So, it's not so helpful if you're helpful if you're having this issue on a fully built project. Once I turned on Vsync for the Game tab in the display, the webcam responded as expected (Logitech C922 I believe, it's been a while). I hope that helps out somebody in this thread. This is in Unity 2020.3.26f1.
     
    Stevens-R-Miller likes this.
unityunity