【问题标题】:Convert Matlab matrix into video file将 Matlab 矩阵转换为视频文件
【发布时间】:2013-10-16 19:17:57
【问题描述】:

如何将矩阵转换为视频文件?特别是 yuv 格式。或者先将其转换为 .avi,然后再转为 yuv。有没有人有这方面的代码?它最初是一个 .avi 文件,然后我将所有帧提取到一个数组或结构中。

我在堆栈溢出时发现并使用了它。我在 Matble [高度宽度 Y/U/V numberOfFrames] 中创建了一个 4D 结构。我正在使用 qcif 所以它的大小是 [176 144 3 150] 但创建的视频是错误的。 (全白)要先转成RGB吗?

Orig; % 3D matrix
X = permute(Orig,[1 2 4 3]); % 4D matrix
movie = immovie(X,map); % map is the colormap you want to use

implay(movie);

另外,在我的程序中,最初的 YUV 文件首先被转换为 avi。所以我的帧结构来自一个 avi 文件。

【问题讨论】:

标签: matlab video-processing yuv


【解决方案1】:

我觉得应该是这样的:

aviobj = avifile('example.avi','compression','None');

for frame = 1:size(M, 4)
    aviobj = addframe(aviobj, M(:,:,:,frame); %// This is assuming your image is a vector of RGB images. If it's a vector of indexed images then drop one : and make the loop go to size(M,3)
end

aviobj = close(aviobj);

【讨论】:

    猜你喜欢
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-28
    • 2017-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多