从帧创建视频
creating a video from frames
在我的Windows通用应用程序中,我正在尝试使用WinRT组件:http://blogs.msdn.com/b/eternalcoding/archive/2013/03/06/developing-a-winrt-component-to-create-a-video-file-using-media-foundation.aspx(基本上是sinkWriter的C++包装器)
以创建带有帧的视频。
我将所有这些代码放在一个C++项目中,我可以毫无问题地从我的 C# 代码调用它。
问题首先出在构造函数上:
HRESULT CVideoGenerator::InitializeSinkWriter(Windows::Storage::Streams::IRandomAccessStream^ stream)
我不确定如何创建流:
var filename = "exportedVideo.wmv";
var folder = Windows.Storage.KnownFolders.VideosLibrary;
StorageFile storageFile = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.ReadWrite);
StorageFile file = await StorageFile.GetFileFromPathAsync(App.PhotoModel.Path);
CVideoGenerator videoGenerator = new CVideoGenerator(1280, 720, stream, 20);
另一件事来自这一行:
hr = sinkWriter->SetInputMediaType(streamIndex, mediaTypeIn, NULL);
//hr 0xc00d5212 : No suitable transform was found to encode or decode the content. HRESULT
有什么想法吗?
我使用了这个视频生成器示例,并遇到了同样的问题。我不是媒体基金会的专家,但经过一些研究,我发现问题出在这些方面:
encodingFormat = MFVideoFormat_WMV3;
inputFormat = MFVideoFormat_RGB32;
好吧,我用第二种格式替换了第一种格式,如下所示:
encodingFormat = MFVideoFormat_RGB32;
inputFormat = MFVideoFormat_RGB32;
它似乎一直有效,直到WriteSample
方法中的新异常
hr = MFCopyImage(
pData, // Destination buffer.
cbWidth, // Destination stride.
(BYTE*)videoFrameBuffer, // First row in source image.
cbWidth, // Source stride.
cbWidth, // Image width in bytes.
videoHeight // Image height in pixels.
);
显然是在内存中写入时访问冲突。还在努力弄清楚!
麦克西姆
相关文章:
- 使用 OpenCV C++ 每 1 分钟创建新的视频文件
- 创建可用的H.264视频文件
- OPENCV从Yuyv Pixelformat视频框架创建YUV420或灰度垫子对象
- 使用最新的 ffmpeg API (2017) 创建视频
- 使用C++创建带有“自定义”捕获器的WebRTC视频轨道
- 如何使用AvConv创建灰度视频
- 如何使用avcodec从OpenCV::Mat类型的jpeg图像创建视频
- 开放框架,从两个视频采集卡创建视频纹理
- 使用 QT 创建器在 c++ 中播放视频
- 使用ffmpeg创建视频
- Qml视频创建从C++的图像流
- 从多个视频部分创建单个视频文件
- 从帧创建视频
- C ++从多个视频文件创建1个视频
- 在由 createdesktop() 创建的新桌面中播放视频
- 如何在Qt创建器中的Qt小部件应用程序中播放本地视频
- 使用QT Creator-C++中的QPixmap序列创建视频文件
- DirectShow过滤器图形使用WMASFWriter创建视频太短
- 如何从磁盘加载Jpeg图像并创建视频文件?Avi等),而无需在c++中使用opencv
- Qt创建视频/AVI文件从小部件