Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:45:41+00:00 2026-05-26T08:45:41+00:00

I am completely new to video input, and just started working with AForge a

  • 0

I am completely new to video input, and just started working with AForge a few days ago. Working with live video is comfortable, but I need to do something with files for a project now.

Using the Windows Media Video 9 VCM codec, saving has not been a problem. The output file works normally with every player I have, but my program always plays it back at about double the frame rate. This is especially odd since there is never any indication that the frame rate is changed: both the default the video was saved with and the new player indicate that the frame rate is 25 fps.

The only suggestions I have found are to change the frame rate before the video is captured, but this seems to do nothing.

Looking around in the AVIFileVideoSource documentation, I found the FrameIntervalFromSource and FrameInterval properties which, together, should give me the results I am looking for, but I can’t get them to work, either. Everything else has been a dead end, and I am out of ideas. Here is the code that I am using to read the file:

    public partial class Form1 : Form
{
    AVIReader input = new AVIReader();
    AVIFileVideoSource source = new AVIFileVideoSource("test.avi");

    public Form1()
    {
        InitializeComponent();
    }

    public void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        input.Open("test.avi");
        for (int i = 0; i < input.Length; i++)
        {
            pictureBox1.Image = input.GetNextFrame();
        }
        source.Stop();
        input.Close();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        source.NewFrame += new NewFrameEventHandler(cam_NewFrame);
        source.Start();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        source.Stop();
        input.Close();

    }
}

Any other suggestions would be greatly appreciated. Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:45:42+00:00Added an answer on May 26, 2026 at 8:45 am

    I found a working solution to the problem by looking into some other areas of the library. In this solution, there were two other classes that I was overlooking: DirectShow, which was already referenced, and Control. Specifically, I needed to use instances of FileVideoSource and VideoSourcePlayer to get the video into something I could work with.

    This version is different from the above in that both the read and write functions have been combined into one program. Furthermore, I was in something of a rush to get this done, so it is still quite fragile. Nevertheless, here is my solution:

        public partial class Form1 : Form
    {
        public Bitmap newBitmap;
        public VideoCaptureDevice cam = null;
        public FilterInfoCollection usbCams;
    
        AVIReader reader = new AVIReader();
        AVIWriter writer = new AVIWriter("wmv3");
        AVIFileVideoSource source = new AVIFileVideoSource("test.avi");
    
        FileVideoSource normSource = new FileVideoSource("test.avi");
        VideoSourcePlayer player = new VideoSourcePlayer();
    
        public Form1()
        {
            InitializeComponent();
        }
    
        public void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap image = (Bitmap)eventArgs.Frame.Clone();
            writer.AddFrame(image);
    
            pictureBox1.Image = image;
        }
    
        public void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            newBitmap = (Bitmap)eventArgs.Frame.Clone();
            pictureBox1.Image = newBitmap;
        }
    
        private void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
        {
            videoSourcePlayer1.VideoSource = normSource;
            videoSourcePlayer1.GetCurrentVideoFrame();
    
            videoSourcePlayer1.DrawToBitmap(newBitmap,
                new Rectangle(0, 0, image.Width, image.Height));
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            source.NewFrame += new NewFrameEventHandler(video_NewFrame);
            source.Start();
            videoSourcePlayer1.NewFrame += new AForge.Controls.VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
            videoSourcePlayer1.Start();
        }
    
        private void button2_Click(object sender, EventArgs e)
        {
            if (source.IsRunning == true)
            {
                source.Stop();
                videoSourcePlayer1.Stop();
            }
    
            if (cam != null)
            {
                cam.Stop();
                writer.Close();
            }
        }
    
        private void button3_Click(object sender, EventArgs e)
        {
            usbCams = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            cam = new VideoCaptureDevice(usbCams[0].MonikerString);
            cam.DesiredFrameSize = new Size(320, 240);
    
            writer.Open("test.avi", 320, 240);
    
            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
            cam.DesiredFrameRate = 25;
            cam.Start();
        }
    }
    

    Thank you for reading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im completely new to Flash and ActionScript2 but what I need is to add
I'm completely new to AIR but what I'm trying to do feels like it
I'm completely new to Flex and am just having a play with a sample
Just became an iPhone developer. I'm completely new to this, and not really sure
I'm completely new in Open GL, so have a question. I need to apply
im completely new to SharePoint and C#, but i gotta do what im told
I did this example using the pluralsight video but the date picker is just
Completely new to asp.net mvc... completely new to web apps so bear with me...
I am completely new to ruby and I inherited a ruby system for a
I am completely new to LINQ in C#/.NET. I understand that I could use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.