0

ダイレクト ショーを使用して、Web カメラ ストリームを vb.net プログラムにキャプチャしようとしています。動作するサブルーチンの実行は次のとおりです。

Private Sub CaptureVideo()
            Dim hr As Integer = 0
            Dim sourceFilter As IBaseFilter = Nothing
            Try
                GetInterfaces()

                hr = Me.CaptureGraphBuilder.SetFiltergraph(Me.GraphBuilder)
                Debug.WriteLine("Attach the filter graph to the capture graph : " & DsError.GetErrorText(hr))
                DsError.ThrowExceptionForHR(hr)

                sourceFilter = FindCaptureDevice()

                hr = Me.GraphBuilder.AddFilter(sourceFilter, "Video Capture")
                Debug.WriteLine("Add capture filter to our graph : " & DsError.GetErrorText(hr))
                DsError.ThrowExceptionForHR(hr)



                hr = Me.CaptureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, sourceFilter, Nothing, Nothing)
                Debug.WriteLine("Render the preview pin on the video capture filter : " & DsError.GetErrorText(hr))
                DsError.ThrowExceptionForHR(hr)


                Dim pSink As DirectShowLib.IFileSinkFilter = Nothing
                Dim pMux As DirectShowLib.IBaseFilter = Nothing
                hr = Me.CaptureGraphBuilder.SetOutputFileName(DirectShowLib.MediaSubType.Avi, "c:\video\myvid1.avi", pMux, pSink)
                Debug.WriteLine("Set File : " & DirectShowLib.DsError.GetErrorText(hr))
                DirectShowLib.DsError.ThrowExceptionForHR(hr)


                hr = Me.CaptureGraphBuilder.RenderStream(DirectShowLib.PinCategory.Capture, DirectShowLib.MediaType.Video, sourceFilter, Nothing, pMux)
                Debug.WriteLine("Render the capture pin on the video capture filter : " & DirectShowLib.DsError.GetErrorText(hr))
                DirectShowLib.DsError.ThrowExceptionForHR(hr)

                Marshal.ReleaseComObject(sourceFilter)

                SetupVideoWindow()

                rot = New DsROTEntry(Me.GraphBuilder)

                hr = Me.MediaControl.Run()
                Debug.WriteLine("Start previewing video data : " & DsError.GetErrorText(hr))
                DsError.ThrowExceptionForHR(hr)

                Me.CurrentState = PlayState.Running
                Debug.WriteLine("The currentstate : " & Me.CurrentState.ToString)

            Catch ex As Exception
                MessageBox.Show("An unrecoverable error has occurred.With error : " & ex.ToString)
            End Try
        End Sub

ただし、行を変更すると:

hr = Me.CaptureGraphBuilder.SetOutputFileName(DirectShowLib.MediaSubType.Avi, "c:\video\myvid1.avi", pMux, pSink)

hr = Me.CaptureGraphBuilder.SetOutputFileName(DirectShowLib.MediaSubType.Asf, "c:\video\myvid1.wmv", pMux, pSink)

黒い画面とエラーが表示されます。

ここに画像の説明を入力

基本的に、非圧縮 AVI の代わりに wmv で記録しようとしています (DiVX / xvid のようなものでも問題ありません)。

ありがとう

4

1 に答える 1

0

WM ASF Writer使用して接続する前に、構成する必要がありますRenderStream。詳細については、Windowsメディアファイルへのビデオのキャプチャを参照してください。

于 2012-04-16T10:24:37.583 に答える