AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

How can I record audio along with Aforge player video record

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

How can I record audio along with Aforge player video record

Postby DSZ » Tue Jun 04, 2019 7:04 am

My app is playing webcam video using Aforge Plyer. Now I want to record this video. Know that using Aforge player audio recording is not possible.
Is there any way to record audio separately and merge it with recorded video using Aforge player?
My current code is here. It can record video from selected webcam using aforge player. But audio is missing
Code: Select all
using AForge.Video;
using AForge.Video.DirectShow;
using Accord.Video.FFMPEG;

    private FilterInfoCollection VideoCaptureDevices;
    private VideoCaptureDevice FinalVideo = null;
    private VideoCaptureDeviceForm captureDevice;
    private Bitmap video;
    private VideoFileWriter FileWriter = new VideoFileWriter();
    private SaveFileDialog saveAvi;

    private void VideoRecord_Load(object sender, EventArgs e)
    {
        VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        captureDevice = new VideoCaptureDeviceForm();
    }
    private void play_Click(object sender, EventArgs e)
    {
        if (captureDevice.ShowDialog(this) == DialogResult.OK)
        {
            VideoCaptureDevice videoSource = captureDevice.VideoDevice;
            FinalVideo = captureDevice.VideoDevice;
            FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
            FinalVideo.Start();
        }
    }
    void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        if (butStop.Text == "Stop Record")
        {
            video = (Bitmap)eventArgs.Frame.Clone();
            FileWriter.WriteVideoFrame(video);
        }
        else
        {
            video = (Bitmap)eventArgs.Frame.Clone();;
        }
    }
    private void Record_Click(object sender, EventArgs e)
    {
        saveAvi = new SaveFileDialog();
        saveAvi.Filter = "Avi Files (*.avi)|*.avi";
        if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height;
            int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width;
            FileWriter.Open(saveAvi.FileName, w, h, 25, VideoCodec.Default, 5000000);
            FileWriter.WriteVideoFrame(video);
            butStop.Text = "Stop Record";
        }
    }
    private void stopRecord_Click(object sender, EventArgs e)
    {
        if (butStop.Text == "Stop Record")
        {
            butStop.Text = "Stop";
            if (FinalVideo == null)
            { return; }
            if (FinalVideo.IsRunning)
            {
                FileWriter.Close();
            }
        }
        else
        {
            this.FinalVideo.Stop();
            FileWriter.Close();
        }
    }
}
}
DSZ
 
Posts: 20
Joined: Mon Feb 25, 2019 7:06 am

Re: How can I record audio along with Aforge player video re

Postby andrew.kirillov » Tue Jun 04, 2019 8:08 am

You can not. AForge.NET Framework never had support for audio.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3451
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework

cron