how to resolve Accord.Video.FFMPEG error Rational is defined in an assembly that is not referenced

430 Views Asked by At

I have developed a visual studio c# Windows app that I want to use Accord.Video.FFMPEG.DLL to merge JPGs into a video file.

I added the reference to the DLL and the following code: enter image description here

 using Accord.Video.FFMPEG;

private void videoTestBttn_Click(object sender, EventArgs e)
{
    int width = 320;
    int height = 240;
    Bitmap bitmap;

    // create instance of video writer
    VideoFileWriter writer = new VideoFileWriter();
    // create new video file
    writer.Open("c:\\test.avi", width, height, 25, VideoCodec.MPEG4);
    // create a bitmap to save into the video file
    Bitmap image = new Bitmap(width, height, PixelFormat.Format24bppRgb);
    // write 1000 video frames
    for (int i = 0; i < 100; i++)
    {
        image.SetPixel(i % width, i % height, Color.Red);
        bitmap = new Bitmap(ffiles[i, 0].ToString());
        writer.WriteVideoFrame(bitmap);
        bitmap.Dispose();
    }
    writer.Close();

}

I get the following error in the build on the 'writer.Open' line of code:

Error CS0012 The type 'Rational' is defined in an assembly that is not referenced. You must add a reference to assembly 'Accord, Version=3.8.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7'.

Downloaded DLL from https://nuget.info/packages/Accord.Video.FFMPEG/3.8.2-alpha

How and where to I add this reference? Looking forward to some assistance!

1

There are 1 best solutions below

0
HighwayRob On

Cleptus was correct !

You should not download individual DLL's from nuget, but install the packages using Nuget itself. That way you would install their dependencies also. Accord.Video.FFMPEG 3.8.2-alpha has the following dependencies: Accord (>= 3.8.2-alpha) and Accord.Video (>= 3.8.2-alpha) – Cleptus Jan 12 at 23:07