本文介绍了如何从yuv 420视频剪辑中提取帧并使用matlab将它们存储为不同的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从yuv 420视频中提取帧?假设我想将它们存储为静止图像。如何?

How do I extract the frames from a yuv 420 video? Let's say i want to store them as still images. How?

推荐答案

以下是来自应该做你想做的事情:

Here's a submission from the MathWorks File Exchange that should do what you want:


  • $文件到图像文件 b $ b

上面提交的函数 loadFileYuv 将加载YUV文件并返回一组电影帧。每个电影帧都是一个包含以下字段的结构:

The function loadFileYuv from the above submission will load a YUV file and return an array of movie frames. Each movie frame is a structure with the following fields:


  • cdata :矩阵 uint8 的值。尺寸是按宽度乘以3。

  • colormap :N-by-3矩阵的双精度。在真彩色系统上它是空的。

  • cdata: A matrix of uint8 values. The dimensions are height-by-width-by-3.
  • colormap: An N-by-3 matrix of doubles. It is empty on true color systems.

因此,你可以提取 cdata 数组中每个电影帧的字段,并将其保存/用作RGB图像。

You can therefore extract the cdata field from each movie frame in the array and save/use it as an RGB image.

您的代码可能如下所示:

Your code might look something like this:

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

这篇关于如何从yuv 420视频剪辑中提取帧并使用matlab将它们存储为不同的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 00:20