Log in

View Full Version : Color Correction and 16:9 AR Cropping


FLM
13th September 2008, 14:32
Hello, everyone.
as you can see, almost a week ago I registered to this community after a long time that I use this website. nearly 7 years now.
Even though the community changed in this time span, I always wanted to thank you for all the help you provided me in the past via your guides on dvd ripping and tv capturing and still provide me help using these forums. you are brilliant. I learn A LOT from you.
whe people ask me for anything regarding video, I reply "Doom9.org". ;)

I capture tv shows with a basic analog tv card using a set-top box (ADB-7200C). I capture from the V.O.D Service using a SCART to S-Video Cable.

My Avisynth knowledge is very basic. I started learning it about a month ago.

I have a couple of questions regarding a video I captured:

1. 16:9 AR Cropping
I have a PAL MPEG-2 720x576i video file.
the video itself is a Letterboxed 16:9 (or is it?) with hebrew subtitles (I don't expect you to understand them :P) encoded into the video stream.
My intent is to convert this MPEG-2 to XviD and I don't want to waste bits on black borders using 4:3 AR.

Sample image:
http://xs231.xs.to/xs231/08376/s01e03483.png

as you can see, I need to retain the subtitles AND retain the 16:9 AR.
The problem is that some letters in the subs are overlapping into the bottom black border (look at the question mark, there is a long letter to the right of it), so I can't crop the image exactly to fit a 16:9 AR.

all I know is that I need to use Crop(), I just can't figure out the appropriate values.
if you need a better image capture, I'll upload on request.

2. Applying Color Correction to the above video
the colors of the video mentioned above are not to my liking.
I want the colors to be like this video:

Sample image:
http://xs231.xs.to/xs231/08376/s04e05438.png

I have been learning from a guide that in order to set the colors, I need to use Tweak().
the thing is that I want to get the colors right without the hassle of retrying over and over using VDubMod.
can It be possible to "transfer" the Tweak() values from one image to the other?
if not, it will help me a lot if I understood what I need to do in order to get the colors right with minimal retries.

I had some more questions I wanted to ask in this thread, but they'll have to wait.

In time, I hope to become an active member and help others with anything I can.
untill then, I'll take the time to know this community more... ;)

thank you in advance for any help...

Umamio
13th September 2008, 15:40
Hi FLM,

First of all I'm just wondering if those sample images are pure frame grabs / screenshots, as 725*583 and 724*452 are not dimensions that any capture card that I know of captures in natively and the second frame shows evidence of resizing interlaced material without field splitting.

Secondly, think of using avsp instead of vdubmod to test your scripts as it will allow you to view the effect of your script changes as soon as you have made them rather than having to save the avs, then switch to vdubmod, then refresh the video
(having said that, I use virtualdub (1.8.5) to check the audio plays correctly in my scripts)

It will be easier to suggest crop values to you if you post a screenshot at its original capture size (you mentioned 720*576)
But what I suggest, as for cropping, is to seek through the video quickly and find the lowest point the subtitles reach and crop from the bottom until that point.
If you prefer symmetry of black borders then crop from the top by the same amount otherwise crop all the black from the top and left and right.

The arguments for the Crop function are in the order (left, top, right bottom). So it would be something like

Crop(2,64,-2,-60)

You will not be able to retain a 16:9 AR (if the AR of the video element is in fact exactly 16:9), with this sort of cropping unless you add extra pillarboxing to the left and right, which somewhat defeats the purpose of removing black borders.
What you can do though is determine the aspect ratio of the frame without top,left,right, borders but including subtitles and set it as the display AR when you encode. The better media players should respect this value and display the video accurately.

If this is for a standalone xvid capable machine that ignores the AR flag just resize to as close to the subtitle-including AR as possible
i.e if (as a non-specific example) the AR with subs is 16:10 you could resize to 536x336

2. As for Tweak, you can't escape having to try out different values until you find some you like, but if you do it in avsp it requires much less effort than going through vdubmod.
I'm not sure what you mean by transferring the values of tweak, tweak will act on every frame of the video that you apply it to. If you mean transfer it between videos, you can just copy paste the Tweak values, but you may or may not have to modify them depending on the quality of the specific source video.

N.B: If you are only using vdubmod for its mpeg2 reading capabilities then you will have to run dgindex on your mpeg captures before being able to include them as sources in your avisynth scripts.

FLM
13th September 2008, 16:10
Thank you for your warm and helpful reply... :)

