Play Motion JPEG 2000 (.mj2) lossless video

Related: Python Matplotlib lossless video creation


Matlab can create lossless videos from image or plot/figure series from Matlab by EITHER:

  • Save PNG image stack, then convert PNG stack to lossless video
  • Save from Matlab directly as lossless JPEG2000 .jp2 video (as described below)

Example

This example saves lossless MJPEG2000 .mj2 video plots from Matlab.

v = VideoWriter('test.mj2','Motion JPEG 2000');
v.LosslessCompression = true; 
v.FrameRate=5;
open(v)
f=figure; 

pause(0.2) % let plot wake up
for i=1:.05:3;
    line(0:.01:1,(0:.01:1).^i) % just an example
    im = getframe(f);
    writeVideo(v,im)
end
close(v)

Play .mj2

This method plays back Motion JPEG 2000 .mj2 files from the command line (outside of Matlab).

  1. install FFmpeg
  2. play lossless Motion JPEG 2000 videos:
    ffplay movie.mj2
    

Notes

  • Motion JPEG 2000 is the only lossless compressed format available from Matlab.
  • mmread.m file enables more Matlab video I/O by using FFmpeg and AVbin via the included compiled FFGrab.mex file.

Categories:

Written by Michael Hirsch, Ph.D. //

Comments