How to detect lossless JPEG 2000 compression? - mjpeg

I have a motion-JPEG 2000 file that I need to determine if the creator used lossless compression to create it based on the file itself. I do not have the raw video data to compare to, and I do not have the source code of the application used to produce the file.
Based on what I have found, it looks like the best I can do is check the wavelet filter (biorthogonal 3/5) and the quantization step size (1), and assume lossless if those conditions are true.
Any suggestions on how to check for lossless compression are greatly appreciated. My working environment is MATLAB or Java, but any hints for other platforms will be helpful.

You can use ffmpeg for this purpose. Download it from here: https://ffmpeg.org/. After you installed the software and added its source folder to WIN path, you can simply do the following:
ffprobe Test.mj2
The output then shows you many details about the video, including its possible
losslessness.
See the following example output

It is possible to use 5/4 wavelet and quantization step of 1, and still truncate the code stream during encoding to get a lossy result. This is still a valid JPEG 2000 images. So, the only way of checking for lossless is to compare with original.

Related

Reducing FFmpeg dlls to only what is used?

I have written Windows software that calls the FFmpeg dlls to encode a sequence of images in a few different formats (animated gif, animated png, mpeg4, wmv, webm). I need to provide the dlls with my software but they significantly increase the download size. Even after zipping everything they increase the size from around 5MB to around 20MB. This isn't a huge problem but I'd like to get the download size down as much as possible.
How easy is it to do this and by roughly how much would I be able to reduce them? Note that I don't need any decoders and am only encoding those 5 formats. I'm not using any special filters and the encoded videos don't have sound. I'd like to know if it's worth it before I start trying to compile the FFmpeg source and playing with configuration flags.

Which image file format compresses the most when using a lossless data compression archive file format (like .zip)?

I understand that graphic images do not compress well when using a lossless compression archive file format like .zip. Is there an image file type that losslessly compresses better (smaller) than the others?
Which image file format compresses the most when using a lossless data compression archive file format (like .zip)?
Lossless image compression algorithms implemented in image file format use the same methods as general purpose compression software, plus some specific methods based on image models. These methods tend to remove data redundancy and to provide a variable length coding that exploits data statistics to reduce coding cost.
Hence if a compressed image can be significantly recompressed by, say, zip, it is probably not a very efficient file format in terms of compression. So to answer your question, the image file format that can be the most efficiently compressed by zip is the format with the least internal compression. And the final result will be worse than using a good lossless image compression method and skipping the zip recompression.
There are good lossless image compression methods available. The compression ratio is of course worse than the one provided by lossy compression, but can be decent, depending on your need. In standard methods, you can use png of lossless jpeg2000. And the are very good non standard methods, as webP, FLIF or BPG. But with none of them you will have any significant gain if using zip on these images.
The file format does not affect the compression ratio of the image .it usually tells us what is the data format and the compression used.
The image itself affects the comprrssion. A monothonic image will compress better than a noisy one.

Video formats with lossless interpolation frames?

I'm playing with image-optimized diffs for storing edits to artwork. Version control seems to treat images as binary blobs, which means changes to common compressed formats like PNG/JPEG rewrite ≈90% of the file, so updates eat roughly the same space as storing separate files anyway.
Instead of writing some bit-twiddling code myself, I had an idea. We already have highly optimized algorithms for storing differences between images: video codecs.
What video codecs out there allow for lossless reconstruction through their interpolation (“b”) frames? The most common ones all understandably err on the lossy side.
For example, HEVC lossless mode – the encoder will find optimal inter or intra predictions and then losslessly code the residual.
(Moved from a comment.)

Lossless JPEG file writing

I have a question with regard to JPEG file writing. Suppose I have a PNG file example.png, and I want to change the file format to JPEG without any information loss. For the now being, I have two solutions:
Solution 1: perform the file formatting transformation with MATLAB
I = imread('example.png');
imwrite(I,'example.jpg','Mode','lossless');
II = imread('example.jpg');
differ = I-II;
max(differ(:))
This solution can produce lossless JPEG files. However, the problem with this solution is that
some information in the original image such as the DPI resolution may be lost. Moreover, the
produced output image cannot be viewed by popular image viewers such as IrfanView and Windows
Paint.
Solution 2: use IrfanView software.
Use the "Save as" function of IrfanView program, we can change the file format very easily. However, although I have set 'best quality 100' option when saving the JPEG file, the output image also show some information loss. The difference between these two images are not zero for all the pixels.
I am therefore wondering what I should do in order to solve the problem. Any ideas will be appreciated.
This problem has no solution (yet, as of 2018).
You can't avoid use of lossy compression if you want the JPEG file to be usable in majority of image viewers.
The commonly supported version of JPEG is based on DCT compression, which - by definition - performs transformation and rounding that causes some precision loss.
The alternative, lossless JPEG compression method, JPEG-LS, is rarely supported.
There's also JPEG-XT extension that's a combination of lossy image + layer for reconstruction of the lossless original. It fails gracefully in JPEG image viewers, but it's even newer, and I don't know if it's implemented anywhere yet.
If you really need lossless, use PNG. With JPEG the best you can get is minimally lossy JPEG in RGB colorspace at quality=100 (which isn't literally 100%).

Forcing custom H.264 intra-frames (keyframes) at encode-time?

I have a video sequence that I'd like to skip to specific frames at playback-time (my player is implemented using AVPlayer in iOS, but that's incidental). Since these frames will fall at unpredictable intervals, I can't use the standard "keyframe every N frames/seconds" functionality present in most video encoders. I do, however, know the target frames in advance.
In order to do this skipping as efficiently as possible, I need to force the target frames to be i-frames at encode time. Ideally in some kind of GUI which would let me scrub to a frame, mark it as a keyframe, and then (re)encode my video.
If such a tool isn't available, I have the feeling this could probably be done by rolling a custom encoder with libavcodec, but I'd rather use a higher-level (and preferably scriptable) tool to do the job if a GUI isn't possible. Is this the kind of task ffmpeg or mencoder can be bent to?
Does anybody have a technique for doing this? Also, it's entirely possible that this is an impossible task because of some fundamental ignorance I have of the h.264 codec. If so, please do put me right.
ffmpeg has a -force_key_frames option that accepts a series of arbitrary timestamps as well as other ways to specify the frames. From the documentation:
-force_key_frames 0:05:00,...
Answered my own question: it's possible to set custom compression keyframes in Apple Compressor.
Compression markers are also known as manual compression markers. These are markers you can add to a Final Cut Pro sequence (or in the Compressor Preview window) to indicate when Compressor should generate an MPEG I-frame during compression.
Source.
Could you not use chapter markers to jump between sections? Not an ideal solution but a lot easier to achieve.
You can use this software:
http://www.applesolutions.com/bantha/MH.html

Resources