I see that I had to be much clearer when submitting the thread.

I'll try and be more specific:
I'm using Windows XP SP2
I have Nvidia Geforce 9600GT Graphics Card.

I'm capturing to 720x576 using Software MPEG Encoder (blahh).

I do index my mpeg2 using DGIndex (awesome program btw!) cause I don't trust DirectShowSource() to accurately process the file. :P

the video is in fact 720x576 interlaced.

the sample images are screen caps I made using alt+PrtScrn when media player 6.4 (mplayer2.exe) was open.
I know that I could have used any other Player that could capture the picture for me, but I wanted to capture the colors of the files when I'm watching the videos with mplayer 6.4.

after I captured the images, I opened the "Paint" application of windows and cropped the media player window and only included the image. that is why the images are not 720x576.

if I had captured the images with any other player, especially CyberLink PowerDVD, the player would capture the images with different color values.

about the 16:9 AR and cropping:
I did seek through the video quickly and found the lowest point of the subtitles - that's why I uploaded that sample image.
The letter near the question mark is the letter that slides into the bottom black border. It's very important to keep it.

I already did what you mention: I first Cropped the top black border and after that cropped the bottom black border using the same value of top border. I encoded a 5 sec clip for testing, and the video came out all uneven. the resolution I resized to was 640x352, which is not 16:9, I know. but that is as close as possible, I think. :\

My intent when encoding to XviD is for watching the video with the PC and with a standalone DVD player: APEX 811DVX. as far as I know and tested, when decoding xvid or divx, the APEX decodes them exactly as xvid codec or divx using Windows.

about color correction:
I always use vdubmod for encoding and avisynth for frameserving. what is avsp? :O
by "transferring the Tweak values" I meant that I want to minimise the tweaking of colors and maybe let an automated program or function to do it for me.
I would input the "Bad Image" and input the "Good Image" and it would take the "Good Image's" color values and apply them to the "Bad Image" - A bit confusing, I know, but I don't have any other idea how to describe it. :P

I want a function like this only because I don't know how to analyze an image and say "ok, this image need this amount of tweaking" - how do you guys do it? only manually?
if so, it's frustrating and time consuming. "\

Thanks again for replying, I'll try googlin' about AVSP in the meantime.

Umamio
13th September 2008, 22:12
First things first: can you upload a 5 second sample around the point with those subtitles?

Sagekilla
13th September 2008, 22:25
You can't "trasnfer" the characteristics of the good image to the bad. That's something in the area of AI almost.

sidewinder711
13th September 2008, 23:30
Regarding your color correction you might have a closer look at Colourlike (http://forum.doom9.org/showthread.php?t=96308) or HistogramAdjust (http://avisynth.org/vcmohan/HistogramAdjust/HistogramAdjust.html), like it was proposed here (http://forum.doom9.org/showthread.php?t=141103).

Greetz

FLM
14th September 2008, 11:19
Umanio: I can't find a free MPEG Cutting program which does NOT re-encode. Cuttermaran needs an Elementry Stream (.mpv,.m2v) and I don't have much space to extract a 3gb file to its elementry stream... :\
Can you suggest any other free cutting program which does not re-encode AND accepts MPEG-2 PS ?
I used a program called MPEG2VCR which accepts PS but it's commercial, 30-day trial. My trial is over. problem... :\

Update: I used DGindex to cut. i hope it does not changes anyting in the file. the file has no audio, you don't need it anyway. :P
here's a 2 second clip on FileFlyer:
http://www.fileflyer.com/view/PcDRIBb
In this sample video there's a comma in the subtitles. the comma is higher than the letter I need to keep and it too slides onto the bottom black border, as is of course the letter.
The best I could come up with is cutting about 60-65 from the tp and bottom and resize to 640x352 which is not 16:9 exactly...
hope you can do something about it and suggest any cropping values that would cut the black borders as much as possible.
thanks. ;)


