如何从 matlab 生成没有编解码器错误的视频?
使用我的 Windows 7 64 位机器,我尝试使用以下序列从 Matlab 生成 avi 文件
aviobj = avifile('test.avi', 'fps', 25);
% a loop of aviobj = addframe(aviobj, frame)
close(aviobj)
但是,生成的文件已损坏 - 使用 VLC 时,它看起来被剪切并且颜色很差,使用媒体播放器时它是黑屏,并且使用Divx Plus 播放器看起来不错,但会生成警告。
我尝试指定其他编解码器类型(通过 avifile('test.avi', 'fps', 25, 'compression', 'TYPE'
),但 Matlab 似乎永远无法找到该编解码器- 我尝试过 Indeo、cvid、MSVC 和 MRLE 等,但 Matlab 只是生成“不支持的压缩方法”警告,然后在调用 addframe
时彻底失败
。我可以解决上述问题吗?或者,是否有一种不同的、简单的方法通过一次添加一帧来生成 avi?
Using my Windows 7 64bit machine, I'm trying to generate an avi file from Matlab using the sequence
aviobj = avifile('test.avi', 'fps', 25);
% a loop of aviobj = addframe(aviobj, frame)
close(aviobj)
However, the file generated is corrupt - with VLC it looks sheared and with bad colors, with Media Player it was a black screen, and with Divx Plus player it looks okay but generates a warning.
I've tried specifying other codec types (via avifile('test.avi', 'fps', 25, 'compression', 'TYPE'
) but Matlab never seems to be able to find that codec - I've tried Indeo and cvid and MSVC and MRLE and many more, but Matlab just generates a "not a supported compression method" warning, and then outright fails when addframe
is invoked.
How can I solve the above problem, or alternatively, is there a different, simple way to just generate an avi by adding a frame at a time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如何从 matlab 生成没有编解码器错误的视频?
尝试使用 mmwrite
http://www.mathworks.com/matlabcentral/fileexchange/15881-mmwrite
How to generate a video from matlab without codec errors?
try to use mmwrite
http://www.mathworks.com/matlabcentral/fileexchange/15881-mmwrite
经过几次在线搜索和实验后,看起来其他人也遇到了这个问题,并建议使用不同的程序来压缩它,这也应该修复文件,所以这就是我所做的:
现在在我尝试过的所有播放器中看起来都是正确的,并且文件大小更小。
Well after a few more searches online and experimentation, looks like others have encountered this problem as well, and suggested just using a different program to compress it and that should also fix the file, so that's what I did:
It now looks correct in all the players I've tried, and the file is smaller in size.
您所描述的 VLC 中发生的情况可能与编解码器不支持的分辨率有关。尝试使用
2,4,8,16
倍数的分辨率,看看效果如何。 VirtualDub 可能会以某种方式解决这个问题。否则真的很简单。你所要做的就是:
What you are describing what happens in VLC is probably related to having a resolution that is not supported by the codec. Try resolutions that are multiples of
2,4,8,16
and see what works. VirtualDub probably takes care of that somehow.Otherwise it's really simple. All you have to do:
我知道我正在回复一个非常旧的帖子,但我帮助了我的兄弟,并学到了一些可能对其他人有帮助的东西:
我的兄弟有一个非常小的视频,是 MRI 扫描的结果,51x51 像素。使用具有“未压缩 AVI”配置文件的 VideoWriter 可以工作,但在 VLC 中播放效果不佳。 Virtualdub 也抛出错误。
解决这个问题的方法是确保视频尺寸是 2 的倍数。
96x96 视频播放效果良好,还可以在 virtualdub 中转码为 XVID。
另外,对于非常小的视频,请在 VLC 中将视频输出模式设置为 wingdi。使用 OpenGL 或 Direct3D 和叠加模式,GPU 将进行缩放并在其间插入像素。
I know I am replying to a very old thread, but I helped my brother with this and learned a few things that might help others:
My brother had a very small video, the result of an MRI scan, 51x51 pixels. Using VideoWriter with profile "Uncompressed AVI" worked, but did not play well in VLC. Virtualdub also threw errors.
What fixed it, is making sure that the video dimensions where a multiple of 2.
A 96x96 video played fine and could also be transcoded to XVID in virtualdub.
Also, with very small videos, set the video output mode to wingdi in VLC. With OpenGL or Direct3D and overlay mode, the GPU will do the scaling and interpolate pixels in between.