<p>Did you try using the <code>-compression_level</code> flag? It takes an int from 0-100 afaik (maybe the range is even higher, the docs just say "int").</p>

<p>That should set a lossy compression strength.</p>

<p>There is also an interesting <a href="http://www.michaelcinquin.com/library/ffmpeg" rel="nofollow">blog post</a> about creating DCI compilant JPEG2000 encodes with FFMPEG for DCP's. Which require lossy encoded JPEG2000.</p>

CC BY-SA 3.0
2015-02-23T03:22:51.257Z
Ancient thread now, but one of the two encoders you want to compare can hit a bitrate target fairly accurately.  Encode with some setting with `libopenjpeg`, then make a HEVC encode with 2-pass at that bitrate.
Peter Cordes
CC BY-SA 3.0
2014-07-23T21:40:40.673Z
Thank you for your answer! The -compression_level flag does indeed reduce picture quality/file size. The range is 0-9999999999999. The only problem with this method is that -compression_level flag is not a defined scale. I'd like to compare the coding efficiency of different encoders. By using -compression_level flag I have no common value, which would allow me to compare different encoders.
dmkr
CC BY-SA 3.0
2014-07-23T22:31:25.750Z
The -profile:v flag mentioned in the blog post might help you. It applys specific encoding profiles that are also found in other encoders.
I cant find it in the documentation specific to JPEG2000, to know which profile is which you may have to look into the source.
timonsku
CC BY-SA 3.0
2014-07-23T22:43:23.103Z
Btw. if you just want to compare JPEG2000 implementations I recommend to just download the OpenJPEG binary directly and work with that, afaik FFmpeg only partially implents it. You will have far more options and better documentation: https://code.google.com/p/openjpeg/wiki/Downloads?tm=2
timonsku
CC BY-SA 3.0
2014-07-23T23:08:53.840Z
The -profile:v flag defines AFAIK such things as image size, wavelet levels etc, but not the compression ration. Well, I'll look into this anyway. I want to compare HEVC against JPEG 2000, especially benefits of higher bit depth in combination with chroma subsampling. I tried OpenJPEG, it kinda does the job. But the input formats are pretty sparse. They either don't support higher bit depth or are all RGB.
dmkr
CC BY-SA 3.0
2014-07-24T13:54:28.273Z
What is the issue with them being RGB? That doesn't affect the compression in any way, doesn't matter what color space your source has, OpenJPEG will decode them and use the color space provided by you for encoding.
Almost all of the listed formats support 16bit color, much more than HEVC even supports.
timonsku
CC BY-SA 3.0
2014-07-24T15:04:24.387Z
Also if you really just want to compress a few images and videos with jpeg2000 and don't need a command line you can use j2k from fnord. Its free and integrates into Photoshop, After Effects and Premiere (if you happen to own any of these, you can also use a free trial).
http://www.fnordware.com/j2k/
timonsku
CC BY-SA 3.0
2014-07-24T15:13:11.750Z
I have few thousands images with different parameters, therefore a command line or a batch file would come in very handy. Yeah, I've read about J2K Fnord plugin, but didn't try it yet. OpenJPEG does RGB->YCC conversion by default, I'm fine with it. But if I use a subsampling factor it stretches the image size... Also it applies the same subsampling factor to each component. Maybe I use a wrong command line, but I couldn't find an option to use a different subsampling factor for each component.
dmkr
CC BY-SA 3.0
2014-07-24T16:48:48.567Z
Well with photoshop you can do a batch processing aswell. So that wouldn't be an issue.
Fnords JPEG2000 plugin is very feature complete and implents almost all aspects of JPEG2000 there are.
timonsku
CC BY-SA 3.0
2014-07-24T23:27:34.240Z
I tried Fnord's JPEG 2000 plugin, as good as it is, there is no subsampling function implemented. And this is something I definitely need.
dmkr
CC BY-SA 3.0
2014-07-23T20:40:58.643Z
2014-07-23T20:40:58.643Z
timonsku
<p>I'm trying to achieve a lossy JPEG 2000 output with FFMPEG, but no success so far.</p>

<p>Using this command line:</p>

<pre><code>ffmpeg -i input.dpx -pix_fmt yuv420p -vcodec libopenjpeg output.jp2
</code></pre>

