0

我想录制麦克风和系统声音
(Youtube 音乐、Media Player 电影声音、键盘类型警告声音...等),
以便通过 Flash Player 将其发布到服务器。

我在 GitHub 上找到了DirectShow示例:virtual-audio-capture-grabber-device
我成功注册了它的 DLL。
该样本的过滤器名称为“ virtual-audio-capturer ”。

C:\Users\user\Desktop\virtual-audio-capture-grabber-device-master\virtual-aud
io-capture-grabber-device-master\source_code\Release>regsvr32 audio_sniffer.dll

我使用Audio Capture Source
WavDest FilterFile Writer Filter的 virtual-audio-capturer 过滤器通过GraphEdt .exe将音频录制到WAVE文件中。该图是可行的。结果文件是正确的。

Flash Player 的麦克风列表中有麦克风(VIA High Definition Audio)和 Stereo Mix(VIA High Definition Audio),但没有 virtual-audio-capture-grabber-device。结果与Action Script 3项目相同。但我可以在Adob​​e Flash Media Live Encoder 3.2上看到虚拟音频捕获抓取设备。( http://img.bbs.csdn.net/upload/201311/12/1384239370_718116.png )

var deviceArray:Array = Microphone.names;

trace("Available sound input devices:"); 
for (var i:int = 0; i < deviceArray.length; i++) { 
    trace(" " + deviceArray[i]); 
} 


虚拟音频捕获器滤波器只有一个输出引脚,没有输入引脚。

    const AMOVIESETUP_MEDIATYPE AMSMediaTypesVCam = 
    {     &MEDIATYPE_Audio,      // clsMajorType
          &MEDIASUBTYPE_NULL     // clsMinorType
    }; 


安装程序.cpp

#define CreateComObject(clsid, iid, var) CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER, iid, (void **)&var);

STDAPI AMovieSetupRegisterServer( CLSID   clsServer, LPCWSTR szDescription, LPCWSTR szFileName, LPCWSTR szThreadingModel = L"Both", LPCWSTR szServerType     = L"InprocServer32" );
STDAPI AMovieSetupUnregisterServer( CLSID clsServer );

#ifdef _WIN64
DEFINE_GUID(CLSID_VirtualCam,
        0x8e146464, 0xdb61, 0x4309, 0xaf, 0xa1, 0x35, 0x78, 0xe9, 0x27, 0xe9, 0x35);
#else
DEFINE_GUID(CLSID_VirtualCam,
        0x8e14549b, 0xdb61, 0x4309, 0xaf, 0xa1, 0x35, 0x78, 0xe9, 0x27, 0xe9, 0x35);
#endif

const AMOVIESETUP_MEDIATYPE AMSMediaTypesVCam = { &MEDIATYPE_Audio, &MEDIASUBTYPE_NULL }; 

const AMOVIESETUP_PIN AMSPinVCam = {
L"Output",             // Pin string name
FALSE,                 // Is it rendered
TRUE,                  // Is it an output
FALSE,                 // Can we have none
FALSE,                 // Can we have many
&CLSID_NULL,           // Connects to filter
NULL,                  // Connects to pin
1,                     // Number of types
&AMSMediaTypesVCam };

const AMOVIESETUP_FILTER AMSFilterVCam = {
&CLSID_VirtualCam,  // Filter CLSID
L"virtual-audio-capturer",     // String name
MERIT_DO_NOT_USE,      // Filter merit
1,                     // Number pins
&AMSPinVCam };

CFactoryTemplate g_Templates[] = {
{
    L"virtual-audio-capturer",
    &CLSID_VirtualCam,
    CVCam::CreateInstance,
    NULL,
    &AMSFilterVCam
}, };

int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);

STDAPI RegisterFilters( BOOL bRegister ) {
HRESULT hr = NOERROR;
WCHAR achFileName[MAX_PATH];
char achTemp[MAX_PATH];
ASSERT(g_hInst != 0);

if( 0 == GetModuleFileNameA(g_hInst, achTemp, sizeof(achTemp))) 
    return AmHresultFromWin32(GetLastError());

MultiByteToWideChar(CP_ACP, 0L, achTemp, lstrlenA(achTemp) + 1, 
                   achFileName, NUMELMS(achFileName));

hr = CoInitialize(0);
if(bRegister) {
    hr = AMovieSetupRegisterServer(CLSID_VirtualCam, L"virtual-audio-capturer", achFileName, L"Both", L"InprocServer32");
}

if( SUCCEEDED(hr) ) {
    IFilterMapper2 *fm = 0;
    hr = CreateComObject( CLSID_FilterMapper2, IID_IFilterMapper2, fm );
    if( SUCCEEDED(hr) )
    {
        if(bRegister)
        {
            IMoniker *pMoniker = 0;
            REGFILTER2 rf2;
            rf2.dwVersion = 1;
            rf2.dwMerit = MERIT_DO_NOT_USE;
            rf2.cPins = 1;
            rf2.rgPins = &AMSPinVCam;
            hr = fm->RegisterFilter(CLSID_VirtualCam, L"virtual-audio-capturer", &pMoniker, &CLSID_AudioInputDeviceCategory, NULL, &rf2);
        }
        else
        {
            hr = fm->UnregisterFilter(&CLSID_AudioInputDeviceCategory, 0, CLSID_VirtualCam);
        }
    }

  // release interface
  if(fm)
      fm->Release();
}

if( SUCCEEDED(hr) && !bRegister )
    hr = AMovieSetupUnregisterServer( CLSID_VirtualCam );

CoFreeUnusedLibraries();
CoUninitialize();
return hr; }

#include <stdio.h>

STDAPI RegisterFilters( BOOL bRegister );

STDAPI DllRegisterServer() {
printf("hello there"); // we actually never see this...
return RegisterFilters(TRUE); }

STDAPI DllUnregisterServer() {
return RegisterFilters(FALSE); }

STDAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);

extern "C" BOOL APIENTRY DllMain(HANDLE hModule, DWORD  dwReason, LPVOID lpReserved) {
return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved); 

请点击链接查看完整的 DirectShow 示例代码。

Flash Player是否提供DirectShow虚拟音频设备?
我应该添加模拟音频输入引脚吗?
我应该实现IAMAudioInputMixer接口吗?
我应该先使用WinDDK制作虚拟音频设备吗?

Win7 SP1 64位系统;
威盛高保真音响;
英特尔音频;
Adobe Flash Media Live Encoder 3.2
Adob​​e Flash Player 11,8,800,94
Adob​​e Flash Builder 4.6
Microsoft Visual C++ 2010
Microsoft Windows SDK 7.1

4

1 回答 1

0

我不能确定,但​​ Flash 可能不使用 DirectShow API 来处理音频,而是使用 Windows 的许多音频 API 中的另一个,可能是 DirectSound。您必须编写音频驱动程序。

于 2013-11-11T09:34:54.250 回答