C# seeking for a library to help generate video showing text

I want to make a software in C# with this feature:

• There is a multiLine text box where user inputs string with N lines.
• The software outputs a MP4 video lasting N seconds.
• Each second the video has a text displayed according to the user input line.

Is there any library that can help doing this?

The video is generated. With the text at the center, and the background remaining black.

• You are asking for several things at once (too broad). It is also not clear: does the software generate the video, or just play an existing one? Where does the text appear: do you want it embedded in the video, overlayed on the video, ...? Please edit the question. – user416 Oct 22 '19 at 7:21
• @jan The video is generated by the software. With the text at the center, and the background remaining black. I am just questioning if anyone can show a library to do this. – gudako Oct 22 '19 at 11:22
• Is there a difference between this video and something like a powerpoint slide show? I mean will you want audio? If not you might have more luck looking for a slideshow type tool/library. – Michael Armes Oct 22 '19 at 17:15
• okay. doing this really can be East in PowerPoint but what I want is to know the way to generate video by C sharp programmatically and this video is just an example. – gudako Oct 23 '19 at 3:47

There’s a C# demo that does something very similar in the LEADTOOLS Multimedia SDK. (Disclaimer: I am an employee of the vendor of this toolkit).

The SDK has a free evaluation that includes the demo, which you can download here.

After you install the SDK, you can find the demo’s source code in this folder:

Since the demo generates AVI instead of MP4, and writes text on a blue background instead of black, you need to modify 6 lines of code in 4 functions to make it match your stated requirements. Below are all the changes needed:

//original code: _tbFile.Text = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\count.avi";
_tbFile.Text = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\text.mp4";


In _btnGenerate_Click()

//original code: double AvgTimePerFrame = (10000000 / 15);
double fps = 1.0; //1 frame per second
double AvgTimePerFrame = (10000000 / fps);
...
//original code: convertCtrl.VideoCompressors.MCmpMJpeg.Selected = true;
convertCtrl.TargetFormat = TargetFormatType.ISO;
convertCtrl.VideoCompressors.H264.Selected = true;
...
//original code: DrawCenteredText(i.ToString());
string s = "This is string number " + i.ToString();
DrawCenteredText(s);


In FillImage()

//original code: _blueBrush = new SolidBrush(Color.Blue);
_blueBrush = new SolidBrush(Color.Black);


In DrawCenteredText()

//original code:  using(Font f = new Font("Arial", 100))
//font was large since text was only a number
//make font smaller to fit larger text
using (Font f = new Font("Arial", 12))


The toolkit has free technical support during evaluation, so if you face problems getting the code to work, you can email the details to our support team.