Sagekilla: I did think it would be Impossible. I just thought that maybe custom functions can be made for this kind of need. :P
maybe it is as complex as AI... :D


sidewinder711: Thank you for the suggestions. I never managed to understand graphs and histograms, but will try them in my spare time.. ;)

smok3
14th September 2008, 13:27
like said before, you can't get to 16:9 without pillarboxing (or excessive cropping of the top, about 100px),
my try
http://resizecalc.somestuff.org/index.php?ssmw=720&sar=1.06667&sar2=&ssmh=576&CT=60&CL=6&CR=6&CB=46&mplayCrop=&trw=720&dar=1&dar2=&mod=&padw=&padh=&css=&doit=true
(btw, video is interlaced)

FLM
15th September 2008, 10:07
Why do I need Pillar Boxing ? the video itself is 16:9 if we don't include the letters that go over the bottom black border (The Letters I want to keep).
From what I know, Pillar Boxing is mostly for 4:3 material on 16:9 display devices. No?

Look, I don't mind having a little bit of black borders if the subtitles will be included and the picture will look like 16:9. meaning the way it looks when it is in its original MPEG-2 file.
I only want to have a 16:9 resoloution, 624x352 is ideal for a low bitrate IMO, so it will play without too many problems in any Standalone Player I will come across.

here's a 5 second XviD clip I tried to do:
http://www.fileflyer.com/view/HiOoiBc
I cropped top and bottom up to the substitles and resized to 640x352 (not 16:9).
The problem is that the Picture is not so much "wide screen". :p
That's the best I could come up with, without any other modification like pillar-boxing.

smok3
15th September 2008, 11:09
the video is obviously not 16:9, so what exactly is the question?

if the video was 16:9 then you could crop 72 px at the top & bottom,
http://resizecalc.somestuff.org/index.php?ssmw=720&sar=1.06667&sar2=&ssmh=576&CT=72&CL=&CR=&CB=72&mplayCrop=&trw=720&dar=1.42222&dar2=&mod=&padw=&padh=&css=&doit=true
that is not true in your case.

manono
15th September 2008, 17:34
all I know is that I need to use Crop(), I just can't figure out the appropriate values.
I use the Crop Function of Gordian Knot's Resolution Tab to figure the crop values. Just make sure that the Pixel Aspect Ratio is set for PAL 4:3. This isn't a 16:9 video. It's widescreen non-anamorphic PAL 4:3, as already stated several times. It's not even 1.78:1, but more like 1.66:1. With the burned in subs extending below the active video, you'll have to retain some black at the bottom. I don't know what resolution you want to use, but for 640x384, this works:

Crop(0,56,0,-48)
LanczosResize(640,384)

http://i163.photobucket.com/albums/t308/Tommydan1/DVDPics/Hebrew.jpg

The problem is that the Picture is not so much "wide screen".
This is even less "wide screen". But you can't just go around making them any resolution you might like. You should be making them what they are. This video is a total mess, by the way. It's encoded as progressive, but the source is interlaced. And the luma is royally messed up.

FLM
15th September 2008, 21:55
Ok, I seem to have a difficulty with this video.
I know this video is totaly messed up, you don't have to tell me. :P
that's why I came here, I knew that you are the only professional forum on the web for help with these things... ;)

I have a difficulty understand the concept of "Aspect Ratio" - my knowledge about it starts and ends with "4:3 meaning full screen" and "16:9 meaning widescreen".
I'd very much appreciate a clarification about what is "non-anamorphic" and what do I need to do in order to have a "widescreen resolution" for this video.
I want a "WS Resolution" only to not worry so much about compatibility with standalone hardware such as DVD-DivX Players and Media Streamers\Players that use a hard-drive.

manono:
thank you for providing me the crop values.
I have a couple of questions for you:
1. why did you totally cropped the top black broder?
Isn't a litle bit of a top is required for a "WS resolution"?
from what I know 640x384 isn't WS. will it be compatible with standalone hardware? :o

