Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

How to capture a thumbnail image of a video? RSS

4 replies

Last post Aug 24, 2011 06:06 AM by Daphne57

(1)
  • Aaadi

    Aaadi

    Member

    42 Points

    35 Posts

    How to capture a thumbnail image of a video?

    Apr 14, 2008 06:35 AM | LINK

    Hi,

    How to capture a thumbnail image of a video in SilverLight 2 ?

     Thanks

     

    Silverligh 2 Bet

    Adi
    Software Engineer
    Softech Worldwide LLC
  • Yi-Lun Luo - MSFT

    Yi-Lun Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: How to capture a thumbnail image of a video?

    Apr 16, 2008 05:02 AM | LINK

    Hello, you can't do that in Silverlight. You'll have to do that on the server. The simplest way to capture capture a screen shoot is using WPF's RenderTargetBitmap. You will of course need .NET 3.0 or above on the server. Then in your web service application, you can use Process.Start method to start a WPF application. In the WPF application, you can write something like this:

    private MediaPlayer player = new MediaPlayer();

     

    private void Window_Loaded(object sender, RoutedEventArgs e)

    {

    VideoDrawing vd = new VideoDrawing();

    player.Open(new Uri("expressionstudio.wmv", UriKind.Relative));

    vd.Rect = new Rect(0, 0, 300, 300);

    vd.Player = player;

    player.MediaOpened +=
    new EventHandler(player_MediaOpened);

    player.Play();

    //You may want to pass a parameter to the WPF application to indicate which frame you want to capture.

    player.Position =
    TimeSpan.FromSeconds(30);

    }

     

    void player_MediaOpened(object sender, EventArgs e)

    {

    DrawingVisual drawingVisual = new DrawingVisual();

    DrawingContext drawingContext = drawingVisual.RenderOpen();

    drawingContext.DrawVideo(player, new Rect(new Point(0, 0), new Point(300, 300)));

    drawingContext.Close();

    RenderTargetBitmap rtb = new RenderTargetBitmap(300, 300, 96, 96, PixelFormats.Pbgra32);

    rtb.Render(drawingVisual);

    //Do whatever you want with this bitmap and then shutdown the WPF application.

    player.Stop();

    App.Current.Shutdown();

    }

    You can also try to use the WPF APIs directly in the web service application. But I haven't tested that.

    shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
  • Zenuke

    Zenuke

    Member

    50 Points

    61 Posts

    Re: How to capture a thumbnail image of a video?

    Dec 20, 2008 11:15 PM | LINK

    Is there any way to elaborate on this anymore or does anyone els ehave an incite?

  • Miyamoto

    Miyamoto

    Member

    90 Points

    112 Posts

    Re: Re: How to capture a thumbnail image of a video?

    Dec 30, 2008 05:35 AM | LINK

    Yi-Lun Luo --

    Thanks very much.  I'm using a web hosting service (DiscountASP.NET).  Do you think this would work there?

    Thanks for your help.

    Miyamoto
  • Daphne57

    Daphne57

    Member

    4 Points

    2 Posts

    Re: How to capture a thumbnail image of a video?

    Aug 24, 2011 06:06 AM | LINK

    It's easy, just use some screen recorder can help you capture pictures from video. It can record whatever on your screen as video file, you just need to play the video on your computer screen, and it will help you record image of the video. And it also can help you save the image to standard format file.