Reputation: 139
I have developed a Visual Studio Winapp that produces a video file utilizing Accord.Video.FFMPEG.DLL.
The quality the video is less than the original images. Here is the code and then a sample original image and snapshot of the resulting video.
What can I change to improve the video image?
VideoFileWriter writer = new VideoFileWriter();
writer.Open(outfile, width, height, 1, VideoCodec.Mpeg4);
for (int i = firstrow; i <= testframes; i++)
{
Bitmap bitmap = new Bitmap(ffiles[i, 0].ToString());
writer.WriteVideoFrame(bitmap);
bitmap.Dispose();
}
I tried Bitmap image = new Bitmap(width, height, PixelFormat.Format64bppArgb);
Upvotes: 0
Views: 674
Reputation: 1
Use videocodec.H264 in the open function it will give better output.
Upvotes: 0
Reputation: 32124
I tried multiple configurations, and it looks like using VP9 codec and WebM file gives the best quality.
We may also set the bitRate argument to high value.
Code sample:
using Accord.Video.FFMPEG;
using Accord.Math;
using System.Drawing;
namespace Testings
{
public class Program
{
static void Main(string[] args)
{
Bitmap tmp_bitmap = new Bitmap(@"Image640x480.png");
int width = tmp_bitmap.Width; //640
int height = tmp_bitmap.Height; //480
tmp_bitmap.Dispose();
VideoFileWriter writer = new VideoFileWriter();
//writer.Open(@"outfile.mp4", width, height, new Rational(1, 1), VideoCodec.H264);
writer.Open(@"outfile.webm", width, height, new Rational(1, 1), VideoCodec.VP9, 50000000);
for (int i = 0; i < 10; i++)
{
Bitmap bitmap = new Bitmap(@"Image640x480.png"); //For the example, I used the same image.
writer.WriteVideoFrame(bitmap);
bitmap.Dispose();
}
writer.Close();
}
}
}
Note:
The output colors doesn't seem accurate, and there are multiple options that doesn't work.
Instead of using Accord, I recommend using FFmpeg CLI, or looking for a better package.
Upvotes: 0