Haley
2005-03-31 16:59:02 UTC
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();
}
=========
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();
}
=========