自采集IVideoFrameObserver问题

自采集registerVideoFrameObserver注册后的IVideoFrameObserver对象,如何触发onCaptureVideoFrame。
前面我经过了:createAgoraRtcEngine、initialize、setChannelProfile、enableVideo、setVideoEncoderConfiguration、以及 AParameter apm(*_lpAgoraEngine);

mediaEngine.queryInterface(_lpAgoraEngine, agora::AGORA_IID_MEDIA_ENGINE);
if (mediaEngine.get() == NULL)
	return 4;

int mRet = apm->setParameters("{\"che.video.local.camera_index\":1024}");
mRet = mediaEngine->registerVideoFrameObserver(&_CExternalVideoFrameObserver);

mediaEngine->setExternalVideoSource(true, false);

就是无法触发onCaptureVideoFrame回调。请问还差哪些步骤,很抱歉示例AgoraMediaSource程序我跑不起来,调试不了。

// 准备工作,需要实现视频采集模块,以及视频数据队列(用来存放采集出来的数据/或者将要渲染的数据)
CVideoPackageQueue *CVideoPackageQueue::m_lpVideoPackageQueue = NULL;

CVideoPackageQueue::CVideoPackageQueue()
{
    m_nPackageSize = 0;
    m_nBufferSize = 0x800000;
    m_bufQueue.Create(32, 0x800000);
}

CVideoPackageQueue::~CVideoPackageQueue()
{
    m_bufQueue.FreeAllBusyBlock();
    m_bufQueue.Close();
}

CVideoPackageQueue *CVideoPackageQueue::GetInstance()
{
    if (m_lpVideoPackageQueue == NULL)
        m_lpVideoPackageQueue = new CVideoPackageQueue();

    return m_lpVideoPackageQueue;
}

void CVideoPackageQueue::CloseInstance()
{
    if (m_lpVideoPackageQueue == NULL)
        return;

    delete m_lpVideoPackageQueue;
    m_lpVideoPackageQueue = NULL;
}

void CVideoPackageQueue::SetVideoFormat(const BITMAPINFOHEADER *lpInfoHeader)
{
  memcpy_s(&m_bmiHeader, sizeof(BITMAPINFOHEADER), lpInfoHeader, sizeof(BITMAPINFOHEADER));

  m_nPackageSize = m_bmiHeader.biWidth*m_bmiHeader.biWidth * 3 / 2;
  _ASSERT(m_nPackageSize <= m_nBufferSize);
}

void CVideoPackageQueue::GetVideoFormat(BITMAPINFOHEADER *lpInfoHeader)
{
  memcpy_s(lpInfoHeader, sizeof(BITMAPINFOHEADER), &m_bmiHeader, sizeof(BITMAPINFOHEADER));
}

BOOL CVideoPackageQueue::PushVideoPackage(LPCVOID lpVideoPackage, SIZE_T nPackageLen)
{
  if (m_bufQueue.GetFreeCount() == 0)
    m_bufQueue.FreeBusyHead(NULL, 0);

  LPVOID lpBuffer = m_bufQueue.AllocBuffer(FALSE);
  if (lpBuffer == NULL) 
    return FALSE;

  _ASSERT(m_bufQueue.GetBytesPreUnit() >= nPackageLen);

  memcpy_s(lpBuffer, m_bufQueue.GetBytesPreUnit(), lpVideoPackage, nPackageLen);

  return TRUE;
}

BOOL CVideoPackageQueue::PopVideoPackage(LPVOID lpVideoPackage, SIZE_T *nPackageSize)
{
  _ASSERT(nPackageSize != NULL);

  if (nPackageSize == 0)
    return FALSE;

  if (m_bufQueue.GetBusyCount() == 0)
    return FALSE;

  if (*nPackageSize < m_nPackageSize) {
    *nPackageSize = m_nPackageSize;
    return FALSE;
  }

  *nPackageSize = m_nPackageSize;
  m_bufQueue.FreeBusyHead(lpVideoPackage, m_nPackageSize);

  return TRUE;
}

// 实现视频观测器,为采集外部视频源做准备
CExternalVideoFrameObserver::CExternalVideoFrameObserver()
{
  m_lpImageBuffer = new BYTE[0x800000];
}

CExternalVideoFrameObserver::~CExternalVideoFrameObserver()
{
  delete[] m_lpImageBuffer;
}

bool CExternalVideoFrameObserver::onCaptureVideoFrame(VideoFrame& videoFrame)
{
  SIZE_T nBufferSize = 0x800000;

  BOOL bSuccess = CVideoPackageQueue::GetInstance()->PopVideoPackage(m_lpImageBuffer, &nBufferSize);
  if (!bSuccess)
    return false;

  m_lpY = m_lpImageBuffer;
  m_lpU = m_lpImageBuffer + videoFrame.height*videoFrame.width;
  m_lpV = m_lpImageBuffer + 5 * videoFrame.height*videoFrame.width / 4;

  memcpy_s(videoFrame.yBuffer, videoFrame.height*videoFrame.width, m_lpY, videoFrame.height*videoFrame.width);
  videoFrame.yStride = videoFrame.width;

  memcpy_s(videoFrame.uBuffer, videoFrame.height*videoFrame.width / 4, m_lpU, videoFrame.height*videoFrame.width / 4);
  videoFrame.uStride = videoFrame.width/2;

  memcpy_s(videoFrame.vBuffer, videoFrame.height*videoFrame.width / 4, m_lpV, videoFrame.height*videoFrame.width / 4);
  videoFrame.vStride = videoFrame.width/2;

  videoFrame.type = FRAME_TYPE_YUV420;
  videoFrame.rotation = 0;

  return true;
}

bool CExternalVideoFrameObserver::onRenderVideoFrame(unsigned int uid, VideoFrame& videoFrame)
{
  return true;
}

// 启用外部视频数据源模式,注册视频观测器,我们使用观测器将外部的数据源传递给引擎以及把引擎返回的数据给到应用
agora::util::AutoPtr<agora::media::IMediaEngine> mediaEngine;
mediaEngine.queryInterface(lpAgoraEngine, agora::AGORA_IID_MEDIA_ENGINE);

int mRet = apm->setParameters("{\"che.video.local.camera_index\":1024}"); 
nRet = mediaEngine->registerVideoFrameObserver(lpVideoFrameObserver);

