Export Video to Lossless JPEG2000 in MXF Container?

Hello, everyone!

I’ve been using Shotcut for a little under a year now and it’s served me well. I have a backlog of completed video projects that I would now like to archive for preservation. I want to use the preservation method as described by the Library of Congress here:

There is no preset for this method in Shotcut (unless I completely overlooked it) and, up until now, I was using stock presets for previous exports. I tried an export already but I think the JPEG2000 conversion was lossy as the file size seemed way too low to me. I have only very basic knowledge of codecs. I also do not know what audio codec I should use for this archiving project.

If someone could please “guide” me through the process of setting up exports that match the Library of Congress standard, it would be much appreciated.

Thank you in advance!

EDIT: Here’s another link to the Library of Congress:

Congratulations on finishing some major projects! To get archive-grade preservation, here is the quick and easy way:

  1. Open the project
  2. Go to the Export panel
  3. Click on the Lossless > FFV1 preset
  4. Click the Advanced button to open more options
  5. Change the Audio tab > Codec option to pcm_s24le
  6. Click the Export File button
  7. Profit

I realize that FFV1 is not what you requested. But it might be what you need.

The “Recommended Formats Statement” link refers to the Motion Pictures category of video. When the LOC says “Motion Picture”, they mean a literal theater-style movie that will be played back on a digital cinema playout server. The Digital Cinema Initiative (DCI) has extremely strict rules about the formats that digital movies can be in, and these rules are detailed in the Digital Cinema Package (DCP) specification. JPEG 2000 in an MXF OP1a file is part of the DCP spec. DCP is what ensures that a movie will play without problems in every theater in the world.

Due to the strictness of these rules, DCP is usually not a viable format for general usage. DCP supports only six resolutions, one of which is 2048x1080. 1920x1080 and 4K UHD are not supported. If your project does not use one of the six supported resolutions, it cannot be encoded into a legal DCP. DCP also supports six frame rates in 2K and three additional frame rates in 4K 3D. But many tools (including the Shotcut/FFmpeg tools that I’ll demonstrate in a moment) only support proper signaling for 24fps and 48fps. If your project is 25/30/50/60 FPS, the tools can’t create a legal DCP. It may be possible to create a high frame rate DCP using other tools like OpenDCP, but this only leads to the next problem…

A DCP is composed of six files… A JPEG 2000 image sequence in one MXF file, WAV audio in another MXF file, and then four XML metadata files. This is not something that is easily created, validated, stored, uploaded, or shared. Most media players cannot play a DCP, either.

DCP also may not provide you with a lossless archive, which would fail your primary objective. The DCP spec puts a hard limit of 250 Mbps as the max bitrate. JPEG 2000 provides two ways of encoding frames… using a CDF 9/7 lossy wavelet that can have the quality level configured by -q:v or -compression_level when using FFmpeg, or using a LGT 5/3 wavelet for lossless compression. However, there is no bitrate control when using LGT 5/3. If your video cannot be losslessly compressed under 250 Mbps using LGT 5/3, then there is no choice but to switch to lossy CDF 9/7 and adjust the compression level until it fits under 250 Mbps. So, not only may you not get the lossless archive you want, but it may also be a science project to figure out the best compression settings for a legal lossy substitute. Hence, even in Hollywood, creating a DCP is often outsourced to a specialty shop. Are you interested in doing extra work to get results that are worse than lossless? I’m certainly not. :slight_smile:

This is why I’m trying to steer you away from the Motion Picture DCP specs, and away from JPEG 2000-in-MXF in general. The next section of the LOC “Recommended Formats Statement” page is called “Video File-Based and Physical Media”. This is much more suited to general usage, as these files are not constrained to a specific playback system the way DCP is. The FFV1 codec as listed in the LOC’s right-hand column is directly supported by Shotcut, and I described the method to use it at the top of this post. The ProRes formats in the left-hand column are also supported by Shotcut, and an export preset even exists for ProRes 422 HQ. (It’s called ProRes HQ, but remember to switch its audio codec to pcm_s24le as described above.) ProRes is considered “visually lossless”, and 4444 XQ may as well be lossless. But technically, they are not bit-for-bit exact the way FFV1 is. ProRes does have more media player and video editor support, though.

