sunny days
sunny days

Reputation: 847

How to create mp4 video using Aforge.Net AviWriter

I'm using Aforge.net library to capture video from Webcam and create .avi files using XVID.

Code snippet that I'm using (this is not the full code) -

writer = new AVIWriter("XVID");

public void StartCapture()
{
            videoSource.Start();
            writer.FrameRate = 30;
            writer.Open(videoFilename, frameWidth, frameHeight);
}

public void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
            writer.AddFrame((Bitmap)eventArgs.Frame);
}

public void EndCapture()
{
            if (!(videoSource == null))
            {
                if (videoSource.IsRunning)
                {
                    videoSource.SignalToStop();
                    videoSource = null;
                    writer.Close();
                }
            }

}

My next requirement is to show this video in a embedded player on browser. After googl-ing I found that only DivX web player can play avi files from browser. However I would like to use HTML5 video tag to play the video so that my video plays in all browsers and I don't have to install separate plugins for each IE, Firefox, Safari etc.

It would be great help if someone can give pointers on how to create mp4 video file using Aforge.net or any windows commandline tool that would convert my avi file into mp4.

Upvotes: 2

Views: 5351

Answers (1)

Jaex
Jaex

Reputation: 4304

I'm using AVIWriter too with x264 to create AVI video then using ffmpeg CLI to convert video container to MP4.

You can install ffmpeg CLI from here: http://www.ffmpeg.org/download.html

And use this command: "-i %input -c:v copy %output"

Replace %input with your AVI file path and %output with result file path with MP4 extension.

Upvotes: 1

Related Questions