video media encoder addframe texture format 5 expected to be 4

hello, im trying to load in a bunch of png images and make a video of them but when i try to add the frame to the encoder i get this error: VideoMediaEncoder::AddFrame texture format 5 expected to be 4.

this is the code i use to load in and add the pictures to the encoder:

IEnumerator EncodeImages()
{
    VideoTrackAttributes videoAttr = new VideoTrackAttributes
    {
        frameRate = new MediaRational(30),
        width = (uint)equirect.width,
        height = (uint)equirect.height,
        includeAlpha = false
    };

    Texture2D tex = new Texture2D(equirect.width, equirect.height, TextureFormat.RGB24, false);
    index = 0;
    using (MediaEncoder encoder = new MediaEncoder("C:/Users/Lars/Desktop/Images/ " + "my_movie.mp4", videoAttr, null))
    {
        while(index < amountOfFrames)
        {
            yield return StartCoroutine(LoadPNG("C:/Users/Lars/Desktop/Images/ " + "photo " + index.ToString() + ".png"));
            encoder.AddFrame(loadedTex);
            index++;
        }
        UnityEditor.EditorApplication.isPlaying = false;
        yield return null;
    }
}


IEnumerator LoadPNG(string filePath)
    {
        loadedTex = new Texture2D(equirect.width, equirect.height);
        byte[] fileData;

        if (File.Exists(filePath))
        {
            fileData = File.ReadAllBytes(filePath);
            //tex = new Texture2D(2, 2);
            yield return loadedTex.LoadImage(fileData);
        }
        else
        {
            Debug.LogError("file at: " + filePath + "doesn't exist");
        }
        yield return null;
    }

i really hope someone can help me, i’ve been stuck at this for 2 days now.

@thecoon14 , I was also facing that issue, this post helped me…

AFAIK that error occurs when we pass a texture with unsupported format to AddFrame method.

So, creating a new texture with RGB24 format and setting pixels of loadedTex to it, worked for me. At last I’ve passed this newly created texture to AddFrame method.

This post neatly explains how to change Texture2D format.