开发者

Video thumbnails in WPF

开发者 https://www.devze.com 2023-01-30 00:40 出处:网络
I\'m trying to add videos to my WPF project, but I can\'t find a proper solution for generating previews/thumbnails of the video. A lot of solutions on the internet mention you should play and then pa

I'm trying to add videos to my WPF project, but I can't find a proper solution for generating previews/thumbnails of the video. A lot of solutions on the internet mention you should play and then pause the video in code behind. I don't really like that solution especially because it gets very messy in combination w开发者_C百科ith the MVVM structure of our project.

Another solution I thought of is generating a screenshot from the video and display that screenshot instead of the video, but I also have no success in creating the screenshots.

How do you guys show thumbnails of your videos?


You do this by setting the MediaPlayer's property of ScrubbingEnabled to true and still you need to move forward to capture any movie at real time.

For more samples, please read this nice blog entry by Clint Rutkas:

http://www.betterthaneveryone.com/archive/2009/10/02/882.aspx


You can use ffmpeg.exe to generate thumbnail for your video as a jpg file,

ffmpeg  -itsoffset -4  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg

Which is simpler way to do it, because by default we only show Thumbnail image and media element is hidden or inactive, and only when we click on it, we start playing the video. This also improves resource usage as media element is heavy if you are displaying multiple videos.

0

精彩评论

暂无评论...
验证码 换一张
取 消