How does one merge two different struct('cdata',[],'colormap',[]) arrays for use with the function movie2avi()?
Show older comments
I have been trying to make an movie using movie2avi() but I want to make the movie from more than one struct('cdata',[],'colormap',[]) array. My attempts to merge two different struct('cdata',[],'colormap',[]) arrays have failed so far.
frames1 = foo1(input);
frames2 = foo2(input);
all_frames = cat(2, frames1, frames2);
movie2avi(all_frames, 'point_set_registration.avi');
The arrays returned by foo1 and foo2 are populated inside foo1 and foo2 using getframe() within a loop. After executing the code above, Matlab does indeed produce an avi file and I do not get any error messages. However, when I play back the resulting avi my code obviously did not do what I wanted it to.
However, when I separately call...
movie2avi(frames1, 'movie1.avi');
% and
movie2avi(frames2, 'movie2.avi');
Then the resulting two videos are correct, except that I want a single avi file instead of two different videos. Basically I want the first half of the video to be made from frames1 and the second half of the video to be made from frames2.
Apparently,
all_frames = cat(2, frames1, frames2);
... is not the proper way to merge two struct('cdata',[],'colormap',[]) arrays for use with movie2avi(). How do I get a single avi video file from two different arrays of the type struct('cdata',[],'colormap',[])?
Answers (1)
Walter Roberson
on 20 Sep 2015
all_frames = cat(1, frames1(:), frames2(:));
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!