Discussion:
How can I add text/line on the video using C# AudioVideoPlayback.V
(too old to reply)
Haley
2005-03-31 16:59:02 UTC
Permalink
Hi, All:

I play video using AudioVideoPlayback.Video in C#. I need to draw some
markups on the video. How can I do this? I tried the following code. But once
the function RenderToTexture() is called, I noticed several important
properties (AverageTimePerFrame, etc.) in the video object is missing. Even
after I work around this, the video shown in the event handler
video_TextureReadyToRender() is corrupted and does not advance. Please help.

Thank you.

=========
private void LoadVideo()
{
PictureBox box = new PictureBox();
Video video = new Video(video_path);

PresentParameters present_parameters = new PresentParameters();
present_parameters.Windowed = true;
present_parameters.DeviceWindow = box;
present_parameters.PresentFlag = PresentFlag.Video;
present_parameters.SwapEffect = SwapEffect.Flip;

Device graphics_device = new Device(0, DeviceType.Hardware, box,
CreateFlags.HardwareVertexProcessing, present_parameters);

video.RenderToTexture(graphics_device);
video.TextureReadyToRender +=
new TextureRenderEventHandler(video_TextureReadyToRender);

video.Play();
}

private void video_TextureReadyToRender(object sender,
TextureRenderEventArgs e)
{
e.Texture.Device.BeginScene();
// Draw text/lines
....
e.Texture.Device.EndScene();
e.Texture.Device.Present();
}

=========
sukhjindernannu
2007-07-17 08:21:16 UTC
Permalink
Hi Haley,
I'm also trying to write text onto a video. Can you tell me the steps
involved in writing text onto a video. I haven't been able to understand the
following
Your Code

//////////////////////////////////
PresentParameters present_parameters = new PresentParameters();
present_parameters.Windowed = true;
present_parameters.DeviceWindow = box;
present_parameters.PresentFlag = PresentFlag.Video;
present_parameters.SwapEffect = SwapEffect.Flip;

Device graphics_device = new Device(0, DeviceType.Hardware, box,
CreateFlags.HardwareVertexProcessing, present_parameters);

video.RenderToTexture(graphics_device);
video.TextureReadyToRender +=
new TextureRenderEventHandler(video_TextureReadyToRender);
/////////////////////////////////////////
Please do let me know of the alternatives if you know any.
Thanks...

Loading...