2.
A) What did you mean when you said "the luma is royally messed up"? Can it be fixed?
And how can I recognize this "defects" in the future?
it will help me a lot if I understood this...

B) Do you see any other defects I should be repairing for xvid encoding? please let me know.

3. About encoded as progressive, source is interlaced:
I know this "defect" and I can't figure out who's at fault: the TV Card or the software. :\
I Use a basic analog TV Card: Leadtek Winfast TV2000XP RM, it doesn't have a built-in MPEG Hardware Encoder.
I captured that MPEG-2 using ChrisTV's MPEG Software Encoder.

I fix this using ReStream and the process is terribly time-consuming. not to mention takes a lot of temporary HDD space. but I don't have any other solution.
I want to buy another card, Just can't decide on a good one. :\
so I know about the "problem" and hate it. :P

I didn't mean for this thread to be that nagging, please accept a beginner's apologies.
I thank you all so much for your endless patience. :) you are amazing... ;)

manono
15th September 2008, 22:49
I have a difficulty understand the concept of "Aspect Ratio" - my knowledge about it starts and ends with "4:3 meaning full screen" and "16:9 meaning widescreen".
Even what you think you know is wrong. There are plenty of widescreen 4:3 movies on DVD or shown on television. There are plenty of examples of "fullscreen" videos being part of a 16:9 video, documentaries especially, where the videos used might come from many different sources. Here, read these:

http://www.doom9.org/aspectratios.htm]
http://www.thedigitalbits.com/articles/anamorphic/anamorphic185demo.html

16:9 and 4:3 are Display Aspect Ratios (DARs) that tell the player how to resize the original 720x480 DVD or broadcast. If 4:3, it gets resized to 640x480 (480 x 4/3 = 640). If 16:9 it gets resized to roughly 854x480 (480 x 16/9 = 853.33).
1. why did you totally cropped the top black broder?

You're making a AVI (right?), so, if possible you want to crop down to the active video. Unfortunately, because of the subs extending below the active video it's not possible to do a complete crop along the bottom.
Isn't a litle bit of a top is required for a "WS resolution"?
What is it with you and this widescreen fixation? You make it what it is.
from what I know 640x384 isn't WS.
From what I know it is. There have been plenty of 1.66:1 movies released, which is, I believe, the narrowest widescreen ratio commonly used. This one, cropped to the active video along the bottom is about 1.70:1. The video was perhaps cropped by the DVD production company or someone else because that's an unusual resolution. I don't know what the definition of widescreen is. Anything wider than Academy Ratio (1.37:1)? Anything wider than the halfway point between 1.33:1 and 1.78:1 (roughly greater than 1.55:1)?
A) What did you mean when you said "the luma is royally messed up"? Can it be fixed?
You have crushed blacks and blown out whites (the subs), but at the same time it just seems too dark overall. The damage has already been done, but I think I'd maybe I'd reestablish the luma at 16-235 and use AGC on it.

http://i163.photobucket.com/albums/t308/Tommydan1/DVDPics/HebrewAGC.jpg

Crop(0,56,0,-48)
LanczosResize(640,384)
Tweak(Coring=True)
HDRAGC(Corrector=0.8,Reducer=1.5)

Since it's interlaced, you either have to deinterlace it first or do an interlaced filter and resize. Since this is for AVI, probably deinterlace it. But there's not really enough of a sample there, and not enough movement for me to be able to tell if it was shot using PAL video cameras, or if it's interlaced for another reason (bad standards conversion). It's probably true interlace, though. And if anyone wants to present a different or better way to improve it, I'll happily bow to their expertise.

FLM
15th September 2008, 23:10
I know that the picture is terrible, that is why I wanted to correct the colors. I didn't know anything about this luma problem.

I do want to make a XviD avi from this MPEG - I totally understand I need to do some serious tweaking of colors to get the best out of it. I just need some guidance in this matter.

about deinterlace: I do use a deinterlacer. do you have any suggestions for a good deinterlacer?
from my experience, leakkernelDeint() gives a good image without blending but give some artifacts... :\

