Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Lars_Hulsmans · Aug 29, 2018 at 11:30 AM · imagevideopngencodingencode

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by KartikNK · Dec 15, 2018 at 04:51 PM

@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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Shashank4412 · Jan 06, 2020 at 07:36 AM 1
Share
 Texture2D newTexure = new Texture2D(240, 400, TextureFormat.RGBA32, false); //width:240, height:400
 
 newTexure.SetPixels(oldTexture.GetPixels());
 
 newTexure.Apply();

Thanks @$$anonymous$$artikN$$anonymous$$ it works

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

93 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Image resize and save 0 Answers

Optimizing VideoClip for Linux 0 Answers

On Pointer Enter for semi-transparent UI? 2 Answers

Saving a Texture2D as a PNG 3 Answers

Animated GIF and Audio Instead of Video? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges