rd.mediaProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p); rd.mediaProfile.Video.Width = firstImageWidth; rd.mediaProfile.Video.Height = firstImageHeight; var saveOperation = Composition.RenderToFileAsync(save_file, MediaTrimmingPreference.Precise, mediaProfile);
这是很正常的,因为如果使用图片生成视频,
MediaClip clip = await MediaClip.CreateFromImageFileAsync(ImageList[i].file, ImageList[i].FrameTimeSpan);
并想要生成和图片大小一致的视频,但是这个算法要求图片的尺寸必须是偶数.
否则报错:MediaEncodingProfile Must have a valid width or height
这应该是MediaEncodingProfile的注意事项.
什么时候图片尺寸不是偶数,比如手动屏幕截图的时候,说不定就是奇数,解决方式就是尺寸+1了