Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Apr 2024
Posts: 324
|
JPGs Closest to PNGs
I decided to use JPGs to save space for my computer. Which software or tools make JPGs from videos that most closely resemble or look like PNGs, ffmpeg, Shutter Encoder, VirtualDub2, Imagemagick, or something else?
|
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 254
|
Most JPEG encoders can make JPEGs that, while lossy, can't be told apart from or closely resemble lossless sources, such as PNG or BMP. Usually, a quality of 95 or upwards, along with 4:4:4 sub-sampling, does the trick. But, since you are concerned with size, Google's Jpegli compresses a bit better than classic JPEG encoders, using some tricks from JPEG XL to gain more compression while creating compliant JPEG files.
In short, convert the video to a sequence of PNGs. Then use cjpegli to encode the JPEGs. Code:
:: BAT file that converts PNGs to JPGs mkdir "out-jpegli" for %%i in (*.png) do ( cjpegli "%%i" "out-jpegli\%%~ni.jpg" ) pause Last edited by GeoffreyA; 15th January 2025 at 13:36. |
![]() |
![]() |
![]() |
#3 | Link | |
Registered User
Join Date: Apr 2024
Posts: 324
|
Quote:
|
|
![]() |
![]() |
![]() |
#4 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 254
|
I haven't tested quality myself, but according to Rosato's limited tests, it is on par with MozJPEG, which has, presumably, higher quality than the old reference libjpeg-turbo. If you look at the graphs, Jpegli 444 seems to have a slight edge in the higher-fidelity regime.
|
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Aug 2024
Posts: 361
|
I think mozjpeg just tuned some default settings of libjpeg-turbo to better suit the "web use".
Now I think that it's not a good choice for "highest quality" use... and if jpegli is similar to that, it's not a good choice too. Luckily mozjpeg provides a flag "-revert" to revert settings to default libjpeg-turbo settings. (you'd want to enable -progressive to optimize the filesize) (Yes, -progressive optimizes filesize better than -optimize, and they both won't change the encoding quality) |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 254
|
Apparently, Jpegli makes its gains through adaptive-quantisation tricks from JPEG XL, along with different quantisation matrices and calculating at higher precision.
EDIT: I put together a quick, haphazard, and very poor comparison. I couldn't find out how to disable subsampling in libjpeg-turbo CLI, not being familiar with it, so I created the JPEGs in GIMP, the settings being 4:4:4 subsampling, floating-point DCT, and optimise. Qualities were 90 and 50. For cjpegli, I left it at default, which, I believe, is using 4:4:4, along with qualities of 90 and 50. The sizes of the resulting JPEGs are different, especially so in the case of quality 50, so it's not a proper bit-for-bit comparison. https://slow.pics/c/SMqBCK7P Last edited by GeoffreyA; 17th January 2025 at 11:53. |
![]() |
![]() |
![]() |
#7 | Link |
Registered User
Join Date: Apr 2024
Posts: 324
|
So which type of jpg has the higher quality, then?
Also, can anyone tell the difference between the PNGs and the cjpegli/Google's Jpegli JPGs? https://slow.pics/c/Uirx1Otf |
![]() |
![]() |
![]() |
#8 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 254
|
libjpeg-turbo may have better quality than Jpegli, but I think it's subjective and depends on what one views as noise or detail. Increasingly, at lower quality settings, Jpegli softens the picture. It's evident in that grainy shot of Naomi Watts above. Anime may paint a different story.
Quote:
Here's a BAT script to try libjpeg-turbo: Code:
mkdir "out-jpeg" for %%i in (*.bmp) do ( cjpeg -quality 95 -optimize -progressive -sample 1x1 -outfile "out-jpeg\%%~ni.jpg" "%%i" ) pause * Using 7-Zip, extract the installer archive. No need to install anything. * From the "bin" directory, copy "cjpeg.exe" and "jpeg62.dll" elsewhere to use with the BAT script. * The source images must be BMP. Last edited by GeoffreyA; 19th January 2025 at 18:12. |
|
![]() |
![]() |
![]() |
#9 | Link | |
Registered User
Join Date: Apr 2024
Posts: 324
|
Quote:
https://slow.pics/c/b3UgbRzG |
|
![]() |
![]() |
![]() |
#10 | Link |
Registered User
Join Date: Oct 2012
Posts: 8,287
|
jpegli is just plain bad. libjpg turbo does a good job here.
this is not an optimal test for this. this is from a video file which already has similar issue which jpg will create. plus chroma scaling and dithering... yes i can tell the difference in such a comparison but only jpegli is sticking out. |
![]() |
![]() |
![]() |
#11 | Link | |
Registered User
Join Date: Apr 2024
Posts: 324
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 | Link |
Registered User
Join Date: Oct 2012
Posts: 8,287
|
line definition is different. you can see more noise around lines.
there is also a very tiny tint difference looks like jpg needs to do it's thing in YCbCr. looking at the file size using jpg turbo at these settings is not worth it. jpegli is using 1/5 to 1/10 of the bit rate that not a fair comparison. |
![]() |
![]() |
![]() |
#13 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 254
|
Quote:
To address the concern of the file sizes being different, I made another comparison with the files from libjpeg-turbo and Jpegli being almost the same size, using the "--target_size" switch. (First, I created the JPEGs with libjpeg-turbo, then passed those sizes to cjpegli. PNGs were converted to BMP with Paint.) https://slow.pics/c/mlv3y3nO Another one using huhn's picture from the chroma tests: https://slow.pics/c/Ao9ROYh9 Last edited by GeoffreyA; 20th January 2025 at 08:18. |
|
![]() |
![]() |
![]() |
#16 | Link |
Registered User
Join Date: Apr 2024
Posts: 324
|
Well, for my comparison, I converted a video into a PNG image sequence and converted 5 of its frames to JPG using cjpegli. Then I converted the same video into a BMP image sequence and convert the equivalent frames to JPG using libjpeg-turbo at quality 100.
Was there a problem with what I did? |
![]() |
![]() |
![]() |
#18 | Link | |
Registered User
Join Date: Apr 2024
Posts: 324
|
Quote:
https://slow.pics/c/DMiPkg0u |
|
![]() |
![]() |
![]() |
#19 | Link |
Registered User
Join Date: Aug 2024
Posts: 361
|
JPGs closest to PNGs is lossless JPEG (yeah, it's a thing)
Edit: There's no encoder I know of that can do it, although libjpeg does provide a lossless option it doesn't look like it's working (at least not as simple as I thought). Even if you successfully encode one the compression ratio will be worse than PNG, I guess. Confusing answer for confusing question, that's what you get. All that aside, there's RGB JPEG that will be your friend to get as close as possible to PNG, because the error and precision problem of colorspace conversion will be gone. (and the file size is already dangerously close to original PNG at quality 100 and it's still lossy LOL the lossless JXL will beat it to the ground) If you want you JPEG to be closest to the video, if the video is YUV 8bit then just use original YUV data, if the video is YUV 10bit then... it's comlicated LOL. You want JPG close to PNG or close to video? or close to pNG which si close to video? FFS Last edited by Z2697; 2nd February 2025 at 23:54. |
![]() |
![]() |
![]() |
Tags |
image-quality, jpeg, png |
Thread Tools | Search this Thread |
Display Modes | |
|
|