
Делаю программу для захвата видео и звука в файл с тв тюнера поддерживающего аппаратное Mpeg2 сжатие.
Создаю граф
public void InitGraph()
{
//Create the Graph
graphBuilder = (IGraphBuilder) new FilterGraph();
//Create the Capture Graph Builder
ICaptureGraphBuilder2 captureGraphBuilder = null;
captureGraphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
//Create the media control for controlling the graph
mediaControl = (IMediaControl) this.graphBuilder;
// Attach the filter graph to the capture graph
int hr = captureGraphBuilder.SetFiltergraph(this.graphBuilder);
DsError.ThrowExceptionForHR(hr);
//Add the Video input device to the graph
hr = graphBuilder.AddFilter(theDevice, "Video filter");
//DsError.ThrowExceptionForHR(hr);
hr = graphBuilder.AddFilter(theDeviceA, "Audio filter");
//Add the Video compressor filter to the graph
hr = graphBuilder.AddFilter(theCompressor, "Video compressor");
hr = graphBuilder.AddFilter(theCompressorA, "Audio compressor");
DsError.ThrowExceptionForHR(hr);
//Create the file writer part of the graph. SetOutputFileName does this for us, and returns the mux and sink
IBaseFilter mux;
IFileSinkFilter sink;
hr = captureGraphBuilder.SetOutputFileName(MediaSubType.Avi, textBox1.Text, out mux, out sink);
DsError.ThrowExceptionForHR(hr);
//Render any preview pin of the device
hr = captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, theDevice, null, null);
hr = captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Audio, theDevice, null, null);
DsError.ThrowExceptionForHR(hr);
//Connect the device and compressor to the mux to render the capture part of the graph
hr = captureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, theDevice, theCompressor, mux);
hr = captureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Audio, theDeviceA, theCompressor, mux);
//DsError.ThrowExceptionForHR(hr);
#if DEBUG
m_rot = new DsROTEntry(graphBuilder);
#endif
ДАЛЕЕ ВЫВОЖУ ВИДЕО НА ФОРМУ
DsError.ThrowExceptionForHR(hr);
Marshal.ReleaseComObject(mux);
Marshal.ReleaseComObject(sink);
Marshal.ReleaseComObject(captureGraphBuilder);
}
При запуске этого графа отлично показывается видео с тюнера и звук. Но вот в файл записывается только видео.Звука нет.
Пробовал на другой карте видеозахвата (без поддержки аппаратного сжатия) всё нормально записывало и звук и видео, а вот с картой использующей апаратный кодер записывается только видео. Построил граф в GraphEdite всё отлично записывает и звук и видео. Может где-то что-то в коде не так? или В чём может быть проблема?





