Thursday, February 18, 2010

Matlab - My Basic Structure for Editing Videos

The Basic Strucutre i use to edit Videos. Video Editting and Video Analysis in matlab should be done the same way as Image Editting and Anlaysis however theres a slight difference when doing this in Videos;

The steps required for video editting:
  1. Identify your input Video
  2. Expound the video by assuming each frame is an Image
  3. Perform some image editting or analysis
  4. Paste all the processed Images in a single sequence
  5. Create a new Video
The following is a structure ill use throughout, Notice the "Orange" Section that will change in each implementation.

fin = 'rawVideo.avi'; %input File name to be changed
fout = 'movie2.avi'; %output File name to be changed

%get the File info
fileinfo = aviinfo(fin);
%get the number of Frames
nframes = fileinfo.NumFrames;

aviobj =
avifile(fout, 'compression', 'none', 'fps',fileinfo.FramesPerSecond);

for i = 1:nframes
%You may need to limit the nFrames, may result in a large file size
%Read frames
from input video

mov_in = aviread(fin,i);
im_in =
frame2im(mov_in);

%Do processing on each frame of the video

%TO DO.....


%Write frames to output video
frm =
im2frame(im_out);
aviobj = addframe(aviobj,frm);

i
%Just to display frame number you can ommit
end;

%Don't forget to close output file
aviobj = close(aviobj);
return;

4 comments:

  1. Do you know how to plot 5 points of a trajectory and then erase them and plot the next five and so on? When I create this kind of videos after several trajectories what you see is a mess and you cannot distinguish between different trajectories ... Thanks

    ReplyDelete
    Replies
    1. The command you are looking for is called "clf" and clears the plots from the current fig, while keeping the fig. Usually you place it before the new plotting command (in the loop you have i guess) so that your eye does not notice the difference. Cheers!

      Delete
  2. Apple Clips is a video editing app that lets users create and share short videos complete with special effects, text, and graphics.
    One of the more interesting features of Clips is Live Titles, which let you create animated captions by talking as you record.
    On Facebook, users play up to 85 percent of videos without sound, making this one of the more valuable video social media tools for boosting engagement rates.

    ReplyDelete