Click here to Skip to main content
Click here to Skip to main content
Go to top

Ticker ( Showing or Scrolling Text Over Running Video )

, 26 Sep 2006
Rate this:
Please Sign up or sign in to vote.
This article tells how you can show your text over video, change text, text color, text background color and its transparency.
Sample Image - Ticker.jpg

Introduction

Showing something over running video? You can see my previous article to show an image over video. But this time, I am going to do some more artwork or text work over running video.

Ticker

Displaying text over video? This project has some similarities with my previous project, but it is not much similar. Here the text also scrolls over video.

Prerequisite

It is a prerequisite to read my article which displays image over video. This is because in that article, I have explained everything which is required to display an image over video, and displaying the text is not much different. So here in this article, I will just stick to the working code which is needed to display text over video.

Prepare the Ground with IVMRMixerControl9

First of all we need to set some preferences for mixing. Because the default mixing preferences are not good for blending the text over video, in the code below I am doing the same:

// Request point filtering (instead of bilinear filtering)
// to improve the text quality. In general, if you are
// not scaling the app Image, you should use point filtering.
// This is very important if you are doing source color keying.
pVmr->QueryInterface(IID_IVMRMixerControl9, (void**)&pMix);
DWORD dwPrefs=0;
pMix->GetMixingPrefs(&dwPrefs);
dwPrefs |= MixerPref_PointFiltering;
dwPrefs &= ~(MixerPref_BiLinearFiltering);
pMix->SetMixingPrefs(dwPrefs);

Preparing the Image From Text

Now we need to make the image having the text we want to show over video.

CDC * pdc = GetDC(); 
CDC mCompatibleDC;
mCompatibleDC.CreateCompatibleDC(pdc);
mCompatibleDC.SelectObject(mFont);
CSize strSize = mCompatibleDC.GetTextExtent(strFinish);
CBitmap bm;
bm.CreateCompatibleBitmap(pdc,strSize.cx,strSize.cy);
mCompatibleDC.SelectObject(&bm);
mCompatibleDC.SetBkColor(mBK_Color);
mCompatibleDC.SetTextColor(mTXT_Color);
mCompatibleDC.TextOut(0,0,strFinish);

Showing the Text Over Video

Now we will prepare for showing the image with text over video.

VMR9AlphaBitmap bmpInfo;
ZeroMemory(&bmpInfo, sizeof(bmpInfo) );
bmpInfo.dwFlags |= VMRBITMAP_HDC;
bmpInfo.hdc = pDC->m_hDC;
LONG cx, cy;
pWC->GetNativeVideoSize(&cx, &cy, NULL, NULL);
bmpInfo.rSrc = Rect;
// rDest specifies the destination rectangle in composition space (0.0f to 1.0f)
bmpInfo.rDest.right = 1.0f;
bmpInfo.rDest.left = 0.0f;
bmpInfo.rDest.top = (float)(cy - Rect.Height()) / (float)cy - EDGE_BUFFER;
bmpInfo.rDest.bottom = 1.0f - EDGE_BUFFER;
// Set the transparency value (1.0 is opaque, 0.0 is transparent).
bmpInfo.fAlpha = 1.0;
pBmp->SetAlphaBitmap(&bmpInfo);

All is done. Now you can blend any text over video.

More Info

If you are interested in more information, see my blog.

History

  • 26 Sep 2006 First version

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

tanvon malik

Pakistan Pakistan
tanvon malik ( real name Tanveer Ahmad )I am a CNC Programmer, cnc setter, cnc operator. want to know about me visit my blog.
CNC Programming Blog
 
Reach Me
cnc blog | facebook | twitter | linkedin | flickr | google+
 
I been in Switzerland MAG former +FMS+ for CNC training.
 

Most interesting technologies I like COM MFC DirectShow such as filter development. I am from Pakistan.
Have worked on projects mostly related video capturing, video data processing and real time object tracking on videos. For these I have worked on projects which use "Open CV Library". Which is mostly used for capturing data and its processing.
 
my vc++ blog tanvon++
my blog about DirectShow in my national language URDU DirectShow.wordpress.com
and below is the place where we discuss DirectShow and VC++
http://groups.yahoo.com/group/tanvon
Follow on   Twitter

Comments and Discussions

 
QuestionMy voite is 1 PinmemberGreg_moon28-Jul-12 22:15 
QuestionCan i get same project in C# [modified] PinmemberMember 435287523-Sep-10 2:43 
GeneralDownload problem PinmemberMember 461091624-Feb-10 21:16 
QuestionOverlay text in External Video Renders Pinmemberkannan1237-Mar-09 6:27 
Generalfixed size text display on video Pinmemberyorawat12-Jan-09 22:15 
QuestionWhat if the source is not a video file. PinmemberTaran930-Sep-08 21:32 
Questionhow to overlay multiple text on video Pinmembermythili29-May-08 2:00 
AnswerRe: how to overlay multiple text on video PinmemberMember 34640464-Jun-08 0:45 
GeneralRe: how to overlay multiple text on video Pinmembermythili9-Jun-08 18:34 
GeneralRe: how to overlay multiple text on video Pinmembermythili11-Jun-08 3:45 
Generalerror in creating vmr filter Pinmembersan07618-Mar-08 19:09 
Questionhow can I use "CLSID_VideoMixingRenderer9" in smart device project. PinmemberSuman Kumar Sikdar9-Apr-07 19:33 
QuestionC# PinmemberMario_F13-Dec-06 12:43 
AnswerRe: C# Pinmemberieremix9-Jan-07 10:03 
GeneralDoesn't Compile in Visual C++ Express 2005 PinmemberreginaldStjohn13-Dec-06 6:28 
GeneralRe: Doesn't Compile in Visual C++ Express 2005 Pinmembertanvon malik6-Sep-08 22:14 
Generalthanks Pinmembershital_harode@rediffmail.com31-Oct-06 22:15 
GeneralRe: thanks Pinmembertanvon malik6-Sep-08 21:53 
Generaltext over video Pinmembershital_harode@rediffmail.com30-Oct-06 22:44 
GeneralRe: text over video Pinmembertanvon31-Oct-06 2:17 
GeneralRe: text over video PinmemberJaneYan6-Feb-07 15:22 
GeneralRe: text over video Pinmembertanvon malik6-Sep-08 22:13 
GeneralYou might want to reload your demo project Pinmemberfwsouthern27-Sep-06 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 26 Sep 2006
Article Copyright 2006 by tanvon malik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid