DirectShow.Net contains sample project DxPlay which plays video without audio. I need to modify this project to make it play audio. I have read I need to add an audio filter and connect to pin but I didn't find a way to do it.
Here is the code from the sample that sets filters up:
// Add the filters necessary to render the file. This function will
// work with a number of different file types.
IBaseFilter sourceFilter = null;
hr = m_FilterGraph.AddSourceFilter(FileName, FileName, out sourceFilter);
DsError.ThrowExceptionForHR(hr);
// Get the SampleGrabber interface
m_sampGrabber = (ISampleGrabber)new SampleGrabber();
IBaseFilter baseGrabFlt = (IBaseFilter)m_sampGrabber;
// Configure the Sample Grabber
ConfigureSampleGrabber(m_sampGrabber);
// Add it to the filter
hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
// Connect the pieces together, use the default renderer
hr = icgb2.RenderStream(null, null, sourceFilter, baseGrabFlt, null);
DsError.ThrowExceptionForHR(hr);
Could you please hint me how I can make it play audio?
If your video is rendered and audio is not, then additional
icgb2.RenderStream(null, MediaType.Audio, sourceFilter, null, null)
will render the audio part.
Just add
icgb2.RenderStream(null, null, lavSplitter, null, null);
If there are both video and audio then after building the video part there is still an audio output pin in the splitter. RenderStream will find it and render, inserting audio decoder and renderer automatically.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.