Click here to Skip to main content
13,042,630 members (73,744 online)
Rate this:
Please Sign up or sign in to vote.
Hello I have successfully managed to push video to the ASFWriter Sink; I am able to view the video on other computers in my network using Windows Media Player Open Url.

As this is great, because it has taken a month to just get this far, but I am still attempting to receive the video feed from inside a windows form and ultimately from an ASPX web page.

Below is the code I am using to receive the video on the client side:

Dim vDecoderGuid As New Guid("82d353df-90bd-4382-8bc2-3f6192b76e34")
' WMVideo DMO
Dim vRendererGuid As New Guid("B87BEB7B-8D29-423F-AE4D-6582C10175AC")
Dim aDecoderGuid As New Guid("2EEB4ADF-4578-4D10-BCA7-BB955F56320A")
' WMAudio DMO
Dim aRendererGuid As New Guid("79376820-07D0-11CF-A24D-0020AFD79767")
Dim vdecoderDMOWrapper As IDMOWrapperFilter = DirectCast(New DMOWrapperFilter(), IDMOWrapperFilter)
vdecoderDMOWrapper.Init(vDecoderGuid, DirectShowLib.DMO.DMOCategory.VideoDecoder)
vdecoder = DirectCast(vdecoderDMOWrapper, IBaseFilter)
GraphBuilder.AddFilter(vdecoder, "WMV DMO Decoder")
vrender = New VideoMixingRenderer()
GraphBuilder.AddFilter(TryCast(vrender, IBaseFilter), "Video Renderer")
monitorConfig = DirectCast(vrender, IVMRMonitorConfig)
If useAudio Then
Dim adecoderDMOWrapper As IDMOWrapperFilter = DirectCast(New DMOWrapperFilter(), IDMOWrapperFilter)
adecoderDMOWrapper.Init(aDecoderGuid, DirectShowLib.DMO.DMOCategory.AudioDecoder)
adecoder = DirectCast(adecoderDMOWrapper, IBaseFilter)
GraphBuilder.AddFilter(adecoder, "WMV DMO Decoder")
arender = AddFilterFromClsid(GraphBuilder, aRendererGuid, "arenderer")
pinADecoderIn = DsFindPin.ByName(adecoder, "in0")
pinADecoderOut = DsFindPin.ByName(adecoder, "out0")
pinARenderIn = DsFindPin.ByName(arender, "Audio Input pin (rendered)")
End If
pinVDecoderIn = DsFindPin.ByName(vdecoder, "in0")
pinVDecoderOut = DsFindPin.ByName(vdecoder, "out0")
pinVRenderIn = DsFindPin.ByName(TryCast(vrender, IBaseFilter), "VMR Input0")
     DirectCast(readerObject, IFileSourceFilter).Load(filename, Nothing)
     reader = DirectCast(readerObject, IBaseFilter)
     GraphBuilder.AddFilter(reader, "Reader")
     pinreaderVOut = DsFindPin.ByName(reader, "Raw Video 1")
     If pinreaderVOut Is Nothing Then
          pinreaderVOut = DsFindPin.ByName(reader, "Raw Video 0")
     End If

     If useAudio Then
     pinReaderAOut = DsFindPin.ByName(reader, "Raw Audio 0")
          If pinReaderAOut Is Nothing Then
               pinReaderAOut = DsFindPin.ByName(reader, "Raw Audio 1")
          End If
     End If
     hr = GraphBuilder.ConnectDirect(pinreaderVOut, pinVDecoderIn, Nothing)
     hr = GraphBuilder.ConnectDirect(pinVDecoderOut, pinVRenderIn, Nothing)
     If useAudio Then
          If pinReaderAOut IsNot Nothing Then
          hr = GraphBuilder.ConnectDirect(pinReaderAOut, pinADecoderIn, Nothing)
          hr = GraphBuilder.ConnectDirect(pinADecoderOut, pinARenderIn, Nothing)
          End If
     End If
rot = New DsROTEntry(Me.GraphBuilder)
hr = Me.MediaControl.Run()

This seems to work when I use small WMV files (larger files 300 meg for 7 minutes of video time opposed to 28 meg for 7 minutes). The small sized files work most of the time. When it doesn't work, it simply displays a single picture of a frame of the video (with no errors) - this also happens with the larger files (just a picture of one of the frames).

Could the issue be that I need to buffer the video stream before I play it? If so, where would I start?

Posted 9-Nov-12 14:05pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100