Home > Enterprise >  How to convert a GIF file to a video file and save it to disk in c#?
How to convert a GIF file to a video file and save it to disk in c#?

Time:07-13

I am making an app in Unity on Windows 10. I want to convert a .gif file to a .mp4 file. But the problem is, I have NO clue how to do that, I searched online and I found this solution, but I have no idea how to do that. Also, I tried to search how to get the frames of a GIF file and it gave a solution for Windows Form application Not what I want to do! Also I have another problem: I am unable to use Bitmap in unity for some reason. I downloaded the code from this website, but I got multiple errors. My solution to those errors:

  1. I downloaded System.Drawing.Common from NuGet, but I still got the same errors.
  2. I even referenced System.Drawing to my project from Assemblies. None of them worked for me. Expected Answer for this question is(Any one):
  3. How to use the following in unity:
import moviepy.editor as mp
clip = mp.VideoFileClip("mygif.gif")
clip.write_videofile("myvideo.mp4")
  1. How to Convert .gif to .mp4 and save it to disk in c#.

CodePudding user response:

https://ffmpeg.org/

ffmpeg -f gif -i infile.gif outfile.mp4

Within unity you can use .net Process class to launch the conversion.

  • Related