[DirectShow] Virtual Audio Device

cherishbox 2013-11-06 11:52:15
Win7 SP1 64Bit System;
VIA High Definition Audio;
Intel显示器音效;
Adobe Flash Media Live Encoder 3.2
Adobe Flash Player 11,8,800,94
Adobe Flash Builder 4.6
Microsoft Visual C++ 2010
Microsoft Windows SDK 7.1

我想录制Microphone和系统音频,
再藉由Flash Player发布.

在网上找到一个Sample: virtual-audio-capture-grabber-device
成功注册其DLL file.
C:\windows\system32>cd C:\Users\user\Desktop\virtual-audio-capture-grabber-devic
e-master(1)\virtual-audio-capture-grabber-device-master\source_code\Release

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


再以DirectShow附带的GraphEdt.exe可以找到virtual-audio-capturer,
使用WavDest Filter + File Writer Filter可以储存录制的音频为wav file,
且可以正常播放该file.


但在Flash Player的设定-->Microphone选项中,
找不到该virtual-audio-capturer,
只有Microphone (VIA High Definition Audio)和Stereo Mix (VIA High Definition Audio).

AS3 Code:
			var deviceArray:Array = Microphone.names;

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


可是Adobe Flash Media Live Encoder 3.2找得到.


請問Flash Player 是否不支持DirectShow做的Virtual Device?
又或者我應該注意DirectShow Code的哪些地方?

謝謝

dll_main.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 // clsMajorType
, &MEDIASUBTYPE_NULL }; // clsMinorType

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 // Pin Media types
};

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

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);
}

其他virtual-audio-capture-grabber-device代码, 请参考上文的连结
...全文
466 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
cherishbox 2013-11-11
  • 打赏
  • 举报
回复
1.加上Analog Audio Input Pin 2.Implement IAMAudioInputMixer interface 请问是否如此便可以将这个虚拟音频装置, 注册到: HKEY_CURRENT_USER/Software/Microsoft/ActiveMovie/devenum/ {33D9A762-90C8-11D0-BD43-00A0C911CE86}, 然后Flash Player便找得着了?
VisioForge Video Capture SDK major features include: Preview Video capture to AVI (using audio/video codecs like MJPEG, DivX, XviD, x264) WMV (support of custom WMV profiles. You can configure streams to use variable bit rate encoding (VBR), uncompressed audio or video stream, video size, buffer size, frame rate, etc.) DV and MPEG from DV/HDV Camcorders and TV Tuners with internal MPEG Encoder (DirectCapture technology) DV (from any video capture device) MPEG-1/2/4 (including VCD/SVCD/DVD profiles) and FLV using FFMPEG wrapper WebM MP4 H264 / AAC custom output formats (using 3rd-party DirectShow filters) Audio capture to WAV (compressed or not) MP3 (using LAME) Frame capture to Bitmap class, BMP, JPEG and PNG files Video processing and effects graphic overlay text overlay video transparency brightness, contrast, saturation, hue, etc. deinterlace denoise pan / zoom resize to any resolution chroma-key 3-rd party DirectShow filters support Audio processing and effects volume booster equalizer 3D-bass system TV Tuning TV channels selecting video formats selecting input selection (TV-Tuner, FM-Tuner, S-Video, etc.) TV frequency overrides auto-tuning Video capture device control video input (crossbar interface) video format frame rate supports video cards with several inputs camera control (brightness, saturation, etc.) Network streaming in WMV format to other media servers and devices using virtual camera/audio source Motion detection Closed captions support Custom interfaces support OSD (On-Screen Display) PIP (Picture-In-Picture) Video encryption Screen capture Virtual Camera output Multiply output screens support Supported input devices: DV and HDV MPEG-2 camcorders USB web-cameras and other capture devices PCI capture cards TV Tuners (with and without internal MPEG Encoder) JPEG/MJPEG, MPEG-4 and H.264 HTTP / RTSP / RTMP IP cameras / servers, HD format supported Audio capture devices and sound cards Development platforms: Visual Studio 2005 and later: Visual C#, Visu

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