Audio Video Recording

Toh Ghim
2013-02-14
2013-02-14
  • Toh Ghim

    Toh Ghim - 2013-02-14

    I'm trying to add in audio recorded via microphone to my rendered avi from webcam recording, both via directshow. The video recording and rendering is working, but i can't seem to be able to add the audio in as the hr value is always a negative one, i'm not sure how to connect the audio to the second pin of the mux filter.. can anybody help me please?

       int hr;
            IBaseFilter mux = null;
    
            IFileSinkFilter sink = null;
    
            try
            {
                hr = capturecapGraph.SetFiltergraph(capturegraphBuilder);
                if (hr < 0)
                    Marshal.ThrowExceptionForHR(hr);
    
                hr = capturegraphBuilder.AddFilter(capturecapFilter, "Ds.NET Video Capture Device");
                if (hr < 0)
                    Marshal.ThrowExceptionForHR(hr);
    
                hr = capturegraphBuilder.AddFilter(audioFilter, "Ds.Net Audio Capture Device");
                if (hr < 0)
                    Marshal.ThrowExceptionForHR(hr);    
    
                DsUtils.ShowCapPinDialog(capturecapGraph, capturecapFilter, this.Handle);
    
                Guid sub = MediaSubType.Avi;
                hr = capturecapGraph.SetOutputFileName(ref sub, capturefileName, out mux, out sink);
                if (hr < 0)
                    Marshal.ThrowExceptionForHR(hr);
    
                Guid cat = PinCategory.Capture;
                Guid med = MediaType.Video;
    
                hr = capturecapGraph.RenderStream(ref cat, ref med, capturecapFilter, null, mux); // stream to file 
    
                if (hr < 0)
                    Marshal.ThrowExceptionForHR(hr);
    
                // Audio Capture
                if (capAudioDevices.Count > 0)
                {
                Guid catA = PinCategory.Capture;
                Guid medA = MediaType.Audio;
                IPin test = null;
    
                hr = capturecapGraph.RenderStream(ref catA, ref medA, audioFilter, null, mux);
                if (hr < 0)
                    Marshal.ThrowExceptionForHR(hr);
                }
    
                return true;
            }
            catch (Exception ee)
            {
                MessageBox.Show(this, "Could not setup graph\r\n" + ee.Message, "DirectShow.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return false;
            }
            finally
            {
                if (mux != null)
                    Marshal.ReleaseComObject(mux); mux = null;
                if (sink != null)
                    Marshal.ReleaseComObject(sink); sink = null;
            }
    
     
  • snarfle

    snarfle - 2013-02-14

    You know, if you are going to post questions in this forum, you really should be using the library this forum is supporting. If you are using a "competitor," go ask them for support.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks