Julian Stöttinger

Videos in Matlab

MATLAB is still not supporting a decent video processing tool under Max OS X and Linux. I checked out a couple of projects out there, e.g. videoIO - but I didn't get lucky with it...

Solution

MATLAB 2009b video object package for import, output, read write, process, play and whatever movies using ffmpeg. Fancy coverflow 3d visualization using frames as texture of 3d rectangles.

Features

  • Most stupid way of implementation

The source provides the slowest and most stupid way for video processing, but it works: It starts ffmpeg (must be installed) and writes pictures of every single frame into the dir /tmp/*cputimehash*. Then it reads the pictures iteratively. Video Information is extracted via 'aviinfo' if it is a avi.

  • provides both MATLAB video object and uint8 matrix

The objects builds a MATLAB movie object with colormap and a convenient matrix holding all your pixel ready to process. There you can change pixels easily and convert it back (v = v.matrix2movie, v = v.movie2matrix)

  • Fancy coverflow visualization

Yes, I seriously map single frames on 3d objects as a texture. There's nothing wrong about it. You can even zoom, drag and edit every object in there interactively!

Requirements

  • Linux64 or Mac OS X 

Windows version is very easy to get: put your ffmpeg file into @video/readframes.m - or just use the built-in video abilities. It is better anyway.

  • ffmpeg installed
  • loads of memory
  • enough space on your /tmp

How to use

This is object-oriented Matlab Code! If you are not familiar with its concepts, please refer to the Matlab documentation
In the root directory of the Videopack type into the Matlab console: 

p = params();

% optional parameter adjustment -> help params
p.splitVideo = true;
p.startframe = 12;
p.endframe = 18;
p.picformat = 'jpg';

v = videopack.video('test.avi',p); %reads test.avi
v.play % plays test.avi
v.coverflow(p,1:6); % optional fancy coverflow visualization
v.writevideo(p); % writes video to filename defined in p

Download source

Download the MATLAB source here.