Skip to main content

directshow_video_mixer

Video Mixer / Picture-in-Picture

This document describes the DirectShow filter configuration for the nanocosmos Video Mixer 2.

See also the [[livevideo_encoder-_overlay_mixing|nanoStream API for the VideoMixer]]

Requirements:

  • DirectShow architecture / C++
  • Nanocosmos Video Mixer 2 Filter

Picture-in-picture mode for 2 video inputs

This short C++ example code shows how to configure the Video Mixer to show video 2 in the right top corner of video 1.

// {0ED06AB0-B2F3-421b-BA63-2E591C932802}
static const GUID CLSID_nanoVideoMixer2 = { 0xed06ab0, 0xb2f3, 0x421b, { 0xba, 0x63, 0x2e, 0x59, 0x1c, 0x93, 0x28, 0x2 } };

// {2140722A-9F1E-4ac7-8A81-CF77CA6DD683}
static const GUID IID_IVideoPlacement = { 0x2140722a, 0x9f1e, 0x4ac7, { 0x8a, 0x81, 0xcf, 0x77, 0xca, 0x6d, 0xd6, 0x83 } };

CComPtr<IBaseFilter> m_pVideoMixer;
m_pVideoMixer.CoCreateInstance(CLSID_nanoVideoMixer2);

// target area picture-in-picture: right top corner of picture 1
RECT rcTarget = {m_VideoWidth * 7/10, m_VideoHeight*1/20,
m_VideoWidth * 9/20, m_VideoHeight * 3/10};

CComQIPtr <IVideoPlacement> api = m_pVideoMixer;
if (api){
api->SetVideoFrameDuration( (REFERENCE_TIME)(10000000LL / m_VideoFrameRate) );
api->SetOutputSize(m_VideoWidth, m_VideoHeight);
RECT rc = {0,0, m_VideoWidth, m_VideoHeight};
api->SetVideoPosition(0, &rc);
api->SetVideoPosition(1, &rcTarget);
return 0;
}