如何从 Windows Store 应用程序中的视频中获取缩略图?

编程入门 行业动态 更新时间:2024-10-28 18:30:51
本文介绍了如何从 Windows Store 应用程序中的视频中获取缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我目前正在开发一款具有录制视频功能的应用.我知道如何录制视频并将其保存在应用程序的 localFolder 中.我的问题是我需要在用户录制视频后向他显示缩略图.因此,为此我想从录制的视频中提取第一帧.最终视频存储在 StorageFile 对象中,但我不知道如何从 StorageFile 对象获取图像.

I am currently working on an app in which there is feature to record video. I am aware about how to record the video and save it in localFolder of app. My problem is that I need to show a thumbnail to user after he records the video. So, for that I want to extract the first frame from the recorded video. The final video is stored in StorageFile object but I am not aware how to get image from StorageFile object.

请任何人都可以建议一些示例代码我该怎么做.我正在使用默认的 Camera API 来录制视频.我的代码在下面

Please can anyone suggest with some sample code how can I do that. I am using default Camera API for recording video. My code is below

private async void CaptureVideo()
{
    CameraCaptureUI cameraUI = new CameraCaptureUI();
    cameraUI.VideoSettings.Format=CameraCaptureUIVideoFormat.Mp4;
    cameraUI.VideoSettings.MaxDurationInSeconds = 10;
    StorageFile capturedVideo = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Video);
    string videoName="video_" + GetDateTimestamp() +".mp4";
    if(capturedVideo !=null)
    {
        saveVideoandShowThumbnail(capturedVideo, videoName);
    }
}

这里的saveVideoandShowThumbnail()方法是将视频保存在Videos文件夹中并生成缩略图.

Here in saveVideoandShowThumbnail() method is to store the video in Videos Folder and generate the thumbnail.

推荐答案

StorageFile.GetThumbnailAsync() 解决了我的问题.我尝试使用以下代码显示视频中的图像.希望对某人有帮助

StorageFile.GetThumbnailAsync() solved my issue. I tried to show image from video using below code. Hope it helps someone

bitmap = new BitmapImage();
bitmap.SetSource(await videoFile.GetThumbnailAsync(ThumbnailMode.SingleItem));

这篇关于如何从 Windows Store 应用程序中的视频中获取缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 18:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1120989.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缩略图   应用程序   视频   Windows   Store

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!