About my WS "fixation" and the reasons behind it:
I want this xvid to be compatible with standalone hardware.
I want the resolution to be 640x wide cause the xvid bitrate I want is no more than 1200k.
for compressibility, I need a low resolution but not too low, a maximum of 640x is ok, from my experience and compressibiity checks.

I want to have the picture cropped as much as possible and still retain somewhat of "balance" - not too stretched out or too "square" as with 4:3.

I will gladly provide you with more video samples. Just tell me what you need exactly.

to make things worse (or easier?), I have another episode from this same tv series which has the subs placed on the video correctly.
example:
http://www.imagebam.com/image/1db8de13412261
what resolution should I use for this episode?

thanks again :)

manono
16th September 2008, 00:38
I totally understand I need to do some serious tweaking of colors to get the best out of it. I just need some guidance in this matter.
The sample didn't have much color, so I don't know what, if anything, needs to be done with the colors.
about deinterlace: I do use a deinterlacer. do you have any suggestions for a good deinterlacer?
LeakKernelDeint is good. I use Yadif. Those 2 along with TDeint are probably the fastest decent deinterlacers.
I want this xvid to be compatible with standalone hardware.
Most standalones are OK with AVIs less than the max 720x480/576.
I want to have the picture cropped as much as possible and still retain somewhat of "balance" - not too stretched out or too "square" as with 4:3.
Again? For the 3rd time, make it what it is.
what resolution should I use for this episode?
I didn't get the sample. I already told you how I figure the crops and resizes for AVI. Perhaps someone else has some words of wisdom for you. Good luck.

FLM
16th September 2008, 16:03
Ok manono, thank you very much for all your kind help :)
I will read the links about aspect ratio you posted and will do the resolution as you told me: 640x384- top border totally cropped.
about the colors: I will look more into HDRAGC and ColorLike and will try to find a good balance.

Thank you all very much for the help :)

MGarret
18th September 2008, 16:04
From the second image sample (with good position of subs) I think that this is not even 1,66:1. When you crop black bars correctly in image editing program you get 768x488 which is 1,57 and more like 14:9 format. BBC is using 14:9 format for broadcast for some of their program. If I were you I would chose something other than 640x384.

Mug Funky
20th September 2008, 17:37
have fun matching the colour in something shot on video with something that looks to have been shot on a reasonably low contrast, high latitude film... you'd have to have different settings for each shot, combining RGB adjustments in shadows, gains and gamma correction, as well as keying blown highlights and faking information in them... quickest way would be to add green to the blacks, raise the gamma and probably turn the overall saturation down slightly. but video doesn't like being forced to look like film, and even with colour specific software and special hardware (grader's balls), it's a very difficult task. that's without going into the lighting and different characteristics of the lenses used... 35mm film is a much larger "sensor size" than any video camera on the market and will have a profound effect on the "feel" of the picture.

as far as blowing up to 16:9, that's not too hard so long as you don't mind the picture getting softer. you'll have to deinterlace first though.

my inclination would be to just pop a bit of contrast in there, denoise it just for the sake of the encoder not dancing around in the blacks, and leave it at that.

...that's my 2 cents as i'm stuck at work on a saturday night :)

FLM
20th September 2008, 20:48
How can an Aspect Ratio be calculated? I'm trying to figure out how you look at an image and know its ratio is 1.66 or 1.70 etc... is there an article about this?

Mug Funky:
You must have a really boring and frustrating job if you managed to summarize what needs to be done for the colors to match, or you just damn briliant and knowledgable... :P

I tried using HDRAGC as suggested here and the settings brightens too much and overall the filter is very slow. I'll try to use Tweak as I see fit.
thanks for the help and suggestions.

45tripp
21st September 2008, 01:47
it seemed to me bright was the aim from the first pics posted.

anyway, a try:
http://www.mediafire.com/?iyiznntzmyz

regarding aspect,
you'd know for sure if you could find a reliable source stating what it is.
otherwise,
look for round objects, and eyeball it.

what's the movie btw?
it almost looks interesting. at least the first screen grab.


tripp