For this example, we will use a sequence of images derived from a driving video. The frames must be read into MATLAB and then added to a video object in chronological order. Let's see how this works:
First, we will change our working directory to the directory that contains our
.jpeg
image sequence. In our example, this directory is calledE:\Videos\seq
. Of course in your system the directory containing the sequence may be different, so you should change the path accordingly. When in this directory, we will save the filenames of the image sequence to a new struct variable, namedcontents
:>> cd ('E:\Videos\seq'); >> contents = dir('*.jpeg');
Then, we must create a video object to store our video in. Let's call it
vid.avi
:>> outputVideo = VideoWriter('vid.avi'); >> outputVideo.FrameRate = 15; >> open(outputVideo);
Now that we have our filenames stored in the
contents
variable and we have opened a video file, we can...