As for audio, WAV audio (called pcm_s24le in Shotcut/FFmpeg) is endorsed by the Library of Congress.

So, that’s my recommendation for LOC-style lossless archiving… FFV1 video with WAV audio. The LOC’s thoughts on FFV1 are posted here:

If you actually are making 24fps feature films and still want to do JPEG 2000 in MXF, I’ll describe the process in the next post.


Here are the Shotcut export settings for lossless JPEG 2000 in MXF:

Image caption: change Format to mxf; change Codec > Codec to jpeg2000 and Rate Control to Average Bitrate; change Audio > Codec to pcm_s24le; change Other to pix_fmt=yuv422p and pred=1

Important notes:

  • The Other tab > pred=1 is what tells the encoder to use lossless mode (LGT 5/3). Use pred=0 for lossy CDF 9/7.
  • The Codec tab > Rate Control option must not be “Quality-based VBR”, because that will send -qscale to the encoder which will take precedence over pred=1, and flip the encoder back to lossy mode. So, set Rate Control to “Average Bitrate” as a workaround, which will be ignored by the encoder since it doesn’t support an average bitrate mode.

Even though these settings will produce a video file, there are problems:

  • The generated file is not DCP-compliant. libopenjpeg is required for DCP compliance, but it is currently not compiled into the Shotcut-bundled build of FFmpeg. The built-in native JPEG 2000 encoder is a non-DCP next-best-thing.
  • The generated file takes 6x the encoding time of FFV1, is sometimes larger in file size than FFV1, and (on my computers) cannot be decoded fast enough to play back in real-time. The file is non-seek-friendly to an epic degree.

The alternative is to use libopenjpeg as the encoder from the FFmpeg command line using an official build of FFmpeg. The file produced by libopenjpeg can be made DCP-compliant, and encode 14x faster than the native JPEG 2000 encoder used by Shotcut. Playback of the file can actually be real-time.

Here are some resources for building DCP-complaint JPEG 2000 files with free tools (I have not tested these techniques with an actual playout server, though):

See all of the DCP-related options to libopenjpeg by running ffmpeg -h encoder=libopenjpeg

As an alternative, this is how to transcode a lossless master from Shotcut into JPEG 2000, using a non-DCP format so the video can be any resolution and frame rate you like:
ffmpeg -i input.mkv -c:v libopenjpeg -c:a copy -f mxf output.mxf

By default, libopenjpeg encodes as lossless, so there are no fancy options to add. This command also assumes the input.mkv file has audio in WAV/pcm_s24le format already. If not, change to -c:a pcm_s24le instead of -c:a copy.

If you simply want wavelet-style compression for its advantages over DCT codecs, but don’t want any of the headaches of DCP or JPEG 2000 encoders, there is another option directly supported by Shotcut called Cineform. It’s a fast, open-source, wavelet-based codec that’s been around for 20 years. I frequently use it interchangeably with ProRes, and I can provide more details if you want them.


Austin, thank you for the reply! I’m glad you provided so much information on the topic, as now you’ve piqued my interest in digital video archiving. The projects I worked on were nothing even close to full-length movies; they were just short, 10-minute creative endeavors I made for YouTube. But I did put a lot of effort into them and recently I grew interested in storing them in a lossless format for preservation.

Could you provide an example of a “lossless master from Shotcut” that I could import into FFMPEG for reencoding in JPEG2000/MXF?

Finally, I would like to try different methods to see which works best for my needs. And yes, I would appreciate details on how to use the Cineform option.

Thanks again!

This simply means exporting from Shotcut to any lossless format. I provided an FFV1 example in my first post, which is a lossless format. Other popular lossless formats are Ut Video, Huffyuv, FFVHuff, MagicYUV, and H.264 in Lossless mode.

As noted above, Shotcut must first produce a lossless file that can then be converted to JPEG 2000 by FFmpeg. If Shotcut has already produced a lossless file in FFV1 format, and that file is already acceptable to the LOC as a preservation format, then why go through the extra step of turning it into a larger, slower-decoding, JPEG 2000 file?

Here are the export settings for Cineform:

Image caption: change Format to mov; change Codec > Codec to cfhd; change Audio > Codec to pcm_s24le; change Other to pix_fmt=yuv422p10le, and add quality=film1 or quality=film3

The image quality of a Cineform encoding is controlled by the quality parameter on the Other tab. The film1 option is slightly under ProRes 422 HQ, whereas film3 is pretty much equal to ProRes 422 HQ. Both Cineform encodings are likely to be smaller files than ProRes 422 HQ. When I say “slightly under” in terms of image quality, this means that I have Shotcut’s preview player zoomed in to 750% doing single-frame A/B viewing comparisons, and I can still barely tell any difference between the original file and the film1 variant. The difference will never be noticed at 100% viewing size and full-speed playback.

The reason the quality options are called “film” is because Cineform has been popular for film preservation due to its excellent RGB support.

Here are some useful questions for evaluating codecs:

  • Time required to export or transcode
  • Can Shotcut export directly to it?
  • File size
  • Encoded quality compared to original
  • Plays back with popular media players
  • CPU percent usage to decode the video
  • Real-time playback possible?
  • Can open in most video editors as-is
  • Any patents or royalties to use it
  • LOC-approved

In particular, I urge you to double-down on the “encoded quality compared to original” criterium. Lossless sounds great in theory, but it’s an enormous amount of disk space to preserve detail that the eye will never notice missing. Compared to a “visually lossless” H.264 CRF 16 encoding, true lossless will be about 10x the file size. Is it worth paying 10x the money for extra hard drive space to store subtle color shifts that the human eye can’t even detect? Maybe, maybe not. This is for you to decide.

To test for yourself, start a new Shotcut project, put the original source clip on V1, and put a test encoding (like FFV1 or JPEG 2000 or H.264 CRF 16) on V2 above the original on V1 so they are synced. Use the track visibility toggle (the eyeball icon in the track header) to turn the encoded video track on and off. Compare the preview window at full image size and at 750% zoomed in. Can you really spot any differences when viewed at full size? Will any post-processing work be done on the preservation copies to justify keeping every detail? How much detail really matters to you? That’s for you to decide, and the decision might need to include the monetary cost for storage in addition to the quest for ultimate image quality. If encoding just a few short videos, lossless is no big deal. For an entire movie collection or a gaming streamer or a prolific content creator, lossless can become a serious liability. There is such a thing as radical overkill in this field. :slight_smile: It helps to test and see the difference to really know for sure if you really need it.


Again, thank you for the information. I tried exporting using all of the methods you described and even experimented with a few others (like wrapping FFV1/WAV in a MXF container, which didn’t work. Lol). Looks like I will be using the FFV1/WAV/MKV method for lossless preservation after all (as long as my video projects stay under a half-hour).

Still, I’m glad I asked the original question, as it helped me better understand the process of encoding video in general.

1 Like

Thanks for sharing your results! Glad you found an option that works for you.

Sorry for the bump, but I didn’t want to start a new thread and my latest question i directly related to this topic.

My latest project has run way over the original estimated runtime. It is now about a half hour with more work to go. I exported what I have worked on up until this point as a FFV1 4K file and it was over 100GB. Trying exports as ProRes or CineForm wasn’t much of an improvement when it came to file size, at least with the settings as they were (default ProRes and your CineForm suggestion).

For this particular project, I’ll be happy to settle for “near lossless” or “visually lossless” when it’s done. Austin, since you were such a big help before, do you have any recommendations for codecs/containers/settings to achieve this?

For visually lossless I use the DEFAULT profile, NO Hardware Ecncoding with Quality set to 67%.

1 Like

What @Elusien said.

A similar option might be using libx264 (no hardware encoding), set Quality to 100% for lossless, set GOP to 249, set B-frames to 0, then on the Other tab change the preset line to preset=ultrafast for a speed boost. This is another attempt at lossless, so the file size might be big again. But the GOP 249 is a major advantage that the other formats don’t have, and it may bring the file size way down to something reasonable. If it’s still too big but you want the next best thing to lossless, you could try Quality 98% which will go back to 4:2:0 (probably) instead of 4:4:4 used for lossless. That’s a big additional savings.

This topic was automatically closed after 90 days. New replies are no longer allowed.