// 开始往引擎推送数据以及从引擎获取数据,通常需要自己维护一个线程循环
lpPackageQueue->PushVideoPackage(m_lpYUVBuffer, nYUVSize); // push to Agora SDK

// 停止外部视频数据源模式
nRet = apm->setParameters("{\"che.video.local.camera_index\":0}");

mediaEngine->registerVideoFrameObserver(NULL);

你是按照这样的代码逻辑来写的吗?

必须要用CVideoPackageQueue对象吗?这个对象只是帧缓存用的吧?我自己有帧缓存处理,没有建CVideoPackageQueue。

BOOL bSuccess = CVideoPackageQueue::GetInstance()->PopVideoPackage(m_lpImageBuffer, &nBufferSize);这个我有自己的方法提取帧数据。其他是按这个介绍做的CExternalVideoFrameObserver。

不是必须的。同样的,onCaptureVideoFrame 回调对于自采集而言也不是必须的,可能是因为没有采集到视频帧数据,才不走这个回调。你 debug 调试看下?

哦,registerVideoFrameObserver这个不是注册后能自动触发回调onCaptureVideoFrame函数,在回调函数内部取数据吗?示例中的CVideoPackageQueue对象就是维护一个缓存区,只有onCaptureVideoFrame回调时才能从里面取帧数据吧。现在我不知道的是如何把手上的帧数据,交给引擎。我理解的registerVideoFrameObserver方法是通过他的onCaptureVideoFrame回调函数找我要数据,但是onCaptureVideoFrame一直就没触发过。或者有什么方法让我能主动推数据(CVideoPackageQueue对象有推的方法,可是我看最后还是靠onCaptureVideoFrame来取,这跟让onCaptureVideoFrame去取我的数据没区别)

“采集到视频帧数据”跟onCaptureVideoFrame是有关联的吗?我看了示例代码中的CVideoPackageQueue的类实现也没有基类,它的用PushVideoPackage方法时也没调用其他引擎函数,这是如何触发 onCaptureVideoFrame回调的?我调试时,前面步骤中引擎函数都返回正确0,就是onCaptureVideoFrame无法触发。

在我的理解里,自采集是你通过系统接口,从摄像头或其他地方拿到视频帧数据,然后再通过 pushVideoFrame 接口传给声网的 SDK。但是 onCaptureVideoFrame 方法严格来说是一个获取裸数据的接口,也就是从中获取到采集的原始视频帧。那对于自采集而言,就不是必须的了啊。

你那边调试过为啥不走到 onCaptureVideoFrame 了吗

明白了,谢谢!

我用pushVideoFrame也无法走到 onCaptureVideoFrame,渲染也不成功,主要是我不确定 pushVideoFrame这个过程是不是正确的。没有看到pushVideoFrame的使用示例。

	if (_GetRGBAFuncType == NULL)
		return 1;

	ExternalVideoFrame frame;
	frame.type = ExternalVideoFrame::VIDEO_BUFFER_TYPE::VIDEO_BUFFER_RAW_DATA;
	frame.format = ExternalVideoFrame::VIDEO_PIXEL_FORMAT::VIDEO_PIXEL_BGRA;

	frame.height = 576;
	frame.stride = 704*4;

	AParameter apm(*_lpAgoraEngine);
	mediaEngine.queryInterface(_lpAgoraEngine, agora::AGORA_IID_MEDIA_ENGINE);
	if (mediaEngine.get() == NULL)
		return 1;

	int m_iIndex = 0;
	do {

		int m_iWidth = 0;
		int m_iHeight = 0;
		bool bSuccess = _GetRGBAFuncType(m_Image, m_iWidth, m_iHeight);
		if (bSuccess)
		{
			char m_path[100] = { 0 };
			sprintf(m_path, "D://video//%d.bmp", m_iIndex++);
			SaveToBmp(m_path, m_Image, m_iWidth, m_iHeight, 4);


			frame.buffer = m_Image;

			frame.timestamp = m_iIndex * 30;

			int ret = mediaEngine->pushVideoFrame(&frame);

			m_iIndex++;
		}


		Sleep(30);
	} while (TRUE);

我确定从我缓存取出来的图片是正确的。m_Image是RGBA原始数据,虽然跟BGRA不一样,但应该可以显示,是变色的图片。前面我也做了setupLocalVideo关联了uid和窗口句柄。

你得先把RGBA转换为BGRA格式才行

https://www.brobwind.com/archives/1465

我转了的也是一样,句柄对应的窗口没有图像,onCaptureVideoFrame也没触发。

有没有报错呢?拿 sdk log 看看吧

Local Date: 5月 20 2019 Local Time: 16:45:26
Build info: Apr  1 2019 00:30:24 r

