[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Directshow subtitles (preferably anti-aliased)

Posted on 2005-03-21
8
Medium Priority
?
906 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
  • 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
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…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses

590 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