View Full Version : MJPEGcorrect filter
obiwan71
28th June 2002, 20:33
Well, I have just tried this filter. And I keep asking myself questions...
This is the image I get when NOT applying the filter:
http://sbouf.free.fr/sans_mjpegcorrect.jpg
This is the image I get when applying it:
http://sbouf.free.fr/avec_mjpegcorrect.jpg
(This is also what I get when just opening the captured file in VirtualDub without using an AVS script)
I have read this : http://www.inmatrix.com/articles/ivtcsynth1.shtml
1/ But...what puzzles me is that the picture at the top is much more like the preview I get during the capturing process.
2/ What is also striking is that the image displayed when playing the captured file is the same color as the first picture.
3/ And the image displayed by the TV set resembles the...second one (is this a matter of connection too ?)
So...where is the truth ? Where are the actual colors ?:confused:
obiwan71
30th June 2002, 09:29
Users of DVB cards can also tell me what they think about it...:)
baz00ie
3rd July 2002, 23:34
Hey mon,
the second JPG should be correct.
To test this, use a video editor to create a few seconds of color bars - then render as a MJPEG video file.
Next load the video into VirtualDub and save out a targa or bmp file to load into a paint program. From the paint program you can get an exact reading of the color values.
The video loaded directly into VirtualDub should give you correct values for Red, Green and blue - while the video loaded thru Avisynth (without filter) should give you incorrect values.
p.s. Thank you for pointing me to this MJPEG-corrector, i have been looking all over for just such a filter.
thanks
baz
obiwan71
4th July 2002, 10:26
Thanks for the reply first!
I see what you mean when you say: "the second JPG should be correct".
Yet, why is it that the colors in the second picture should be that "washed-out"? As you can see, black is not pure black, and the same can be said about the whites. The first picture, as well as the image displayed in any preview window, have strongly contrasting colors.
So...I am (also) wondering: is there a link between the encoding process (MJPEG) and the subsequent rendering of colors? It would surprise me (think of a black picture - create one in a photo editor and compress it in the JPEG format...).
(PS: the quality of the source does matter, of course. My source is digital satellite. That is why I was asking DVB card users about this specific issue...)
baz00ie
4th July 2002, 15:31
Well, let me tell ya what i've come up with..... Now, i'm sure it ain't perfect, and if someone else has a better idea, please come foward.
When you playback a MJPEG video thru Media Player or the like, the contrast and brightness is alter from the original. It's not the codec, and it's not the satelite feed, it's the way Windows deals with that codec - perhaps it's a directshow filter or the Microsoft video renderer. But in any case what you're seeing in the playback window is WRONG!!
If however, you were to directly convert that same video into a MPEG1, MPEG2 or DivX format, the contrast and brightness would not be altered when played back - it would look like the "the second .jpg". What you would see is the original color balance AS IT WAS CAPTURED!!!! This is important. This is what you want.
To deal with the situation, i do the following.
I capture the video using VirtualDub with "UYVY" as my format and MJPEG as my codec. Before i capture, i select "preview" mode under the "video" menu and then set my 'source' settings for brite, cont, sat and hue. This gives me the closest representation as to what the final output video will look like.
Next, go back to "overlay" mode and begin capturing.
MJPEG looks incorrect during playback, but that's OK, because it's not a good choice for such a thing. I use MJPEG for capturing and for creating a MASTER copy of the final video,... from which, i create other formats such as MPEG1, MPEG2 or DivX for playback.
VirtualDub's "preview" mode is the key, it shows you exactly what your computer is seeing,.. color wise. Other capture software may have a similar option, but if they don't, try VirtualDub for you capturing.
I know my response isn't very technical, but it might help you see what's going on and how to deal with it.
good Luck
baz
obiwan71
4th July 2002, 21:06
OK. Thanks again for those comments. :)
Before i capture, i select "preview" mode under the "video" menu and then set my 'source' settings for brite, cont, sat and hue. This gives me the closest representation as to what the final output video will look like.
Well, you must be right. In fact, I have got the same observations when using FreeVCR and its "preview" mode.
So...
Whether:
1/ The digital signal is not THAT good (talking of contrast or colors; comparison with DVD?).
Or
2/ The connection and the capturing process itself DO matter (and what about compression? It would not alter colors that way...).
I hope DVB card users might read this thread and post screenshots. It would be quite telling!
Zhnujm
5th July 2002, 21:46
just tried it with a dvb capture:
-without the filter the picture is ok
-with the filter it is washed out
(both via avisynth mpeg2source).
so the filter is definitly the cause of the washed out colors.
but anyway, you say your source is digital sattelite so i think you also use a dvb card. so what wonders me is how can you use freevcr for capturing and get a mjpeg avi file out of your dvb card ??
i hope you dont want to say you capture the video out of your dvb card with an analog tv-card :scared:
Darksoul71
6th July 2002, 21:34
Hi obiwan71 !
Sorry for my late reply. I´ve been reading your PM a while ago but I was busy with my exams. Personaly I don´t get it. May be I´m legaly blind but could you please eplain what the problem is with your capture ?
What shall the MPEG filter do ? Shall it correct any color space problem ?
Greetings,
D$
obiwan71
8th July 2002, 13:25
To Zhnujm:
but anyway, you say your source is digital sattelite so i think you also use a dvb card. so what wonders me is how can you use freevcr for capturing and get a mjpeg avi file out of your dvb card ??
Well...Don't worry. :D
I'm using an ANALOG card (DC10+) to capture video out from a satellite receiver (quality shouldn't be downgraded much). That's why I was asking people like you, who can easily copy the MPEG-2 stream direct to disk...it should be the "original" picture.
If you could post a screenshot (taken from the MPEG-2 file, of course), it would be great!
To Darksoul71:
This is a summary:
Well, this is not such a "problem" but it is still annoying (and strange). The MJPEG capture processed through AVIsynth looks great, with contrasted colors, while the colors seemed washed out when opening the file into VirtualDub. Then...where are the actual colors? And a few other questions relating to it: how does connection matter? Could the MJEG codec be THAT degrading/lossy that black is not...pure black, (or close to)?; how does the satellite signal look like when using a DVB card? You may be very interested in those questions, since you also use a MJPEG codec for capturing...
Zhnujm
8th July 2002, 21:32
sorry obiwan71, but you wouldnt believe how much people do exactly that ;)
here is the pic, the left without the filter
maybe your mjpeg file doesnt need a correction with this filter ?
obiwan71
9th July 2002, 00:39
OK! Thanks a lot for those pictures. "Black is black"...on the first one! :D
maybe your mjpeg file doesnt need a correction with this filter ?
Well...unfortunately, what I would say is : it DOES need a correction...in a way, but the source of all could very well be the MJPEG codec itself, since colors would be altered during the capture. The MJPEGcorrect filter would then be needed to restore those...altered colors, whereas the picture decoded through AVIsynth would look...the way it has been intended to!
It would be quite interesting to see what happens when using other codecs, especially a lossless one, like Huffyuv...
baz00ie
9th July 2002, 17:23
Guys, guys, relax!.... You've not been listening to what i've been saying.
The MJPEG codec is not at fault!!! the color difference occurs when the video is passed throught the Microsoft Video Renderer!!!. This is why i suggested the test with the color bars. It's the video renderer NOT the codec.
Either download some color bars or have them created in your editor. once that is done, render both a Huffyuv video and a MJPEG video. When you play them back in WMP the color values will be different, BUT, when you load the video files directly into VDub the color values will be correct as well as identical to the original color bars - Color bars exist to help with just such a problem.
It's IMPORTANT not to use your video player to judge what is correct when dealing with MJPEG and Microsoft. What you see in VDub is correct - trust VDub.
And remember, MJPEG use to be the industry standard befor MPEG2 came along - that's why i say, "the codec ain't the problem"
And YES Avisynth needs the MJPEGcorrector, otherwise the black values will get crushed and you will lose detail in your image. The MJPEGcorrector is a damn good thing and i have been looking all over the internet for just such a pluggin. the only problem is i don't know who created it- i'd like to find out so that I can thank that person.
(re-read my earlier posts)
Later
baz
Zhnujm
9th July 2002, 21:22
well, what i wanted to show with the picture is that the filter DOES change the color values.
for both files i used avisynth mpeg2source, the only difference is the filter.
so would you say that in fact the picture on the right side is "correct" and the picture on the left is only darker because its processed via avisynth ? (talking of a mpeg-2 source)
WarpEnterprises
9th July 2002, 22:30
Maybe I have some other clues.
From my tests I thought the strange colours always occur when the source video is in YUV-format.
I did the following test:
Made a mpg with: .avs (ColorBars) fed into TMPG,
there the option "Output YUV data as basic YCbCr not CCIR601" checked [when I do not check this Black doesn't look black on my TV so it can't be the setting which uses the whole colour space].
Then fed this mpg in DVD2AVI, tried both PC and TV scale conversion as d2v-project.
Made BMP with the built-in function and compared the 3 darkest grey stripes.
On setting "PC" the RGB values were: 7,0,7 0, 0, 0 9, 9, 9
on setting "TV": 7,7,7 16,16,16 24,24,24
Using mpeg2dec and feeding to VirtualDub the results were:
0,0,0 0, 0, 0 9, 9, 9
regardless of the TV/PC setting (of course because this should only affect YUV->RGB in DVD2AVI, but in my example the conversion is done either in Avisynth or VD).
So it seems that only the conversion done by DVD2AVI in "TV" scale gets the full colour range
The 7,0,7 for the DARKEST part seems like some calc error, and the conversion in mpeg2dec seems to cut off the darkest parts or ASSUMES a "CCIR601" colour range where no such dark parts occur.
It doesn't help to do Levels in avisynth, the dark colours are lost!
Now, what's really wrong?
Wilbert
10th July 2002, 09:48
As to what baz00ie said, have a look at this thread:
http://forum.doom9.org/showthread.php?s=&threadid=27932&highlight=huffyuv
Is this of any help?
obiwan71
10th July 2002, 17:27
I'm getting lost...:scared::D
Anyway...the pictures posted by Zhnujm showed one thing: the original picture and colors are those on the left, aren't they?
THE question is: how is it that after capturing we get...something so much different? By the way, baz00ie, you've talked of "losing detail" in the picture. What makes you say so? This is something about colors and contrast, not detail, isn't it? Would you say that the picture on the right, that with washed out colors, looks better than the other one? (I know that it should look that way after applying the correction filter...)
Plus don't forget that Zhnujm's pictures were taken direct from the digital source; which is slightly different from an analog capture, and which may lead us to think that the codec "is at fault".
baz00ie
10th July 2002, 20:51
OK, one more time.....
Now, the original question was, "What is the correct image when i capture video on my hard drive?" "What is the Truth?"
This is important to understand, because there are many different filters, players and editors that may effect the way the image looks when you view it on your computer.
What We need to know is "What does the RAW VIDEO DATA coming into your capture card look like and what does the RAW VIDEO DATA as it sits on your Hard Drive look like - without any influence by playback filters or renderers?" "And how do the two compare?"
The best way to accomplish this is to use "preview" mode in your capture software to adjust your 'brightness, contrast, hue, and saturation - then begin to capture. NEXT, you load the video DIRECTLY (under "file" select "open video file") into VDub to see if the RAW DATA matches what came through the card. Don't use Avisynth to load it in. Don't use Mpeg2dec to load it in - or anything else of that nature.
Feeding the video through some filters and/or some conversion software and then telling me that what you are seeing is the original RAW DATA doesn't cut it.
"What is the truth?" Follow the method as described above and you will find the truth.....
******************
Now the loss of detail question....
If you have a scene in a movie where someone is hiding in a dark corner of a room, there are going to be slight, varying degrees of light and shadow on and around them. If the black levels are not handled correctly then the details that describe the shadowy outline may get lost. You end up with one big dark area instead of a person hiding in the shadows - the black levels have been 'crushed' into one level. Trying to recover the image after the black levels have been 'crushed' is next to imposible. It's much easier to add contrast then to remove it.
This can also be observed when characters are wearing dark clothing. If the black levels get 'crushed' then you will lose the detail that shows the folds of the fabric. With proper black levels, however, the video image will maintain those qualities that give it depth and subtlety.
I've said my piece, and that's all.
later dudes
baz
obiwan71
11th July 2002, 20:15
OK, bazz00ie, thanks for those explanations again. I see what you mean.
Anyway, it's not that easy! :D
Perhaps I shouldn't bother and encode through AVIsynth without applying any filter at all. The image I get then looks nice to me. Since all I want is getting sharp(er) contrast and getting rid of those washed colors, that's probably what I should do.
And what do you think would happen when using a lossless codec rather than MJPEG?
Zhnujm
11th July 2002, 21:16
made a few tests that maybe help or confuse even more...
i capture the dvb comp out with a analog capture card and load it directly in vdub.
1: mjpeg capture: limited color range (around 15 to 250 RGB), "washed out" colors on monitor
2: huffyuv capture: correct colors (looks like the original mpeg-2 data)
now i convert the mjpeg capture to huffyuv
1: full processing mode (vdub does yuv->rgb conversion) -> huffyuv file with limited color range
2: fast recompress (vdub does no color space conversion) -> huffyuv file with correct colors
now i convert the captured huffyuv file to mjpeg
1: full processing mode -> mjpeg file with correct colors
2: fast recompress -> mjpeg file with limited colors
you can also replace the huffyuv codec with xvid or divx, its the same
maybe someone with enough free time can explain this. :D
WarpEnterprises
12th July 2002, 08:54
It seems that every YUV-program/codec assumes one of two (0-255 or 16-235) color ranges in the YUV-data, and when there are multiple conversions (as in nearly all cases you mentioned) each one must assume the right scale.
As far as I know only the VFAPI-plugin for DVD2AVI can be set as you like.
In the other cases you must use some level-adjust filters, which of course can be "too late" if the conversion cutted of some color range.
Btw somewhere I read the MJPEGCorrect filter has been made for some spatial error most visible in cartoons, but I can't find the page anymore.
obiwan71
12th July 2002, 10:44
One interesting thing to add:
When you do a space color conversion in Avisynth (YUV to RGB), which is unnecessary (or should be at least), it has NO effect on the colors.
McQuaid
18th July 2002, 18:53
Ok, I didn't read every post but the thing you guys are talking about stems from video overlay.
Actually there are 2 things going on but I'm not sure if they are both due to video overlay.
It's clearly evident video overlay is at work in the before/after pictures of the woman. The black looks dark grey. Video overlay has seperate brightness settings from your desktop. By default most cards seem to have videooverlay set slightly higher than the desktop. On my old v3 for example the video overlay was set to 1.3. I set it to 1.0 and its fine now.
The second issue has to do with post filtering, I don't think this is related at all to video overlay but I could be wrong. I believe its defined at the codec level. For example, when playing a divx, you can muck with the brightness, sat, etc but more importantly you can set how intensive a cpu operation it is during playback through the quality slider. The more you increase this, the more post filtering is done. This is normally considered a good thing as it will attempt to get rid of macro blocks and other video anomolies. DVD playback also has post filtering and I'm pretty sure standalone dvd players do as well. Yes, when post filtering is done, you are not seeing the unaltered original but it usually equates to more pleasing playback quality. Just make sure your video overlay brightness isn't set too high.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.