Search Unity

Question Can't get Video to appear on Raw Image.

Discussion in 'Audio & Video' started by EOMedvis, Feb 16, 2024.

  1. EOMedvis

    EOMedvis

    Joined:
    Feb 19, 2019
    Posts:
    91
    I'm using the Unity Video Player to play a video on a canvas. I believe I set up everything correctly, but the video visuals don't appear on the Raw Image I'm using to render, but the audio plays just fine.

    Here's my setup:
    1) Made a Render Texture. Set the dimensions.
    upload_2024-2-16_15-27-32.png

    2) Create a "Raw Image" object under my canvas. Add the render texture into the texture slot:
    upload_2024-2-16_15-29-34.png

    3) Make a empty game object with a Video Player component. Add the render texture to its texture slot:
    upload_2024-2-16_15-31-13.png

    4) I have a simple script that has a list of videos in an array. I assigned a video clip to the VideoPlayer, and the instructed it to play:

    Code (CSharp):
    1. public class VideoController : MonoBehaviour
    2. {
    3.     [SerializeField] private VideoPlayer mainVideo;
    4.     [SerializeField] private VideoClip[] videos;
    5.  
    6.     private double[] vidLengths;
    7.  
    8.     public double[] Video_Lengths
    9.     {
    10.         get { return vidLengths; }
    11.     }
    12.  
    13.     private void Start()
    14.     {
    15.         vidLengths = new double[] { videos[0].length, videos[1].length, videos[2].length, videos[3].length };
    16.     }
    17.  
    18.     public void PlayMain()
    19.     {
    20.         mainVideo.clip = videos[0];
    21.         mainVideo.Play();      
    22.     }
    23.  
    24.     public void StopMain()
    25.     {
    26.         mainVideo.Stop();
    27.     }
    28. }
    The video plays, but I only get the audio. I see the Render Texture and the VideoImage, but nothing appears on the actual screen.

    upload_2024-2-16_15-33-42.png

    Am I doing something wrong?

    Thanks in advance.
     
  2. EOMedvis

    EOMedvis

    Joined:
    Feb 19, 2019
    Posts:
    91
    anyone?

    I am getting this warning when I play the vid:

    Color primaries 0 is unknown or unsupported by WindowsMediaFoundation. Falling back to default may result in color shift.

    Not sure if it has anything to do with the issue.
     
    Last edited: Feb 18, 2024
  3. EOMedvis

    EOMedvis

    Joined:
    Feb 19, 2019
    Posts:
    91
    Problem fixed using Custom Render Texture instead of the normal one. Not sure what the difference was.