MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何使用Matlab从yuv 420视频剪辑中提取帧并将其存储为不同的图像? (https://www.labfans.com/bbs/showthread.php?t=23847)

poster 2019-12-10 20:48

如何使用Matlab从yuv 420视频剪辑中提取帧并将其存储为不同的图像?
 
如何从yuv 420视频中提取帧?假设我想将它们存储为静止图像。怎么样?



[B]回答:[/B]

这是[URL="http://www.mathworks.com/matlabcentral/fileexchange/"]MathWorks File Exchange[/URL]提交的内容,应该可以完成您想要的操作:
[LIST][*]通过[URL="http://www.mathworks.com/matlabcentral/fileexchange/authors/16240"]Da Yu[/URL] [URL="http://www.mathworks.com/matlabcentral/fileexchange/6318-convert-yuv-cif-420-video-file-to-image-files"]将YUV CIF 4:2:0视频文件转换为图像文件[/URL][/LIST]上面提交的函数loadFileYuv将加载YUV文件并返回电影帧数组。每个电影帧都是具有以下字段的结构:
[LIST][*] cdata : uint8值的矩阵。尺寸为高×宽×3。[*] colormap :N×3的双精度矩阵。在真彩色系统上为空。[/LIST]因此,您可以从数组中的每个影片帧提取cdata字段,并将其保存/用作RGB图像。

您的代码可能看起来像这样:

nFrames = 115; %# The number of frames vidHeight = 352; %# The image height vidWidth = 240; %# The image width mov = loadFileYuv('myVideo.yuv',vidHeight,vidWidth,1:nFrames); %# Read the file for k = 1:nFrames %# Loop over the movie frames imwrite(mov(k).cdata,['myImage' int2str(k) '.bmp']); %# Save each frame to %# a bitmap image file end

[url=https://stackoverflow.com/questions/3614441]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 08:35

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.