Search Unity

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:
    26
    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:
    18
    I'm also having this issue in 2019.2.2f1. Has anyone found a solution?
     
  6. Nico20003

    Nico20003

    Joined:
    Apr 4, 2014
    Posts:
    35
    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:
    676
    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:
    2,269
    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:
    676
    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.
  13. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    I had the same issue with the Logitech C920.
    @1280x 720 resolution the frame rate was very low, @ 1920 x 1080 it was awful.
    Finally I had to revert to my old-good Logitech B525, that is perfect (no jerky at all, @ every resolution).
    So I think it's an issue of this specific webcam
     
  14. rbardet

    rbardet

    Joined:
    May 6, 2017
    Posts:
    1
    I Have the same probem with the Brio 4k at requested 1920x1080 30fps I only get 1 fps
     
  15. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,023
    Based on my tests, indicating "0" value for requested FPS in constructor
    leads to the FPS Value by Default for target camera.

    So, for example, it's 24 FPS for Samsung Galaxy A71.

    I also noticed that performance notably drops when you build with Development Mode (On).
     
    Last edited: Jun 2, 2023
    tribbloid likes this.