# Adding text to video frames

I'm currently trying to add text to a video. To do so I've been manipulating each frame by adding text to each bitmap and then rendering a new video.

using (var vFReader = new VideoFileReader())
{

using (var vFWriter = new VideoFileWriter())
{

for (var i = 0; i < vFReader.FrameCount; i++)
{

var graphics = Graphics.FromImage(image);

graphics.SmoothingMode = SmoothingMode.AntiAlias;

//graphics.DrawString("PASSED YOU A MESSAGE", font, Brushes.White, new Point(vFReader.Width / 2, 170), format);

graphics.Flush();

vFWriter.WriteVideoFrame(image);
}
vFWriter.Flush();
}
}


This is running rather slowly, so I was wondering if this is the wrong approach to take?

Or, is there a way to speed up the execution of my current code?

• Though I can see the overlap, I'm not quite convinced CodeReview.SE is the correct place for this question (if I'm wrong, feel free to correct me). – Flater Apr 13 '18 at 11:15
• Please post the complete method and some benchmarks. – t3chb0t Apr 13 '18 at 14:38