Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Directshow GMFBridge将多个剪辑保存到单个文件_Vb.net_Directshow_Directshow.net - Fatal编程技术网

Vb.net Directshow GMFBridge将多个剪辑保存到单个文件

Vb.net Directshow GMFBridge将多个剪辑保存到单个文件,vb.net,directshow,directshow.net,Vb.net,Directshow,Directshow.net,下面是我在GMFBridge中使用的代码主体。我有一个sg(sourcegraph)和rg(rendergraph)对象,它将filtergraph、mediaseeking等保存在一个地方,以便我可以释放它们 当我运行这个程序时,它会将剪辑完美地渲染到屏幕上。寻找每个剪辑并正确播放。我在“网桥段末端”中获得了我期望的正确的事件代码序列(即,每个剪辑一条BEOS消息) 然而,当我尝试将剪辑写入AVI文件时,我只得到第一个剪辑。我也只收到过一条“桥段结束”的信息。“with rg”部分中注释掉的代

下面是我在GMFBridge中使用的代码主体。我有一个sg(sourcegraph)和rg(rendergraph)对象,它将filtergraph、mediaseeking等保存在一个地方,以便我可以释放它们

当我运行这个程序时,它会将剪辑完美地渲染到屏幕上。寻找每个剪辑并正确播放。我在“网桥段末端”中获得了我期望的正确的事件代码序列(即,每个剪辑一条BEOS消息)

然而,当我尝试将剪辑写入AVI文件时,我只得到第一个剪辑。我也只收到过一条“桥段结束”的信息。“with rg”部分中注释掉的代码是我用来写入AVI文件的代码。如果我检查GraphEdit中的图形,它们是正确连接的

我还在底部添加了“网桥段结束”消息的代码

这让我快发疯了。我一定错过了一些非常简单的东西。谢谢你的帮助

        ' Get the source media file...
        If openfile.ShowDialog = Windows.Forms.DialogResult.OK Then

            If Bridge Is Nothing Then
                Bridge = New GMFBridgeController
                Bridge.AddStream(True, eFormatType.eAny, True)
                'Bridge.AddStream(False, eFormatType.eMuxInputs, False)
                Bridge.SetBufferMinimum(200)
            End If

            With sg
                ' Create graph to use. 
                .graph = New FilterGraph

                ' Create other interfaces. Don't need them all but am 
                ' experimenting. 
                .mediacontrol = DirectCast(.graph, IMediaControl)
                .mediaseeking = DirectCast(sg.graph, IMediaSeeking)
                .mediaeventex = DirectCast(.graph, IMediaEventEx)
                .mediaeventex.SetNotifyWindow(Me.Handle, WM_GRAPHNOTIFY, Nothing)

                ' Create the graphedit entry so I can see what I've made. 
                .rotentry = New DsROTEntry(.graph)

                ' If not using bridge comment out this line. 
                sg.filter = Bridge.CreateSourceGraph(openfile.FileName, sg.graph)
            End With

            With rg
                .graph = DirectCast(New FilterGraph, IFilterGraph2)
                .capgraph = New CaptureGraphBuilder2
                .capgraph.SetFiltergraph(.graph)

                ''''' CODE THAT I USE TO WRITE TO AN AVI FILE
                '''''Dim aviDest As IBaseFilter = New AviDest()
                '''''.graph.AddFilter(aviDest, "AVI Mux")
                '''''Dim writer As IBaseFilter = New FileWriter
                '''''.graph.AddFilter(writer, "File Writer")
                '''''Dim filewriter As IFileSinkFilter2 = DirectCast(writer, IFileSinkFilter2)
                '''''filewriter.SetFileName(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\StatsManager\Videos\momtest.avi", Nothing)

                ' Create the render graph ...
                .filter = Bridge.CreateRenderGraph(sg.filter, .graph)

                ' Ancillary control interfaces...
                .mediaseeking = DirectCast(.graph, IMediaSeeking)
                .mediacontrol = DirectCast(.graph, IMediaControl)

                ' Let me see the graph in GraphEdit.
                .rotentry = New DsROTEntry(.graph)
            End With

            ' Add my list of offsets...
            For Each obj As Object In listOffsets.Items
                clipoffsets.Add(Val(obj.ToString))
            Next

            ' How long to play the clips for...
            clipplaytime = Val(txtClipTime.Text)

            ' Just so I know what video I chose. 
            Me.Text = "Video:" + Path.GetFileName(openfile.FileName)
        End If
这是处理“段结束”消息的代码

Public Sub Bridge_OnEndOfSegment() Handles Bridge.OnEndOfSegment
    Try
        log("BEOS")
        clipindex = clipindex + 1
        If clipindex = clipoffsets.Count Then          ' this is the proper version :)
            log("End of clips")
            clipindex = 0
            If chkLoop.Checked = False Then
                sg.mediacontrol.Stop()
                rg.mediacontrol.Stop()
            Else
                log("....looping")
                SeekToClip(clipoffsets(clipindex))
            End If
        Else
            log("Moving to clip:" + clipoffsets(clipindex).ToString)
            SeekToClip(clipoffsets(clipindex))
        End If

    Catch ex As Exception
        log("ERROR in EOS :" + ex.Message)
    End Try
End Sub

是否所有剪辑的格式都完全相同(包括分辨率、采样率)?是的,它们实际上都是来自同一视频的剪辑,因此没有任何类型的更改。我看不出任何错误,只要看一下您的代码。你想发布更多的代码(例如SeekToClip)还是离线联系我,我会在这里为大家发布一个答案,当我们整理好它的时候?嗨,Geraint,那太好了。我会这样做,希望能把它整理好。很高兴分享代码。