MATLAB Answers

How to convert struct to a video

18 views (last 30 days)
Peter
Peter on 26 Nov 2016
Answered: Walter Roberson on 26 Nov 2016
v = VideoReader(path);
vidHeight = v.Height;
vidWidth = v.Width;
mov=struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]);
numFrames = get(v,'NumberOfFrames');
for k=1:numFrames
mov(k).cdata = read(v,k);
end
Then I will apply some change to the mov, but I cannot output a video using VideoWriter or VideoFileWriter, as it says something like the input does not correct
Is that mean I cant use any of them to convert a struct to a video? What else can I do? Thanks

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Nov 2016
Videofilewriter step method only accepts individual image arrays (or y cr cb arrays).
Videowriter writeVideo method only accepts individual image arrays or individual frames compatible with movie structure (your mov is an array of those)
You will need to loop writing the contents of your mov structure array.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.