function makevideo_anno(frames, points, filename, options)
tmpfile = 'tmp.xxoo.avi';
aviobj = avifile(tmpfile);

options = argutil_setdefaults(options, 'issc', false, 'bboxes', [], 'mesh', []);

if length(size(frames)) == 3
    [m, n, nFrame] = size(frames);
    isMono = true;
else
    [m, n, nChannel, nFrame] = size(frames);
    isMono = false;
end;

if options.issc
    maxz = max(frames(:));
    minz = min(frames(:));
end;
    
for i = 1:nFrame
    if options.issc && isMono
        imagesc(frames(:, :, i), [minz, maxz]);
    elseif isMono
        imshow(frames(:, :, i));
    else
        imshow(frames(:, :, :, i));
    end;

    hold on;
    if iscell(points)
        plot(points{i}(:, 1), points{i}(:, 2), 'g.', 'LineWidth', 0.5);
    else
        plot(points(:, 1, i), points(:, 2, i), 'g.', 'LineWidth', 0.5);
    end;
    hold on;
    
    % tracking boxes
    if ~isempty(options.bboxes)
        b = options.bboxes(i, :);
        rectangle('Position', [b(1), b(2), b(3) - b(1) + 1, b(4) - b(2) + 1], 'EdgeColor', 'r', 'LineWidth', 2);
    end;
    vis_drawMesh(points(:, :, i), options.mesh);
    
    hold off;
    
    %axis([0 300 0 300]);
    axis ij;
    
    frame = getframe(gca);
    aviobj = addframe(aviobj, frame);
end;
aviobj = close(aviobj);
% use mencoder to transfer video format
eval(['! mencoder -o ' filename ' -ovc lavc -lavcopts vcodec=wmv2:vbitrate=9800 ' tmpfile ' >/dev/null']);
eval(['! rm ' tmpfile]);