INFO    16:45:26:826  14792; Agora SDK ver 2.4.0 build 1595, built on Apr  1 2019 00:38:59
INFO    16:45:26:826  14792; Agora SDK git ver:6092a8a37 and branch:HEAD
WARN    16:45:26:892  14792; CacheManager: load cache from storage error, err=2 elapsed 0
ERROR   16:45:26:892  14792; CacheManager: load report cache from storage error, err=2 elapsed 0
INFO    16:45:26:892  14792; initialize plugin manager
INFO    16:45:26:892  14792; built-in encryption is enabled
INFO    16:45:26:894  14792; use event engine
INFO    16:45:26:894  14792; Agora Rtc Engine SDK ver 2.4.0 build 1595, built on Apr  1 2019 00:39:02
INFO    16:45:26:895  19568; Agora Service Worker Thread started: 00297240
INFO    16:45:27:962  14792; API call to setChannelProfile 1
INFO    16:45:27:962  14792; API call to enable video
INFO    16:45:27:962  14792; API call to setVideoEncoderConfiguration 704x576 30 fps -1 minFps 0 kbps min -1 kbps mode 0 degradation prefer 0
INFO    16:45:27:962  14792; API call to setClientRole 1
INFO    16:45:27:963  14792; API call to join channel 'channel_1' uid 0, SDK ver 2.4.0 build 1595, device info 'System manufacturer/System Product Name/x64-based PC/Windows 6.2.9200'
INFO    16:45:29:998  19568; network: 'NETWORK_UNKOWN' -> 'LAN' ipv4/v6 '192.168.10.3'/'fe80::bc26:aa0e:c5b9:e7db' gw '192.168.10.1'/'' subtype 0 level -1 ssid '' bssid '' rssi -1 asu -1
INFO    16:45:29:998  19568; [rs] updateServers 199.190.44.36:8000, priority 1
INFO    16:45:29:998  19568; [rs] updateServers 199.190.44.37:8000, priority 1
INFO    16:45:30:003  19568; [rlbs] selected: 52.80.192.229:9700
INFO    16:45:30:003  19568; [rlbs] request rs list from 52.80.192.229:9700 with fake ch report_lbs_1558341930003.......
INFO    16:45:30:011  19568; [MIO] mediaIO controller created
INFO    16:45:30:011  19568; found 'NULL' device: 'System manufacturer/System Product Name/x64-based PC/Windows 6.2.9200'
INFO    16:45:30:011  19568; CacheManager: save cache to storage elapsed 0
INFO    16:45:30:011  19568; [ap] selected: 47.74.211.17:8000
INFO    16:45:30:012  19568; connecting to 47.74.211.17:8000 handle 1648a630, 1620
INFO    16:45:30:012  19568; [ap] CdsTdsRequest, vendor: 5974287d9132460e8c4406ce234cb752, device: System manufacturer/System Product Name, detail: System manufacturer/System Product Name/x64-based PC/Windows 6.2.9200, system: Windows/6.2.9200, version: 
INFO    16:45:30:012  19568; [ap] creating channel with 47.74.211.17:8000, ts 0, flag: 72
INFO    16:45:30:012  19568; [ap] selected: 54.223.118.211:1080
INFO    16:45:30:012  19568; [ap] CdsTdsRequest, vendor: 5974287d9132460e8c4406ce234cb752, device: System manufacturer/System Product Name, detail: System manufacturer/System Product Name/x64-based PC/Windows 6.2.9200, system: Windows/6.2.9200, version: 
INFO    16:45:30:012  19568; [ap] creating channel with 54.223.118.211:1080, ts 0, flag: 72
INFO    16:45:30:012  19568; [ap] selected: 47.107.39.93:25000
INFO    16:45:30:012  19568; [ap] CdsTdsRequest, vendor: 5974287d9132460e8c4406ce234cb752, device: System manufacturer/System Product Name, detail: System manufacturer/System Product Name/x64-based PC/Windows 6.2.9200, system: Windows/6.2.9200, version: 
INFO    16:45:30:012  19568; [ap] creating channel with 47.107.39.93:25000, ts 0, flag: 72
INFO    16:45:30:012  19568; [rp] {"rtc.channel_profile":1}
INFO    16:45:30:012  19568; [rp] {"rtc.video.enabled":true}
INFO    16:45:30:012  19568; API call to enable video
INFO    16:45:30:012  19568; [rp] {"rtc.client_role":1}
INFO    16:45:30:012  19568; set client role to broadcaster
INFO    16:45:30:012  19568; [rp] {"che.video.local.camera_index":1024}
INFO    16:45:30:012  19568; doStopLastmileProbeTest
INFO    16:45:30:012  19568; ***CALL BEGIN: appid:'59****************************52' cname:'channel_1' info:'' sid:'B7020014889545C8983D6D89E69234F4'
INFO    16:45:30:012  19568; addRef of media engine, ref=1
INFO    16:45:30:012  19568; [che] create chat engine, ctx:00000000
INFO    16:45:30:012  19568; [MYDEBUG] large group call false
INFO    16:45:30:013  19568; ChatEngineParameterHelper::applyMediaEngineMode: 
INFO    16:45:30:013  19568; applyMediaEngineMode(): Hardware encoding false Hardware decoding false
INFO    16:45:30:013  20908; Thread with name:AudioAsyncTask started 
INFO    16:45:30:013  19568; engine git commit version:9a04b3a50 and branch:(HEAD
INFO    16:45:30:014  19568; output: kPlatformDefaultAudio
INFO    16:45:30:014  19568; [WIN_CORE] +++++++Code block begins for checking CoreAudio properties++++++
INFO    16:45:30:021  19568; AgoraRTC::AudioDeviceNotificationWindows::AudioDeviceNotificationWindows created
INFO    16:45:30:026  19568; [WIN_CORE] ===================Render Devices Enumeration===================
INFO    16:45:30:026  19568; [WIN_CORE] #rendering endpoint devices (counting all): 2
INFO    16:45:30:026  19568; [WIN_CORE] ++Endpoint  0:
INFO    16:45:30:026  19568; [WIN_CORE] ID string    : {0.0.0.00000000}.{37bfa29d-e569-4ab2-9975-d1bd99a4ed43}
INFO    16:45:30:026  19568; [WIN_CORE] friendly name: "Realtek Digital Output (Realtek High Definition Audio)"
INFO    16:45:30:026  19568; [WIN_CORE] state (0x1)  : *ACTIVE*
INFO    16:45:30:026  19568; [WIN_CORE] ++Endpoint  1:
INFO    16:45:30:026  19568; [WIN_CORE] ID string    : {0.0.0.00000000}.{54c9b18c-f9b3-4f9a-8e42-4597b399bae3}
INFO    16:45:30:026  19568; [WIN_CORE] friendly name: "鎵0鍣?(Realtek High Definition Audio)"
INFO    16:45:30:026  19568; [WIN_CORE] state (0x1)  : *ACTIVE*
INFO    16:45:30:026  19568; [WIN_CORE] =========================EnumDeviceEnd==========================
INFO    16:45:30:027  19568; [WIN_CORE] ==================Capture Devices Enumeration===================
INFO    16:45:30:027  19568; [WIN_CORE] #capturing endpoint devices (counting all): 3
INFO    16:45:30:027  19568; [WIN_CORE] ++Endpoint  0:
INFO    16:45:30:027  19568; [WIN_CORE] ID string    : {0.0.1.00000000}.{3da27f5e-59ed-4f50-9093-d8c47b48b4ed}
INFO    16:45:30:028  19568; [WIN_CORE] friendly name: "楹﹀厠椋?(Realtek High Definition Audio)"
INFO    16:45:30:028  19568; [WIN_CORE] state (0x1)  : *ACTIVE*
INFO    16:45:30:028  19568; [WIN_CORE] ++Endpoint  1:
INFO    16:45:30:028  19568; [WIN_CORE] ID string    : {0.0.1.00000000}.{452a69bb-38d7-4b76-851b-e1eb8f6b0457}
INFO    16:45:30:028  19568; [WIN_CORE] friendly name: "绔嬩綋澹版贩闊?(Realtek High Definition Audio)"
INFO    16:45:30:028  19568; [WIN_CORE] state (0x1)  : *ACTIVE*
INFO    16:45:30:028  19568; [WIN_CORE] ++Endpoint  2:
INFO    16:45:30:028  19568; [WIN_CORE] ID string    : {0.0.1.00000000}.{80add5fd-75bf-476d-9672-6871a8ec40ed}
INFO    16:45:30:028  19568; [WIN_CORE] friendly name: "绾胯矾杈撳叆 (Realtek High Definition Audio)"
INFO    16:45:30:028  19568; [WIN_CORE] state (0x8)  : UNPLUGGED
INFO    16:45:30:028  19568; [WIN_CORE] =========================EnumDeviceEnd==========================
INFO    16:45:30:030  19568; [WIN_CORE] *** Windows Core Audio is supported ***
INFO    16:45:30:030  19568; [WIN_CORE] ++++++++Code block ends for checking CoreAudio properties++++++++
INFO    16:45:30:030  19568; audio jitterbuffer new smooth
INFO    16:45:30:030  19568;   OS info: Microsoft  (build 9200), 64-bit
INFO    16:45:30:032  19568; [WIN_CORE] Set playout device on Windows by Windows Device Type (-2): friendly name: "鎵0鍣?(Realtek High Definition Audio)"
INFO    16:45:30:064  19568; [WIN_CORE] Set recording device on Windows by Windows Device Type (-2): friendly name: "楹﹀厠椋?(Realtek High Definition Audio)"
INFO    16:45:30:068  19568; StereoPlayoutIsAvailable(), output: available=1
INFO    16:45:30:068  19568; StereoRecordingIsAvailable(), output: available=1
INFO    16:45:30:068  19568; RegisterReceiveCodec 13.
INFO    16:45:30:068  19568; RegisterReceiveCodec 98.
INFO    16:45:30:068  19568; RegisterReceiveCodec 99.
INFO    16:45:30:068  19568; RegisterReceiveCodec 100.
INFO    16:45:30:068  19568; RegisterReceiveCodec 127.
INFO    16:45:30:068  16732; Thread with name:EngineMonitorThread started 
INFO    16:45:30:069  19568; RegisterVolumeNotify
INFO    16:45:30:069  19568; setMuteStatus, muted: Off
INFO    16:45:30:069  19568; setMuteOutput, muted: false
INFO    16:45:30:069  19568; Audio Engine Init success
INFO    16:45:30:069  19568; Available number of cores:6
INFO    16:45:30:069  19568; PipelineManager::SetDest  engine = 1655EEE8
INFO    16:45:30:069  19568; agora::media::VideoEngine::CreateVideoSendTrack
INFO    16:45:30:070  10192; Thread with name:VideoAsyncTask started 
INFO    16:45:30:070  19568; agora::media::VideoEngine::init: feature prerotation enabled
INFO    16:45:30:070  19568; Agora Engine video codec set to standard mode role mode 2
INFO    16:45:30:070  19568; Agora Engine video codec index 1
INFO    16:45:30:070  19568; Agora Engine video stream type = 0
INFO    16:45:30:071   9576; Thread with name:VideoEncodeThread started 
INFO    16:45:30:071  19568; Device type: 0
INFO    16:45:30:071  19568; last unique frame idx: -1 - -1
INFO    16:45:30:071  19568; Device type: 0
INFO    16:45:30:071  19568; EncoderWrapper::Create hardware_ = 0, hardware_low_ = 0
INFO    16:45:30:071  19568; low bit rate limit 3758096384
INFO    16:45:30:071  19568; dont need to increase unique frame idx
INFO    16:45:30:071  19568; the init unique frame idx: -1 - -1
INFO    16:45:30:072  15500; Thread with name:VideoProcessThread started 
INFO    16:45:30:072  19568; agora::media::VideoEngine::setCodec: index=1 width=640 height=360 framerate=15
INFO    16:45:30:072  19568; agora::media::VideoEngine::setCodec: Intra Request = 0
INFO    16:45:30:072   9576; Thread with name:VideoEncodeThread stopped
INFO    16:45:30:073   5592; Thread with name:VideoEncodeThread started 
INFO    16:45:30:073  19568; Device type: 0
INFO    16:45:30:073  19568; agora::media::VideoEngine::h264WebInteropEnable: enable 0
INFO    16:45:30:073  19568; agora::media::VideoEngine::setCaptureDevice: index=1024
INFO    16:45:30:073  19568; VideoSendTrackImpl::agora::VideoSendTrackImpl::UpdateCapturer capturer=1656EC40
INFO    16:45:30:073  19568; agora::media::VideoEngine::CreateVideoCapturer: interface=1656EC40
INFO    16:45:30:073  19568; agora::media::VideoEngine::setMaxVideoBitrate: max bitrate=0
INFO    16:45:30:073  19568; Setting video fec method 1, real using 1
INFO    16:45:30:073  19568; SetBandwidthAgressiveLevel to 2.
INFO    16:45:30:073  19568; dynamic sending rate control enabled 0.

INFO    16:45:30:073  19568; videoEngine created and initialize here
INFO    16:45:30:073  19568; agora::media::VideoEngine::CreateVideoSendTrack
INFO    16:45:30:073  19568; [MIO] updateCapturer: (00000000), type:(1)
INFO    16:45:30:073  19568; agora::media::VideoEngine::CreateAgoraDefaultCapture: type=0
INFO    16:45:30:073  19568; VideoSendTrackImpl::agora::VideoSendTrackImpl::UpdateCapturer capturer=164C0F48
INFO    16:45:30:073  19568; agora::media::VideoEngine::CreateVideoCapturer: interface=164C0F48
INFO    16:45:30:073  19568; [MIO] updateLocalRender: (00000000), type:(1)
INFO    16:45:30:073  19568; agora::media::VideoEngine::CreateAgoraDefaultRender
INFO    16:45:30:073  19568; VideoSendTrackImpl::agora::VideoSendTrackImpl::UpdateRenderer, renderer=1656C888
INFO    16:45:30:073  19568; agora::media::VideoEngine::CreateVideoRenderer: interface=1656C888
INFO    16:45:30:073  19568; [MIO] video send track prepared !!
INFO    16:45:30:073  19568; [che] applyVideoProfile: 704x576 30 fps  -1 minFps 1852 kbps, min -1 kbps orientationMode 0 degradationPrefer 0
INFO    16:45:30:073  19568; agora::media::VideoEngine::validateVideoParameters: validate video parameters resolution 704x576, fps 30, rate 1852000
INFO    16:45:30:073  19568; agora::media::VideoEngine::setMaxVideoBitrate: max bitrate=1852000
INFO    16:45:30:073  19568; agora::media::VideoEngine::setCodecRates: set frame rate to 30
INFO    16:45:30:073  19568; agora::media::VideoEngine::setCodec: index=1 width=640 height=360 framerate=30
INFO    16:45:30:073  19568; agora::media::VideoEngine::setCodec: Intra Request = 0
INFO    16:45:30:073   5592; Thread with name:VideoEncodeThread stopped
INFO    16:45:30:074  16156; Thread with name:VideoEncodeThread started 
INFO    16:45:30:074  19568; Device type: 0
INFO    16:45:30:074  19568; last unique frame idx: -1 - -1
INFO    16:45:30:074  19568; Device type: 0
INFO    16:45:30:074  19568; EncoderWrapper::Create hardware_ = 0, hardware_low_ = 0
INFO    16:45:30:074  19568; low bit rate limit 2684354560
INFO    16:45:30:074  19568; set last big unique frame idx: -1
INFO    16:45:30:074  19568; set last small unique frame idx: -1
INFO    16:45:30:074  19568; the init unique frame idx: -1 - -1
INFO    16:45:30:074  19568; SetTargetWidthHeight width:640, height:360
INFO    16:45:30:074  19568; agora::media::VideoEngine::setCodecResolution: set to 704 x 576
INFO    16:45:30:074  19568; agora::media::VideoEngine::setCodec: index=1 width=704 height=576 framerate=30
INFO    16:45:30:074  19568; agora::media::VideoEngine::setCodec: Intra Request = 0
INFO    16:45:30:074  16156; Thread with name:VideoEncodeThread stopped
INFO    16:45:30:075  16876; Thread with name:VideoEncodeThread started 
INFO    16:45:30:075  19568; Device type: 0
INFO    16:45:30:075  19568; last unique frame idx: -1 - -1
INFO    16:45:30:075  19568; Device type: 0
INFO    16:45:30:075  19568; EncoderWrapper::Create hardware_ = 0, hardware_low_ = 0
INFO    16:45:30:075  19568; low bit rate limit 0
INFO    16:45:30:076  19568; set last big unique frame idx: -1
INFO    16:45:30:076  19568; set last small unique frame idx: -1
INFO    16:45:30:076  19568; the init unique frame idx: -1 - -1
INFO    16:45:30:076  19568; SetTargetWidthHeight width:704, height:576
INFO    16:45:30:076  19568; Set broadcast min br to -1.
INFO    16:45:30:076  19568; [che] chat engine initialized
INFO    16:45:30:076  19568; [time] process EngineInitialize takes 64
INFO    16:45:30:076  19568; agora::media::VideoEngine::adjustCodecFrameRates: Cannot adjust frame rate when VQC is on
INFO    16:45:30:076  19568; [tactics] version:2.4.0 maxBitrate:1852 704X576 30 fps needHandle:1
INFO    16:45:30:076  19568; [tactics] config json version:20150101-0000 duallinkd:true poor:u
INFO    16:45:30:076  19568; [tactics] parse config for beckon error for tactics size:15
INFO    16:45:30:084  19568; [vocs] vocs initialized
INFO    16:45:30:085  19568; CacheManager: save cache to storage elapsed 0
INFO    16:45:30:085  19568; [cm] emit join channel signal, size=3
INFO    16:45:30:085  19568; [cm] connection state changed from 1 to 2
INFO    16:45:30:085  19568; CacheManager: save cache to storage elapsed 0
INFO    16:45:30:085  19568; agora::media::VideoEngine::adjustCodecFrameRates: Cannot adjust frame rate when VQC is on
INFO    16:45:30:085  19568; [tactics] version:2.4.0 maxBitrate:1852 704X576 30 fps needHandle:1
INFO    16:45:30:085  19568; [vocs] lookup channel...
INFO    16:45:30:085  19568; [vocs] selected: 47.107.39.93:8000
INFO    16:45:30:085  19568; connecting to 47.107.39.93:8000 handle 16478978, 2040
INFO    16:45:30:085  19568; [vocs] report bitrate: a/v/t: 50/1852/1902
INFO    16:45:30:085  19568; [vocs] creating channel with 47.107.39.93:8000, ts 1558341930085.......
INFO    16:45:30:085  19568; [vocs] selected: 54.223.118.211:1080
INFO    16:45:30:085  19568; [vocs] report bitrate: a/v/t: 50/1852/1902
INFO    16:45:30:085  19568; [vocs] creating channel with 54.223.118.211:1080, ts 1558341930085.......
INFO    16:45:30:085  19568; [vocs] selected: 106.14.12.130:25000
INFO    16:45:30:085  19568; [vocs] report bitrate: a/v/t: 50/1852/1902
INFO    16:45:30:085  19568; [vocs] creating channel with 106.14.12.130:25000, ts 1558341930085.......
INFO    16:45:30:085  19568; [ap] selected: 47.74.211.17:8000
INFO    16:45:30:085  19568; connecting to 47.74.211.17:8000 handle 16478a90, 2044
INFO    16:45:30:085  19568; [ap] creating channel with 47.74.211.17:8000, ts 279918371, flag: 2
INFO    16:45:30:085  19568; [ap] selected: 54.223.118.211:1080
INFO    16:45:30:085  19568; [ap] creating channel with 54.223.118.211:1080, ts 279918371, flag: 2
INFO    16:45:30:085  19568; [ap] selected: 47.107.39.93:25000
INFO    16:45:30:085  19568; [ap] creating channel with 47.107.39.93:25000, ts 279918371, flag: 2
INFO    16:45:30:085  19568; [ap/u] **responsed from 47.107.39.93:25000, CDS(8).
INFO    16:45:30:085  19568; [ap] onAPCdsRes success with config: 钙惎咴冥椦蠠釖柌论墉粕鈨厬?
INFO    16:45:30:085  19568; [cs] applied directly: {"configs":{},"version":"27"}, elapsed: 0
INFO    16:45:30:086  19568; CacheManager: save cache to storage elapsed 0
INFO    16:45:30:086  19568; [rlbs/u] responsed from 52.80.192.229:9700 with servers 117.21.184.25:8913
INFO    16:45:30:086  19568; [rs] updateServers 117.21.184.25:8913, priority 3
INFO    16:45:30:086  19568; [rs] updateServers 114.236.93.137:8913, priority 3
INFO    16:45:30:086  19568; [rs] updateServers 14.17.81.121:8913, priority 3
INFO    16:45:30:086  19568; [dns] parsed ip 120.132.29.28
INFO    16:45:30:086  19568; [dns] parsed ip 101.201.199.195
INFO    16:45:30:086  19568; [dns] parsed ip 118.190.148.38
INFO    16:45:30:086  19568; [dns] parsed ip 54.223.118.211
INFO    16:45:30:086  19568; [ap] onParsedDns with err 0, 120.132.29.28, 101.201.199.195, 118.190.148.38, 54.223.118.211, 
INFO    16:45:30:086  19568; [dns] parsed ip 114.236.138.35
INFO    16:45:30:086  19568; [rs] dns parse result code: 0, servers size: 1
INFO    16:45:30:086  19568; [rs] updateServers 114.236.138.35:8000, priority 2
INFO    16:45:30:086  19568; [ap/u] **responsed from 47.107.39.93:25000, TDS(64).
INFO    16:45:30:086  19568; [ap] onAPTdsRes success with config: {"OPUS test for v2.4.0":{"B":{}}}, size: 1
INFO    16:45:30:086  19568; [ap/u] **responsed from 54.223.118.211:1080, CDS(8).
INFO    16:45:30:086  19568; [ap/u] **responsed from 54.223.118.211:1080, TDS(64).
INFO    16:45:30:103  19568; [dns] parsed ip 120.132.29.28
INFO    16:45:30:103  19568; [dns] parsed ip 54.223.118.211
INFO    16:45:30:103  19568; [dns] parsed ip 118.190.148.38
INFO    16:45:30:103  19568; [dns] parsed ip 101.201.199.195
INFO    16:45:30:104  19568; [ap/u] **responsed from 47.74.211.17:8000, CDS(8).
INFO    16:45:30:105  19568; [ap/u] **responsed from 47.74.211.17:8000, TDS(64).
INFO    16:45:30:105  19568; [dns] parsed ip 118.190.148.38
INFO    16:45:30:105  19568; [dns] parsed ip 120.132.29.28
INFO    16:45:30:105  19568; [dns] parsed ip 54.223.118.211
INFO    16:45:30:105  19568; [dns] parsed ip 101.201.199.195
INFO    16:45:30:162  19568; [vocs/t] tcp create channel connected with 002983F0
INFO    16:45:30:162  19568; [vocs] report bitrate: a/v/t: 50/1852/1902
INFO    16:45:30:162  19568; [vocs] tcp - creating channel with 47.107.39.93:8000, ts 1558341930162.......
INFO    16:45:30:162  19568; [ap/u] **responsed from 47.107.39.93:25000, STUN(2).
INFO    16:45:30:179  19568; [vocs/u] **responsed from 54.223.118.211:1080, 3 vos, elapsed 2217, server ts 1558341930093, wan ip 58******214
INFO    16:45:30:179  19568; [vos] added server: 27.148.206.58:4002
INFO    16:45:30:179  19568; [vos] added server: 117.21.184.22:4011
INFO    16:45:30:179  19568; [vos] added server: 117.21.184.5:4007
INFO    16:45:30:180  19568; [ch0] vos initialized
INFO    16:45:30:180  19568; [vos] selected: 117.21.184.5:4007
ERROR   16:45:30:180  19568; [ch0] login strategy=2
INFO    16:45:30:180  19568; [ds]: ver 1 ds '{"streamType":5,"clientRole":1}'
INFO    16:45:30:180  19568; [ch0] Login VOS (proto:12, cid:1802831144, uid:3446614363, ts:1558341930180, ticket size:84 ds:1 stream:+A+VH) 2: 117.21.184.5:4007
INFO    16:45:30:195  19568; [vocs/u] **responsed from 106.14.12.130:25000, 3 vos, elapsed 2232, server ts 1558341930097, wan ip 58******214
INFO    16:45:30:201  19568; [vocs/u] **responsed from 47.107.39.93:8000, 3 vos, elapsed 2239, server ts 1558341930100, wan ip 58******214
INFO    16:45:30:209  19568; [ap/u] **responsed from 54.223.118.211:1080, STUN(2).
INFO    16:45:30:282  19568; [ap/u] **responsed from 47.74.211.17:8000, STUN(2).
INFO    16:45:30:285  19568; [ch0] **VOS response to login request (res 0 elapsed 2323, server ts 1558341930126, s-c:-159) from 117.21.184.5:4007, and current dest server 117.21.184.5:4007
INFO    16:45:30:285  19568; updateActiveVosList: ["117.21.184.5:4007"]
INFO    16:45:30:285  19568; [cm] connection state changed from 2 to 3
INFO    16:45:30:285  19568; agora::media::VideoEngine::RequestEncodeKeyFrame
INFO    16:45:30:285  19568; [che] start call begins
INFO    16:45:30:285  19568; Update settings: mode 3, rec_source -10, rec_fs 16000, builtin aec 0
INFO    16:45:30:285  19568; Set Application Mode in RTC Engine to No. 4 UC 0
INFO    16:45:30:285  19568; SetCodec by type : No. 77
INFO    16:45:30:286  19568; [che] applyVideoProfile: 704x576 30 fps  -1 minFps 1852 kbps, min -1 kbps orientationMode 0 degradationPrefer 0
INFO    16:45:30:286  19568; agora::media::VideoEngine::validateVideoParameters: validate video parameters resolution 704x576, fps 30, rate 1852000
INFO    16:45:30:286  19568; agora::media::VideoEngine::setMaxVideoBitrate: max bitrate=1852000
INFO    16:45:30:286  19568; agora::media::VideoEngine::setCodecRates: set frame rate to 30
INFO    16:45:30:286  19568; agora::media::VideoEngine::setCodec: index=1 width=704 height=576 framerate=30
INFO    16:45:30:286  19568; agora::media::VideoEngine::setCodec: Intra Request = 0
INFO    16:45:30:286  19568; agora::media::VideoEngine::setCodecResolution: set to 704 x 576
INFO    16:45:30:286  19568; Set broadcast min br to -1.
INFO    16:45:30:286  19568; VideoSendTrackImpl::agora::VideoSendTrackImpl::UpdateCapturer capturer=1656EC40
INFO    16:45:30:286  19568; agora::media::VideoEngine::CreateVideoCapturer: interface=1656EC40
INFO    16:45:30:286  20908; setLoopbackRecording, enabled: false, delay 0, aec 1 
INFO    16:45:30:286  19568; Use external video source
ERROR   16:45:30:286  19568; Assert external camera failed! Force using 1025
INFO    16:45:30:286  19568; VideoSendTrackImpl::agora::VideoSendTrackImpl::UpdateCapturer capturer=1656EC40
WARN    16:45:30:286  19568; VideoSendTrackImpl::agora::VideoSendTrackImpl::UpdateCapturer, Ignore updating the same capturer
INFO    16:45:30:286  19568; Create participant 0
INFO    16:45:30:286  19568; agora::media::VideoEngine::_startCapture: device? 1025 init? 1 local enabled? 1 capturing? 0 rendering? 0
INFO    16:45:30:296  20908; [WIN_CORE] Audio Engine's current mix format for rendering shared-mode streams:
INFO    16:45:30:296  20908; [WIN_CORE] wFormatTag     : 0xFFFE (65534)
INFO    16:45:30:296  20908; [WIN_CORE] nChannels      : 2
INFO    16:45:30:296  20908; [WIN_CORE] nSamplesPerSec : 48000
INFO    16:45:30:296  20908; [WIN_CORE] wBitsPerSample : 32
INFO    16:45:30:296  19568; [rtpSender] set paced sender status 0.

INFO    16:45:30:296  19568; AgoraVideoInput::agora::AgoraVideoInput::Init thread=1, type=100, device=External Push Device
INFO    16:45:30:297  21324; Thread with name:AgoraInputThread started 
INFO    16:45:30:297  19568; agora::media::VideoEngine::h264WebInteropEnable: enable 0
INFO    16:45:30:297  19568; agora::media::VideoEngine::setCodec: index=1 width=704 height=576 framerate=30
INFO    16:45:30:297  19568; agora::media::VideoEngine::setCodec: Intra Request = 0
INFO    16:45:30:297  19568; agora::media::VideoEngine::setMaxVideoBitrate: max bitrate=1852000
INFO    16:45:30:297  19568; SetTargetWidthHeight width:704, height:576
INFO    16:45:30:297  19568; AgoraVideoInput::agora::AgoraVideoInput::Start width=704, height=576, fps=30
INFO    16:45:30:297  19568; agora::media::VideoEngine::_startCapture: startCapture success
INFO    16:45:30:297  19568; SetBandwidthAgressiveLevel to 2.
INFO    16:45:30:297  19568; agora::media::VideoEngine::RequestEncodeKeyFrame
INFO    16:45:30:297  19568; agora::media::VideoEngine::doStartLocalRender: init? 1 capture id -1 device 1025 capturing? 1 rendering? 0
INFO    16:45:30:297  19568; agora::media::VideoEngine::doStartLocalRender: local render windows 00000000
INFO    16:45:30:297  19568; AgoraVideoOutput::agora::AgoraVideoOutput::Init thread=0, type=100, view=00000000
ERROR   16:45:30:297  19568; AgoraVideoOutput::agora::AgoraVideoOutput::Init unable to initialize renderer
ERROR   16:45:30:297  19568; agora::media::VideoEngine::doStartLocalRender: failed to initialize local render, view=00000000
INFO    16:45:30:298  19568; [che] start call returns 0, elapsed 12
INFO    16:45:30:298  19568; [time] process EngineStartCall takes 12
INFO    16:45:30:298  19568; setNetEQMinimumPlayoutDelay delay(0)
INFO    16:45:30:298  19568; join channel success: cname 'channel_1' uid 3446614363 elapsed 2335
INFO    16:45:30:298  20784; API call to setupLocalVideo 000F1752
INFO    16:45:30:298  20784; [API] userManagerPendingView: user 0 window 989010
INFO    16:45:30:298  20784; API call to start preview
INFO    16:45:30:298  19568; CacheManager: save cache to storage elapsed 1
INFO    16:45:30:298  19568; [API] userManagerBindUserView: user 0 mode 1 window 989010
INFO    16:45:30:298  19568; agora::media::VideoEngine::doStartLocalRender: init? 1 capture id -1 device 1025 capturing? 1 rendering? 0
INFO    16:45:30:298  19568; agora::media::VideoEngine::doStartLocalRender: local render windows 000F1752
INFO    16:45:30:298  19568; AgoraVideoOutput::agora::AgoraVideoOutput::Init thread=0, type=100, view=000F1752
INFO    16:45:30:298  19568; AgoraRTC::ModuleVideoRenderImpl::ModuleVideoRenderImpl: prefer renderer 1(flags: 0x00000000)
INFO    16:45:30:298  19568; View Info: left=0,top=0,right=800,bottom:600,isVisible=1
INFO    16:45:30:301  20908; [WIN_CORE] IsFormatSupported : nChannels=2, nSamplesPerSec=48000 is supported
INFO    16:45:30:301  20908; [WIN_CORE] VoE selected this rendering format:
INFO    16:45:30:301  20908; [WIN_CORE] wFormatTag         : 0x1 (1)
INFO    16:45:30:301  20908; [WIN_CORE] nChannels          : 2
INFO    16:45:30:301  20908; [WIN_CORE] nSamplesPerSec     : 48000
INFO    16:45:30:301  20908; [WIN_CORE] wBitsPerSample     : 16
INFO    16:45:30:310  20908; [WIN_CORE] render Initialize time 0  hr 0
INFO    16:45:30:310  20908; [WIN_CORE] IAudioClient::GetBufferSize() => 1056 (<=> 4224 bytes)
INFO    16:45:30:310  20908; [WIN_CORE] render side is now initialized
ERROR   16:45:30:311    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717700360
INFO    16:45:30:311   6644; [WIN_CORE] render thread is now registered with MMCSS (taskIndex=907)
INFO    16:45:30:311   6644; [WIN_CORE] [REND] size of buffer       : 1056
INFO    16:45:30:312   6644; [WIN_CORE] [REND] max stream latency   : 0 (0.00 ms)
INFO    16:45:30:312   6644; [WIN_CORE] [REND] device period        : 100000 (10.00 ms)
INFO    16:45:30:312   6644; [WIN_CORE] [REND] initial delay        : 30
INFO    16:45:30:312   6644; [WIN_CORE] [REND] endpointBufferSizeMS : 22.00
INFO    16:45:30:313  20908; [WIN_CORE] rendering audio stream has now started...
INFO    16:45:30:313  20908; output: enabled=0
INFO    16:45:30:313  20908; output: volume=58
INFO    16:45:30:313  20908; => OnWindowsCurrentDeviceChange() : kPlayoutDevice attributes 0
INFO    16:45:30:313  20908; StartPlayout complete
INFO    16:45:30:313  20908; StartSend
INFO    16:45:30:314    696; Thread with name:D2D Render Thread started 
INFO    16:45:30:314  19568; AgoraRTC::VideoRenderWindowsImpl::Init,Render Type:D2D Render,iRet:0
INFO    16:45:30:315  19568; AgoraVideoOutput::agora::AgoraVideoOutput::Start uid=0, stream_id=1025, render_mode=1
INFO    16:45:30:315  19568; AgoraRTC::IncomingVideoStream::SetStreamListener running for stream 0
INFO    16:45:30:315  19568; [che] onVideoFrameFrozen: uid 0, frozen false
INFO    16:45:30:315   6420; Thread with name:IncomingVideoStreamThread started 
INFO    16:45:30:315  19568; agora::media::VideoEngine::doStartLocalRender success
INFO    16:45:30:315  19568; [rp] {"rtc.video.preview":true}
ERROR   16:45:30:316  19568; API call failed to start video preview due to not in idle mode
INFO    16:45:30:317  20908; [WIN_CORE] Audio Engine's current mix format for capturing shared-mode streams:
INFO    16:45:30:317  20908; [WIN_CORE] wFormatTag     : 0xFFFE (65534)
INFO    16:45:30:317  20908; [WIN_CORE] nChannels      : 2
INFO    16:45:30:317  20908; [WIN_CORE] nSamplesPerSec : 48000
INFO    16:45:30:317  20908; [WIN_CORE] wBitsPerSample : 32
INFO    16:45:30:317  20908; [WIN_CORE] IsFormatSupported : nChannels=2, nSamplesPerSec=48000 is supported
INFO    16:45:30:317  20908; [WIN_CORE] VoE selected this capturing format:
INFO    16:45:30:317  20908; [WIN_CORE] wFormatTag        : 0x1 (1)
INFO    16:45:30:317  20908; [WIN_CORE] nChannels         : 2
INFO    16:45:30:317  20908; [WIN_CORE] nSamplesPerSec    : 48000
INFO    16:45:30:317  20908; [WIN_CORE] wBitsPerSample    : 16
ERROR   16:45:30:344    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717703060
INFO    16:45:30:346  20908; [WIN_CORE] capture Initialize time 0  hr 0
INFO    16:45:30:346  20908; [WIN_CORE] IAudioClient::GetBufferSize() => 1056 (<=> 4224 bytes)
INFO    16:45:30:346  20908; [WIN_CORE] capture side is now initialized
INFO    16:45:30:348  17080; [WIN_CORE] [CAPT] size of buffer       : 1056
INFO    16:45:30:348  17080; [WIN_CORE] [CAPT] size of sync buffer  : 8448 [bytes]
INFO    16:45:30:348  17080; [WIN_CORE] [CAPT] max stream latency   : 0 (0.00 ms)
INFO    16:45:30:349  17080; [WIN_CORE] [CAPT] device period        : 100000 (10.00 ms)
INFO    16:45:30:349  17080; [WIN_CORE] [CAPT] extraDelayMS         : 10.00
INFO    16:45:30:349  17080; [WIN_CORE] [CAPT] endpointBufferSizeMS : 22.00
INFO    16:45:30:349  20908; [WIN_CORE] capture audio stream has now started...
INFO    16:45:30:350  20908; output: enabled=0
INFO    16:45:30:350  20908; => OnWindowsCurrentDeviceChange() : kRecordingDevice micBoost 503319040 max: 30.0 min:  0.0 step: 10.0 level:  0.0 volume:240
INFO    16:45:30:350  20908; StartRecording complete
INFO    16:45:30:350  20908; Application Config module:  Route 0, NS on, AEC on, AGC on, BSS off, HC off
INFO    16:45:30:350  20908; MID = 0, Routing = 0
INFO    16:45:30:350  20908; output: kWindowsCoreAudio
INFO    16:45:30:350  20908;   Output: audioLayer=2
INFO    16:45:30:350  20908; output: volume=255
INFO    16:45:30:350  20908; output: enabled=0
INFO    16:45:30:350  20908; output: enabled=0
INFO    16:45:30:351  20908; output: enabled=0
INFO    16:45:30:352  19568; [ch0] rtt: 53
ERROR   16:45:30:377    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717705760
INFO    16:45:30:380  19568; TRACER: onFirstLocalAudioFrame codec 77 elapsed 2417
ERROR   16:45:30:408    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717708460
ERROR   16:45:30:439    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717711160
ERROR   16:45:30:470    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717713860
ERROR   16:45:30:501    688; agora::media::VideoEngine::DeliverFrame: Error preprocessing frame 3717716560

代码没多少,我按快速开始“视频互动”的“快速开始”写的,后面加上了自采集。

建议先将demo跑通一下,这里调试不了,有报什么错吗?
onCaptureVideoFrame是裸数据的接口的,你现在想要做什么处理?一般不建议调用该接口去做处理。建议使用 pushVideoFrame接口去处理。

没有报错,有没有pushVideoFrame的demo,Advanced-Video-master这样的demo里没有用到pushVideoFrame

demo 用的是 PushVideoPackage
lpPackageQueue->PushVideoPackage(m_lpYUVBuffer, nYUVSize);