如何将avi文件转换为yuv 420(软件/matlab/源代码/c/c++任何东西)
题
伙计们,我想将 avi 文件转换为 yuv 420 视频剪辑。有什么方法可以做到这一点吗?谢谢!
解决方案
您可以将 AVI 文件读入 MATLAB 使用内置的 mmreader
班级. 。将 AVI 帧读入电影帧的结构数组后,您可以使用以下命令将它们保存为 YUV 文件: saveFileYuv
在此提交中找到的函数 MathWorks 文件交换:
您的代码可能如下所示:
%# Get the video data:
vidObj = mmreader('myVideo.avi'); %# Create a video file object
nFrames = vidObj.NumberOfFrames; %# Get the number of frames
vidHeight = vidObj.Height; %# Get the image height
vidWidth = vidObj.Width; %# Get the image width
%# Preallocate the structure array of movie frames:
mov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),...
'colormap',[]); %# Note that colormap is empty!
%# Read each video frame into the structure array:
for k = 1:nFrames
mov(k).cdata = read(vidObj,k); %# Place frame k in the cdata field of mov(k)
end
%# Save the movie frame array as a YUV 4:2:0 file:
saveFileYuv(mov,'myVideo.yuv',1);
其他提示
我不推荐用Matlab。你想这样做可以很容易地使用做什么的mplayer / mencoder的...为什么利用Matlab是什么?
mencoder.exe -of rawvideo clock.avi -o clock.yuv -nosound -ovc原始
您可能如果colrs不正确添加-vf swapuv到交换的U和V分量。
不隶属于 StackOverflow