1

Directshow Audio/Video Capture

In VB.Net, I can capture the video from connected device, but unable to recieve any sound, as speakers are connected. I can play movies and mp3s from MediaPlayer. But, confused, why the sound is not coming. Please guide me to set audio filters in the following code. Please help, kindly make relevant changes in the following code...

    Public Function FindCaptureDevice() As IBaseFilter
        Debug.WriteLine("Start the Sub FindCaptureDevice")
        Dim hr As Integer = 0
        Dim classEnum As IEnumMoniker = Nothing
        'Dim classEnum1 As IEnumMoniker = Nothing
        Dim moniker As IMoniker() = New IMoniker(0) {}
        Dim source As Object = Nothing
        Dim devEnum As ICreateDevEnum = CType(New CreateDevEnum, ICreateDevEnum)

        hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, classEnum, 0)
        DsError.ThrowExceptionForHR(hr)
        Marshal.ReleaseComObject(devEnum)

        If classEnum Is Nothing Then
            Throw New ApplicationException("No video capture device was detected.\r\n\r\n" & _
                           "This sample requires a video capture device, such as a USB WebCam,\r\n" & _
                           "to be installed and working properly.  The sample will now close.")
        End If


        If classEnum.Next(moniker.Length, moniker, IntPtr.Zero) = 0 Then
            Dim iid As Guid = GetType(IBaseFilter).GUID
            moniker(0).BindToObject(Nothing, Nothing, iid, source)
        Else
            Throw New ApplicationException("Unable to access video capture device!")
        End If
        Marshal.ReleaseComObject(moniker(0))
        Marshal.ReleaseComObject(classEnum)
        Return CType(source, IBaseFilter)
    End Function
Ravi
  • 297
  • 1
  • 5
  • 19
  • 1
    You don't have a single audio-related line of code here, there is nothing to help with. Start from looking into audio capture samples. – Roman R. Dec 22 '12 at 08:57
  • I tried some .. but, all in vein! – Ravi Dec 22 '12 at 11:10
  • @Ravi where should the sound come from? (for example did you connect the line in from your sound card, or do you use a webcam with build-in microphone)? – wimh Dec 22 '12 at 12:18
  • built-in sound card! I am new to this Directshow thing... So do not know much how to go ahead. even the code here is also from some of online samples.... What I need is to add the audio filter in the fgm. I dont know how to do it! :-( – Ravi Dec 25 '12 at 11:46

0 Answers0