<p>As a result I get lossless output, which is a default setting for JPEG 2000. I tried -b:v and -q:v, but they both have no impact to the output.</p>

<p>Does anyone know a command that changes the quality/compress the output?</p>

<p>Any kind of help is really appreciated. Thank you!</p>

<ffmpeg><output>
Lossy output with FFMPEG JPEG 2000
dmkr
# Lossy output with FFMPEG JPEG 2000

(Asked by: username_0 on 2014-07-23)

I'm trying to achieve a lossy JPEG 2000 output with FFMPEG, but no success so far.
Using this command line:
ffmpeg -i input.dpx -pix_fmt yuv420p -vcodec libopenjpeg output.jp2

As a result I get lossless output, which is a default setting for JPEG 2000. I tried -b:v and -q:v, but they both have no impact to the output.
Does anyone know a command that changes the quality/compress the output?
Any kind of help is really appreciated. Thank you!

**Tags:** ffmpeg, output


---

## 1 answers

### Answer by username_1 on 2014-07-23. Score: 4

Did you try using the `-compression_level` flag? It takes an int from 0-100 afaik (maybe the range is even higher, the docs just say "int").

That should set a lossy compression strength.

There is also an interesting [blog post](http://www.michaelcinquin.com/library/ffmpeg) about creating DCI compilant JPEG2000 encodes with FFMPEG for DCP's. Which require lossy encoded JPEG2000.

> **Comments:**
> **username_0**: Thank you for your answer! The -compression_level flag does indeed reduce picture quality/file size. The range is 0-9999999999999. The only problem with this method is that -compression_level flag is not a defined scale. I'd like to compare the coding efficiency of different encoders. By using -compression_level flag I have no common value, which would allow me to compare different encoders.  
> **username_1**: The -profile:v flag mentioned in the blog post might help you. It applys specific encoding profiles that are also found in other encoders. I cant find it in the documentation specific to JPEG2000, to know which profile is which you may have to look into the source.  
> **username_1**: Btw. if you just want to compare JPEG2000 implementations I recommend to just download the OpenJPEG binary directly and work with that, afaik FFmpeg only partially implents it. You will have far more options and better documentation: https://code.google.com/p/openjpeg/wiki/Downloads?tm=2  
> **username_0**: The -profile:v flag defines AFAIK such things as image size, wavelet levels etc, but not the compression ration. Well, I'll look into this anyway. I want to compare HEVC against JPEG 2000, especially benefits of higher bit depth in combination with chroma subsampling. I tried OpenJPEG, it kinda does the job. But the input formats are pretty sparse. They either don't support higher bit depth or are all RGB.  
> **username_1**: What is the issue with them being RGB? That doesn't affect the compression in any way, doesn't matter what color space your source has, OpenJPEG will decode them and use the color space provided by you for encoding. Almost all of the listed formats support 16bit color, much more than HEVC even supports.  
> **username_1**: Also if you really just want to compress a few images and videos with jpeg2000 and don't need a command line you can use j2k from fnord. Its free and integrates into Photoshop, After Effects and Premiere (if you happen to own any of these, you can also use a free trial). http://www.fnordware.com/j2k/  
> **username_0**: I have few thousands images with different parameters, therefore a command line or a batch file would come in very handy. Yeah, I've read about J2K Fnord plugin, but didn't try it yet. OpenJPEG does RGB->YCC conversion by default, I'm fine with it. But if I use a subsampling factor it stretches the image size... Also it applies the same subsampling factor to each component. Maybe I use a wrong command line, but I couldn't find an option to use a different subsampling factor for each component.  
> **username_1**: Well with photoshop you can do a batch processing aswell. So that wouldn't be an issue. Fnords JPEG2000 plugin is very feature complete and implents almost all aspects of JPEG2000 there are.  
> **username_0**: I tried Fnord's JPEG 2000 plugin, as good as it is, there is no subsampling function implemented. And this is something I definitely need.  
> **username_2**: Ancient thread now, but one of the two encoders you want to compare can hit a bitrate target fairly accurately.  Encode with some setting with `libopenjpeg`, then make a HEVC encode with 2-pass at that bitrate.  

---

