Search Unity

Video videoplayer flahes red while playing.

Discussion in 'Audio & Video' started by MSachs, Mar 14, 2018.

  1. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    Hi,

    I have a videoplayer which plays a video on a raw image using a render texture. The problem is that when I build the game and the video is playing the screen flashes red for whatever reason. IN the editor everything works fine...

    Did anybody have this problem before and knows a solution?

    thanks :)
     
  2. vettorazi

    vettorazi

    Joined:
    Feb 20, 2018
    Posts:
    2
    same here... did you tried export? sometimes works
     
  3. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    what do you mean by export? Export what to where?
     
  4. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    Anyone got an idea?

    So far I tried multiple VideoClips with .mov and .mp4 files, 1080p and 4k resolution and different sizes/resolutions of the Render Texture and the RawImage. When my game runs at 720p or below it works fine, 1080p rarely but sometimes works correctly and every resolution higher than 1080p doesn't work at all. The videos stutter, during stuttering the whole screen flashes red and sometimes the video seems to be playing at a slower speed than normal...

    Really hope someone has an Idea...
     
  5. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    Same issue here... not sure how to resolve this
     
  6. Joshdbb

    Joshdbb

    Joined:
    Oct 28, 2014
    Posts:
    50
    I also have this issue.
     
  7. jsm2112

    jsm2112

    Joined:
    Nov 30, 2016
    Posts:
    2
    I am having a similar issue. However, it only occurs on my new MBP 2018 and not on my older MBP. Same unity version 2017.3.0f3. If I play in editor or build for macOS, I get the red flashing during video playback.

    Would upgrading to unity 2018 solve this issue?
     
  8. jsm2112

    jsm2112

    Joined:
    Nov 30, 2016
    Posts:
    2
    After messing around, if I disable Metal Editor Support on my MBP 2018 the editor plays the video correctly.

    I hope this helps everyone else.
     
  9. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    If anybody still needs a fix for this: For me it helped to enable VSync in the Quality Settings. For me it limits the game to 30FPS (I think that is half of what my monitor can display) but it gets rid of the red flashes and flickering. If you don't want the 30FPS limit you can just enable VSync via script when the video plays and disable it again when it ended.
    https://docs.unity3d.com/ScriptReference/QualitySettings-vSyncCount.html

    I start my videos using a button so it would be just something like this:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Video;
    5.  
    6. public class MovieController : MonoBehaviour
    7. {
    8.     public VideoPlayer MyVideo;
    9.  
    10.     public void StartMyVideo ()
    11.     {
    12.         MyVideo.gameObject.SetActive (true);
    13.         QualitySettings.vSyncCount = 2;
    14.     }
    15. }
    16.  
    and to stop it something like this

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Video;
    5.  
    6. public class StopVideo : MonoBehaviour
    7. {
    8.     public VideoPlayer MyVideo;
    9.  
    10.     public void StopMyVideo()
    11.     {
    12.         MyVideo.gameObject.SetActive (false);
    13.         QualitySettings.vSyncCount = 0;
    14.     }
    15. }
    16.  
     
  10. markzorn

    markzorn

    Joined:
    Oct 6, 2016
    Posts:
    12
    I am having this problem in 2018.3.10f1. Tried all of the vsync settings, as well as turning off Metal and always get a red flash right as the video plays. Any help would be appreciated!
     
  11. aryanop12

    aryanop12

    Joined:
    Apr 19, 2022
    Posts:
    1
    I got the solution just change your render texture colour format to R16B16G16A16_SFLOAT or anyone which have RGB values because now a days colour have RGB values but render texture is set to R or RG by default.