FFMPEG Support of JPEG-XL

 

JPEG-XL is the recent alternative to the old JPEG. JPEG-XL exploits variable DCT size, advanced entropy coding, adaptive quantization, loop filters (to eliminate blockiness).

The sources of JPEG-XL are here  , the binaries (incl. for Windows) are here   . 

How to build JEPG-XL codec (cjxl and djxl) in Windows with Visual Studio 2019?

  •         git clone https://github.com/libjxl/libjxl.git
  •           with Windows PowerShell run  deps.sh to copy necessary tools (e.g. libpng to work with png-files)
  •          mkdir ‘build’ directory
  •          go to ‘build‘ folder and run:

    cmake .. -G "Visual Studio 16 2019" -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_TESTING=OFF

  •            open Visual Studio solution LIBJXL.sln
  •            build all, incl. cjxl (encoder) and djxl (decoder).  There is one issue, in the project jxl_extras_codec-static it’s necessary to change output lib-file to jxl_extras_codec.lib instead of jxl_extras_codec-static.lib

 

The folder of binaries contains dozens binaries, but we need: cjxl.exe  is JPEG-XL encoder and djxl.exe is the decoder.

Selected parameters of cjxl.exe:

-d         target visual distance in JND units, 0.0 equivalent to mathematically lossless, 1.0 to visually lossless.

-q         quality setting, higher value = higher quality. This value is internally mapped to –distance. 100 equal to mathematically lossless. 90 to visually lossless.

-e          encoder effort setting (like presets in x264/x265). Range: 1 .. 9.  Higher numbers more encoding time.

Example [ encode input png-file in lossless mode]

cjxl.exe        kindzadza.png      kindzadza_lossless.jxl     -d 0.0    -e 8

JPEG XL encoder v0.9.0 97e5ab0 [AVX2,SSE4,SSSE3,SSE2]
Encoding [Modular, lossless, effort: 8]
Compressed to 87690 bytes (8.296 bpp).
397 x 213, 0.213 MP/s [0.21, 0.21], 1 reps, 12 threads.

 

Example [ encode input png-file in visually lossless mode]

cjxl.exe   kindzadza.png     kindzadza_vlossless.jxl -d 1.0 -e 8

JPEG XL encoder v0.9.0 97e5ab0 [AVX2,SSE4,SSSE3,SSE2]
Encoding [VarDCT, d1.000, effort: 8]
Compressed to 22182 bytes (2.099 bpp).
397 x 213, 0.569 MP/s [0.57, 0.57], 1 reps, 12 threads.

 

Example [ decode jxl-file into png-format]

djxl.exe     kindzadza_lossless.jxl         test.png

 

In addition to cjxl.exe and djxl.exe a special tool  jxlinfo.exe is compiled to get information on jxl-file (encoded JPEG-XL files)

jxlinfo.exe      baboon.jxl
JPEG XL image, 512x512, lossy, 8-bit RGB
Color space: RGB, D65, sRGB primaries, sRGB transfer function, rendering intent: Perceptual

 

FFMPEG Support of JPEG-XL

Note:  the recent version of ffmpeg supports JPEG-XL (pls. take the recent version builds ffmpeg-git-full from here)

DEVILS jpegxl JPEG XL (decoders: libjxl) (encoders: libjxl)

 

  • Encode with ffmpeg in lossless mode:

ffmpeg -i kindzadza.png -c:v libjxl   kindzadza_ls.jxl

with distance of 1 JND (visually lossless mode):

        ffmpeg -i kindzadza.png -c:v libjxl -distance 1.0 kindzadza_vls.jxl

lossless with preset complex:

ffmpeg -i kindzadza.png -c:v libjxl -effort 7 kindzadza_vls.jxl

 

  • Decode jxl-file with ffmpeg

ffmpeg   -i kindzadza_ls.jxl    -c:v libjxl    kindzadza_ls.png

Leave a Reply

Your email address will not be published. Required fields are marked *