MediaComposition GetThumbnailAsync crashes

0

I try to extract thumbnail from StorageFile using Windows Media Editing API with the following code:

public async Task<IInputStream> GetThumbnailAsync(StorageFile file)
{
    var mediaClip = await MediaClip.CreateFromFileAsync(file);

    var mediaComposition = new MediaComposition();
    mediaComposition.Clips.Add(mediaClip);

    return await mediaComposition.GetThumbnailAsync(
        TimeSpan.Zero, 0, 0, VideoFramePrecision.NearestFrame);
}

But I always get the error below.

The data specified for the media type is invalid, inconsistent, or not supported by this object. (Exception from HRESULT: 0xC00D36B4)

I have tried with different input file formats (avi / mp4 / mov) and smaller or bigger files with no luck.

I know I could extract the thumbnail of the file using StorageFile.GetThumbnailAsync API but this only works for the very first frame. And I need to be able to extract any arbitrary frame from the video file. So MediaComposition API seems to be able to deliver what I need.

uwp
windows-10-universal
asked on Stack Overflow Jan 29, 2016 by aguyngueran

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0