Page 1 of 1

How can I record audio along with Aforge player video record

PostPosted: Tue Jun 04, 2019 7:04 am
by DSZ
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();
        }
    }
}
}

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

PostPosted: Tue Jun 04, 2019 8:08 am
by andrew.kirillov
You can not. AForge.NET Framework never had support for audio.