gpt4 book ai didi

c# - 使用DirectSound设置不同的音频输出

转载 作者:行者123 更新时间:2023-12-03 01:58:39 24 4
gpt4 key购买 nike

我有个问题。对于捕获视频,我可以选择其他摄像头和麦克风,everythig很好,但是对于回放视频,我需要设置输出音频,但我不知道该怎么做。

我的代码看起来像这样:

IFilterGraph2 _previewGraph;
IFilterGraph2 _captureGraph;
IBaseFilter _advancedSystemFormatFileWriter;
IFileSinkFilter _filewriterSink;
ICaptureGraphBuilder2 _captureGraphBuilder;
_captureGraph = (IFilterGraph2)new FilterGraph();
_captureGraphBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
var hResult = _captureGraphBuilder.SetFiltergraph(_captureGraph);
Marshal.ThrowExceptionForHR(hResult);
stage++;
CaptureMediaControl = _captureGraph as IMediaControl;
_advancedSystemFormatFileWriter = (IBaseFilter)new WMAsfWriter();
hResult = _captureGraph.AddFilter(_advancedSystemFormatFileWriter, "WM ASF File Writer");
Marshal.ThrowExceptionForHR(hResult);
stage++;
_filewriterSink = _advancedSystemFormatFileWriter as IFileSinkFilter;
hResult = _filewriterSink.SetFileName(captureFilename, null);
Marshal.ThrowExceptionForHR(hResult);
stage++;
hResult = BridgeController.InsertSourceFilter(_previewSinkFilter, _captureGraph, out _captureSourceFilter);
Marshal.ThrowExceptionForHR(hResult);
stage++;
hResult = _captureGraph.AddFilter(_speakerCaptureFilter, "Audio Renderer");
Marshal.ThrowExceptionForHR(hResult);
//connect bridge output to file writer inputs
hResult = _captureGraph.Connect(
DsFindPin.ByDirection(_captureSourceFilter, PinDirection.Output, 0),
DsFindPin.ByName(_advancedSystemFormatFileWriter, "Video Input 01"));
Marshal.ThrowExceptionForHR(hResult);
stage++;
hResult = _captureGraph.Connect(
DsFindPin.ByDirection(_captureSourceFilter, PinDirection.Output, 1),
DsFindPin.ByName(_advancedSystemFormatFileWriter, "Audio Input 01"));
Marshal.ThrowExceptionForHR(hResult);

我可以在哪里以及如何放置有关发言人的信息?

最佳答案

代码段不完整。表示音频输出的变量是speakerCaptureFilter。您不显示其初始化。您可以为所需的特定设备创建/初始化音频渲染过滤器,并且播放的音频将被路由到相应的设备。

关于c# - 使用DirectSound设置不同的音频输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33561478/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com