EVR: transparent textout on video window
On the form the button, trackbar, the panel (panel1 - the successor from tpanel + is added canvas, align=client), I start video through EVR on the panel (tpanel)
...
FGraph: IGraphBuilder;
FEVR: IBaseFilter;
FDisplayC开发者_如何学运维ontrol: IMFVideoDisplayControl;
...
OnBtnclik>>
if not Succeeded (CoCreateInstance (CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, FGraph)) then Exit;
if not Succeeded (CoCreateInstance (CLSID_EnhancedVideoRenderer, nil, CLSCTX_INPROC, IID_IBaseFilter, FEVR)) then Exit;
FGraph. AddFilter (FEVR, 'EVR');
(FEVR as IMFGetService).GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, FDisplayControl);
FDisplayControl. SetVideoWindow (Panel1.Handle);
UpdateEvr; // resize
FGraph. RenderFile (PWideChar ('c:\video\myvideo.avi'), nil);
FDisplayControl. SetAspectRatioMode (0);
...
OntrackbarChange>>
...
with panel1.Canvas do
begin
Font. Color: = cllime;
Brush. Style: = bsclear;
Font. Size: = 20;
TextOut (10, 10, ' TRANSPARENT TEXT ');
end;
The text is displayed, but flickers. How to deduce the normal transparent text on panel1 during video playing?
CG.E.Rad 2010
It seems odd to me that you are painting during the track bar change event. Why don't you paint in an overridden Paint
method? That would allow you to do double-buffering if all other attempts at flicker reduction failed.
That said, I'd probably avoid custom painting if possible. I'd use a TLabel
to display the text and it will paint as part of the paint cycle. If you still had flicker problems then you might find TStaticText
flickers less that TLabel
.
I think your problem is caused by the DirectShow engine drawing the video on top of your label. You are "re-freshing" your label when you paint it on the track bar event, but the refresh rate of the video playpack will never be the same as your track bar events, so the flickering occurs. I think there is no way of getting this approach to work. I recommend to take a look in the sample code "Text" and "Text9" on Summer 2004 DirectX DSK Update as stated in the following post: http://www.eggheadcafe.com/software/aspnet/32121970/placing-text-overlay-on-direct-show-video.aspx Those sample codes are written in C++, but it should not be too difficult to translate them to Delphi.
http://www.delphibbs.com/keylife/iblog_show.asp?xid=33152
in procedure TEVR9Demo.VideoPlay;
first step - add:
image1.canvas.Brush.Color:=clblack;
image1.Canvas.FloodFill(10,10,clblack,fsborder);
image1.Canvas.FloodFill(10,10,clblack,fsSurface);
image1.Canvas.Font.Color:=cllime;
image1.Canvas.Font.Size:=24;
image1.Canvas.Brush.Style := bsclear;
image1.Canvas.TextOut(10,10,'TRANSPARENT TEXT EXAMPLE');
e!!!
精彩评论