5

I'd like to insert subtitle into the media file without using Library that provides it automatically(Like a DirectShow)

I used way to draw by using window desktop's drawing handle, but it couldn't work. I think it is because of the speed of update... right? Anyway, is there any function or method to paint over a media file or get their overlay handle?

    [DllImport("user32.dll")]
    static extern IntPtr GetDesktopWindow();

    [DllImport("user32.dll")]
    static extern IntPtr GetDCEx(IntPtr hwnd, IntPtr hrgn, uint flags);

    [DllImport("user32.dll")]
    static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);

    public void SubtitleDraw()
    {
        IntPtr hWnd = GetDesktopWindow();
        IntPtr hDc = GetDCEx(hWnd, IntPtr.Zero, 1027);

        Font font1 = new Font("Times New Roman", 24, FontStyle.Regular,GraphicsUnit.Pixel);    
        Point pt = new Point(40, 375);

        PointF pointF1 = new PointF();
        pointF1 = PlayerForm.ActiveForm.PointToScreen(pt);

        Graphics g = Graphics.FromHdc(hDc);
        g.DrawString(SubtitleText, font1, Brushes.Black, pointF1);

        ReleaseDC(hWnd, hDc);
    }
4

1 回答 1

0

You're going to want to research DirectShow and filters if you want to draw on top of a video while playing at any decent framerate. There is some scattered documentation out there for how to interact with DirectShow filter graphs from .NET, but it's pretty scarce.

If you have a video playing in a media control, it will almost always be playing the video in an overlay, so anything you draw "on top" of it will be on top of the control, but still beneath the "overlay" where the real video is playing.

于 2013-04-10T08:15:20.910 回答