Difference between revisions of "JPEG2000"

From Archivematica
Jump to navigation Jump to search
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Main Page]] > [[Documentation]] > [[Media type preservation plans]] > JPEG2000
[[Main Page]] > [[Documentation]] > [[Format policies]] > JPEG2000
Line 17: Line 17:
*JPEG2000 image compression ranges from completely lossless to very lossy.
*JPEG2000 image compression ranges from completely lossless to very lossy.
*Florida digital Archive has "high confidence level" in ability to preserve losslessly compressed JP2 files: [http://www.fcla.edu/digitalArchive/formatInfo.htm FDA Recommended Data File Formats].
*Florida digital Archive has "high confidence level" in ability to preserve losslessly compressed JP2 files: [http://www.fcla.edu/digitalArchive/formatInfo.htm FDA Recommended Data File Formats].
*JPEG2000 has limited support for colour profiles: See [http://jpeg2000wellcomelibrary.blogspot.com/2010/12/guest-post-ensuring-suitability-of-jpeg.html Ensuring the suitability of JPEG 2000 for preservation].
== Encoding JPEG2000-MXF video ==
===More information===
===Method one: OpenDCP===
*[http://blogs.loc.gov/digitalpreservation/2013/01/is-jpeg-2000-a-preservation-risk/ Is JPEG2000 a Preservation Risk], Chris Adams, Library of Congress Signal Digital Preservation Blog, January 28, 2013.
*[http://www.updig.org/guidelines/ph_archiving.html Universal Photographic Digital Imaging Guidelines: Archiving] and [http://www.dpconline.org/docs/reports/dpctw08-01.pdf Technology Watch Support:JPEG 2000 - a Practical Digital Preservation Standard? Digital Preservation Coalition 2008].  
*[http://www.digitalpreservation.gov/formats/fdd/fdd000143.shtml Library of Congress Sustainability of Digital Formats: JPEG 2000 Part 1 (Core) jp2 File Format]
*OpenJPEG 1.4 ([http://www.openjpeg.org/])
*OpenDCP ([http://code.google.com/p/opendcp/])
This workflow is designed around digital cinema package (DCP) production.
Most of the open-source tools are based around DCP since they're being
designed by indie filmmakers.
OpenDCP is a utility for creating DCPs. The [http://www.cinecert.com/asdcplib/ AS-DCP library] and the [http://sourceforge.net/projects/mxflib/ mxflib library] it's based on are possibilities
for someone with more programming skills than me to build an
archives-targeted tool.
The disadvantage to this route is that DCPs use separate files for audio
and video, accompanied by an XML file describing the pair, which might
make playback less convenient than a single AV MXF. The available tools
are also targeted more to film framerates, and I'm not sure if it's
possible to obtain a video FPS like 29.97 using unmodified tools.
Step 1: Decoding source video
The source video should be decoded into a series of single frames before
being encoded into JPEG2000. This can be done using Ffmpeg.
<code>ffmpeg -i invideo -vcodec tiff f%10d.tif</code>
This will produce one file for every frame in the video. Why do we do
this? Well, the various Motion JPEG2000 formats are essentially a series
of single JPEG2000 files; each frame will be encoded to JPEG2000 before
multiplexing into a video.
The audio should be decoded to uncompressed WAV. This is a simple process
so I won't go into much detail here. The command should be a variant of
<code>ffmpeg -i invideo outfile.wav</code>
Step 2: Create JP2 frames
Next, these frames should be compressed into JPEG2000. Note that this will
'''not''' be done using OpenJPEG's support for Motion JPEG2000! Motion
JPEG2000 is a specific container for single JPEG2000 frames, while MXF
wraps its frames in a different way. Technically, JPEG2000/MXF
is considered a separate format.
<code>image_to_j2k -ImgDir directory -OutFor j2c</code>
This will create JP2 frames using the default lossless compression frames,
but you may wish to customize this. Frames will be saved as .j2c files in
the same directory as the TIFF frames.
Step 3: Create MXF file
<code>opendcp_mxf -i image_directory -r framerate -o video.mxf
opendcp_mxf -i audio.wav -o audio.mxf
opendcp_xml --reel video.mxf audio.mxf</code>
This will produce two MXFs, one containing video and one containing audio.
The third command creates an accompanying XML file, mainly targeted at
digital projectors.
===Method two: GStreamer===
GStreamer can encode to and from JPEG2000 MXF. By default it uses JasPer
as the JP2 encoder, which has some limitations. I believe there may be a
project underway to replace JasPer with OpenJPEG. GStreamer's commandline
utility also has very inconvenient syntax; it's designed primarily to be
used as a library to be called by custom programs. The gst-launch utility
is mainly meant for debug purposes. For production would be best to write
a custom archives-oriented converter based on Gstream rather than use the
gst-launch utility.
The advantage to GStreamer is that it provides all of the required
functionality, and can go straight from a source video to producing an
On the other hand, GStreamer currently uses JasPer for JP2 encoding. It
may be better to use it in conjunction with an external JP2 encoder.
*GStreamer ([http://gstreamer.freedesktop.org])
The GStreamer debug utility is based around a chain of smaller tools
chained together. Here's a sample command which takes a video-only file,
in QuickTime format with PNG video, and turns it into a JPEG2000 MXF:
<code>gst-launch-0.10 filesrc location=video.mov ! qtdemux ! pngdec !
ffmpegcolorspace ! videoscale ! jp2kenc ! mxfmux ! filesink
This goes through a series of steps to get from your source video to the
encoded video. This example does:
*filesrc location=video.mov : Tells gst-launch where to find the source video
*qtdemux : Demultiplexes the video. This means that it "opens" the container and extracts the tracks inside it, making them available to the other GStreamer tools
*pngdec : Decodes PNG compressed video into uncompressed video
*ffmpegcolorspace : Interprets the colour space in the video. Necessary to be able to pass it to other tools
*videoscale : Negotiates the size of the video. When used with no arguments, it just ensures the next tool knows what the size is
*jp2kenc : Encodes the video stream to JPEG 2000. You can specify the settings here if you want
*mxfmux : Combines (multiplexes) the streams being processed into an MXF container
*filesink location=video.mxf : Saves the video to a "filesink", e.g. a location on the hard drive
The exact commands will depend on the source video. You can also do a
combined audio/video file, but the commands for that are kind of complex
and, to be honest, I haven't quite gotten my head around it yet.
You can also decode and convert videos using GStreamer. Here's a sample
command to convert the previous video to MPEG-4 with default settings:
<code>gst-launch-0.10 filesrc location=video.mxf ! mxfdemux name=d d. !
jp2kdec ! ffmpegcolorspace ! videoscale ! ffenc_mpeg4 ! filesink
===Method three: GStreamer + OpenJPEG===
As I mentioned before, GStreamer's JP2 encoder isn't ideal right now.
However, you can easily encode a video with another tool and wrap it into
MXF using GStreamer.
First, extract your video to frames with ffmpeg as described above, then
compress them to JP2 frames using the following command:
<code>image_to_j2k -ImgDir directory -OutFor j2k</code>
You should then wrap them into an MJ2 video using the following command:
<code>wrap_j2k_in_mj2 directory video.mj2</code>
This will produce a single MJ2 file using the frames you extracted. By
default the framerate will be 25fps, which is probably wrong - consult the
OpenJPEG documentation to find out how to set the framerate.
You can then open this video file using GStreamer and rewrap the frames
into an MXF using a command like the following:
<code>gst-launch-0.10 filesrc location=video.mj2 ! mj2demux ! mxfmux ! filesink
This will produce an MXF with the contents as your video - no
recompression or loss of quality. Hooray!
===Areas for future work===
GStreamer seems ripe for someone to develop a custom, archives-oriented video conversion program. Any volunteers?
==More information==
[http://www.digitalpreservation.gov/formats/fdd/fdd000143.shtml Library of Congress Sustainability of Digital Formats: JPEG 2000 Part 1 (Core) jp2 File Format]

Latest revision as of 15:53, 19 February 2013

Main Page > Documentation > Format policies > JPEG2000

File extension(s)[edit]


Format registry information[edit]

None. Closest is PRONOM (JPX - JPEG 2000 Extended)

Significant characteristics[edit]

See Significant characteristics of raster images

Preservation action plan[edit]

See Raster images

Preservation issues[edit]

More information[edit]