1

Directshow 音频/视频捕获

VB.Net中,我可以从连接的设备捕获视频,但无法接收任何声音,因为连接了扬声器。我可以从 MediaPlayer 播放电影和 mp3。但是,困惑,为什么声音不来。请指导我在以下代码中设置音频过滤器。请帮助,请在以下代码中进行相关更改...

    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
4

0 回答 0