Playing Motion JPEG 2000 (.mj2) videos from Matlab

MATLAB can create and read lossy and lossless Motion JPEG 2000 videos on Windows and Linux. You can play back Motion JPEG 2000 files on Linux with “ffplay” as follows:

In Terminal, type
ffplay movie.mj2
where of course “movie.mj2″ is the .mj2 Motion JPEG 2000 video to be played.

from the Command Prompt, type c:\ffmpeg\bin\ffplay movie.mj2
(assuming you downloaded ffmpeg to c:\ffmpeg)

Rotate180CCW-checkerboard.mj2 (51kB)
is a sample Motion JPEG 2000 .mj2 video of a rotating greyscale checkerboard you can use to test your Motion JPEG 2000 player.

Note, if you get an errow about missing CODECs, you will need to update your ffmpeg to a version that included libopenjpeg. Thankfully for Ubuntu users, there is a PPA with the most recenter FFMPEG with MJ2 support:
sudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

Then it should play for you. I have tested with FFMPEG version 0.10.7

2 thoughts on “Playing Motion JPEG 2000 (.mj2) videos from Matlab”

  1. Thanks for the helpful posts on .mj2 video. I wonder if you have some advice for me.
    I’m generating .mj2 files with R2012a on Ubuntu 10.04, and ffplay won’t play my .mj2 files (on Ubuntu). Is there a specific codec I need to install?
    When I try to play my files, ffplay says:
    “could not open codecs”
    But when I try your test file, ffplay says:
    “Could not find codec parameters (Video: Motion JPEG2000, 65×65)”

  2. Hello Matt H.,
    I have also noted your codec issue on some PCs with old/incomplete FFMPEG installs.

    Please consider the PPA now mentioned at the bottom of the article.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>