C# decode, edit and encode frames in an AVI file

128 views Asked by At

I am developing a C# App to edit my AVI file. I want to decode, modify and encode it. This is the process I would like:

  1. load each frame from my AVI file into a temporary bitmap in memory.
  2. modify the bitmap. (This is not a simple edit).
  3. write the bitmap into the same file or another file.
  4. destroy the bitmap.
  5. repeat for all frames Is there a nice and simple way to do this?

I have tried "A-Simple-C-Wrapper-for-the-AviFile-Library" but could not get it to compile.

And: kaitai'w work but I think it is old and cannot parse new AVI files.

My favorite would be AForgeNet but I have tried various things with no luck. This is my very simple code:

using AForge.Video.VFW;

namespace Aforge1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnTest1_Click(object sender, EventArgs e)
        {
            AVIReader reader = new AVIReader();
            reader.Open("C:\\CSharp\\testBasics\\test2.avi");   //error occurs here
            reader.Close();
        }
    }
}

Previously it threw this error on the reader.Open() command:

AForge.Video.VideoException:'Failed initializing decompressor.'

But I think I've broken something else and now I get this error:

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

I know my AVI file exists. I have added all references to the AForge DLLs. Please help me use AForgeNet (or something better).

0

There are 0 answers