Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: JB on August 22, 2018, 03:23:14 PM

Title: Bug in the image export as a jpg ???
Post by: JB on August 22, 2018, 03:23:14 PM
Hi,

i was using your awesome tool avidemux 2.7.1 on windows to capture images from shows and i figured that the image exported in jpg have a different color histogram than the same image exported in png or bmp. The bmp and png look the same and have the same histogram (or very close) but the jpg is more whitey or blemish, less vivid like the color were washed with grey. the bmp or png look the same a the vlc snapshot so i think there is something wrong with the jpg. It happens with all the shows i tested mp4 or x265.

any ideas?

JB
Title: Re: Bug in the image export as a jpg ???
Post by: eumagga0x2a on August 22, 2018, 03:44:56 PM
Getting colors perfectly right is not possible. We have to deal with rounding errors of colorspace conversion when saving as PNG / BMP or with additional compression artifacts when saving as JPEG.
Title: Re: Bug in the image export as a jpg ???
Post by: eumagga0x2a on August 22, 2018, 05:49:51 PM
It looks like we end up with a wrong color range when saving to JPEG and this is not simply corrected by setting color_range to AVCOL_RANGE_JPEG in AVCodecContext and/or in the AVFrame we pass to the encoder. Will look into it, this bothers me too.
Title: Re: Bug in the image export as a jpg ???
Post by: JB on August 23, 2018, 03:38:07 PM
Thanks for the clarification, i"ve come up with a quick fix, i export in png (no real visual difference with the bmp save the size) then i batch convert with imageMagick. This way i have the  same size as the avidemux jpg export but the same color range as the png export (or vlc).

Now the tricky question, since i exported lots of jpg in the wrong color space before finding out the color difference, do you think i can reconvert them to the good color space since i have still the original vids ? or does the jpg export lose some of the colors?
Title: Re: Bug in the image export as a jpg ???
Post by: eumagga0x2a on August 23, 2018, 04:02:47 PM
JPEG export is always lossy, you better use png as an intermediate. You could also just add the "contrast" video filter, press the "MPEG2 -> PC" button in its configuration dialog as well as "Play Filtered" button in the main window and save JPEGs with already stretched range.

The issue is really that most MPEG videos use the limited range and it is up to the player to stretch it to full (or not). The video in the preview window in Avidemux has already the range stretched, saving as JPEG reveals rather the true colors (colorspace conversion, necessary for saving as PNG seems to correct the range automatically).

I've attached a sample 1280x720 jpeg image. When loaded in Avidemux, the two rightmost stripes turn into a single white one in the preview. When saved as JPEG, you get the correct picture.
Title: Re: Bug in the image export as a jpg ???
Post by: JB on August 24, 2018, 02:27:54 PM
Now, i"m confused

when i save your sample.jpg in png, i have the same result as the preview :  the two rightmost stripes turn into a single white one
meaning i lose color precision.

i can"t do : You could also just add the "contrast" video filter, press the "MPEG2 -> PC" button  because this option is not available with my videos or your sample.jpg (i cannot select it in the menu)

but the awesome news is that if i load the washed out jpgs back and save them to png the "real" colors come back then i convert back to jpg with imagemagick and i have even a smaller size with the vivid color. Thank you for giving me the idea to load an image in in avidemux, i"d never thought of that.

so i don't understand but it works the way i need, so good. If you have some refs to explain further how colorspace conversion works in avidemux or in general that may help though
Title: Re: Bug in the image export as a jpg ???
Post by: eumagga0x2a on August 24, 2018, 02:57:19 PM
Quote from: JB on August 24, 2018, 02:27:54 PM
i can"t do : You could also just add the "contrast" video filter, press the "MPEG2 -> PC" button  because this option is not available with my videos or your sample.jpg (i cannot select it in the menu)

Filters are not applicable and thus disabled in copy mode. Select a video codec first.

The main conclusion from my testing is that "washed out" colors of exported JPGs are the true colors. Vivid colors of the video preview are made up by the invoked renderer.
Title: Re: Bug in the image export as a jpg ???
Post by: JB on August 25, 2018, 04:28:36 PM
good to know, the confusing part is that video preview and vlc have the same made up rendering.