?
Solved

Directshow subtitles (preferably anti-aliased)

Posted on 2005-03-21
8
Medium Priority
?
864 Views
Last Modified: 2013-12-08
Hi.

I'm writing a simple video player application, and I need to display subtitles and/or other controls (i.e. volume level). I'm using pure directshow from directx9 and windowless mode (at least i think, the video is displayed on a forms canvas). I need to display the subtitles (preferably anti-aliased). I tried to display the subtitles in a second form above the video, but it doesn't work in fullscreen.

Code prefered (delphi or c/c++), but any advice accepted.

Thanks.
0
Comment
Question by:BlueAlien
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 17

Expert Comment

by:davebytes
ID: 13613485
Have you checked out the DX9 DShow samples?  I just found the watermark sample:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/introducingsomenewvideomixingrenderersampleapplica.asp
(click the link to the watermark sample...)

Looks like it does what you are looking for, in terms of you saying "and/or other controls".  The sample should be a good starting point.

You could also ask this guy, if you specifically just want to do subtitles (sounds like there's some form of Subtitle Mixer already built-in to DS):
http://tobias.everwicked.com/

-d
0
 
LVL 8

Expert Comment

by:_corey_
ID: 13619439
Depending on how you need to sync things up, the new VMR9 render filter might do what you want.  it provides an interface to use bitmap overlays and alpha values.

I've had to use a custom filter to draw text over the video stream, but you don't need to put that effort in unless you need that annotated video to save to a file.

corey
0
 
LVL 17

Expert Comment

by:davebytes
ID: 13622603
The Samples page I linked to above gives source examples that should work with both VMR7 and VMR9 -- in theory, if you believe MS. ;)

-d
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BlueAlien
ID: 13628290
Thanks for the advice, but I wont't be able to try them till next week.
0
 

Author Comment

by:BlueAlien
ID: 13662208
I checked out the Watermark sample, but it shows alpha-blending, not anti-aliasing. Though it helps with setting up the wmr9. I would need help with the anti-aliased text.

Thanks.
0
 
LVL 17

Accepted Solution

by:
davebytes earned 1600 total points
ID: 13662988
You said 'preferably'...

First off, this is a bigger process than just one answer, IMHO.  Though, if you had just wanted subtitles, I gave another reference link above.

Second, there are numerous approachs to creating anti-aliased text.  Windows will do it for you if you set up the font properly before rendering to a HDC.  You could also render double-sized (or more), and do a quick downsample filter to proper resolution.

The Text sample on that same page (below the Watermark sample) shows how to do basic text rendering.

To kick it up a notch, you'll want to use your own LOGFONT definition to create a new HFONT to render with.  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_1wmq.asp
refers to the logfont structure.  Note the "lfQuality" field allows specification of antialiasing style.

CreateFontIndirect will take your logfont structure and create the HFONT.  This is a sample:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3r77.asp

If you set the quality field to one of the antialias settings, you should get antialiased text in your bitmap.

That should be it.  I haven't tried this all out in one test, but I've used the antialiasing thing before myself for rendering text into texture maps at high quality...

-d
0
 
LVL 8

Assisted Solution

by:_corey_
_corey_ earned 400 total points
ID: 13663047
As davebytes pointed out, I believe the only way to control aliasing is at the HDC level.  

Here is an example of using a custom font in drawing to an HDC.  I used this when drawing to video in a custom filter.

You will need to set the appropriate anti-aliasing qualities on your own of course.

        LOGFONT lf;

        GetObject(GetStockObject(ANSI_VAR_FONT), sizeof(LOGFONT), &lf);
 
        // Set the font attributes, as appropriate.  
 
        lf.lfWeight = FW_SEMIBOLD;
 
        int heightRatio = (m_nHeight/16) / lf.lfHeight;
        SelectObject(m_DC, CreateFont(m_nHeight/16, lf.lfWidth*heightRatio,
            lf.lfEscapement, lf.lfOrientation, lf.lfWeight,
            lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet,
            lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality,
            lf.lfPitchAndFamily, lf.lfFaceName));

corey
0
 

Author Comment

by:BlueAlien
ID: 14106916
Thanks for the answers and sorry for the late reply.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question