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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th October 2002, 16:25   #1  |  Link
Swan
It's more fun to compute
 
Swan's Avatar
 
Join Date: Apr 2002
Location: Scandinavia
Posts: 536
Strange problem DivX-encoding letterboxed video

Hi all,

I'm having a weird problem I just can solve.
I'm encoding music videos I have captured as Mpeg-2 (720 x 576 PAL) to DivX 3 and whenever the video is "letterboxed", the problem occurs.
On clips that are full 4:3, I can crop the black and the junk off the sides, and the clip looks terrific after encoding.

The problem I have is that in the area on letterboxed videos where the black border sort of "meet" the film content, the black pixels at the border "come alive" and look like marching ants.
It's hard to explain what it looks like, but I have uploaded a short clip to demonstrate the problem here:
http://w1.837.telia.com/~u83704167/clip/cut.avi

My script looks like this:

LoadPlugin("mpeg2dec.dll")
LoadPlugin("decomb.dll")
mpeg2source("eur.d2v")
Telecide()
crop(10,44,700,489)
BicubicResize(576,368,0,0.5)

I am using Decomb 4.0, Avisynth 2.0.6 (downloaded from Sourceforge) and and Dividee's Mpeg2dec.dll (downloaded from Doom9. File date 2001.08.16).

I see the "marching ants" even when commenting out Crop and Resize and viewing the .avs in MediaPlayer 6.4. When I comment out Telecide (), "the ants" disappear.

/Swan
Swan is offline   Reply With Quote
Old 26th October 2002, 20:47   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,924
If there is any black border on top when Telecide gets the clip, the postprocessing can cause this. Use Crop first to remove the border and then add it back afterwards if you need it. One day I will add a parameter to mask the black area, but for now that is the workaround. This also applies to FieldDeinterlace.
Guest is offline   Reply With Quote
Old 26th October 2002, 21:13   #3  |  Link
Swan
It's more fun to compute
 
Swan's Avatar
 
Join Date: Apr 2002
Location: Scandinavia
Posts: 536
Thanks Neuron,

Is this what you meant?

LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\decomb.dll")
mpeg2source("F:\Mpeg\musicvideo\eur.d2v")
crop(10,44,700,489)
Telecide()
BicubicResize(576,368,0,0.5)

Put Crop before Telecide ()?

I didn't quite understand what you meant by
"Use Crop first to remove the border and then add it back afterwards if you need it."

How do I add it back?
I wish to keep the amount of black and the "So 80's" logo, as you see on the clip.

/Swan
Swan is offline   Reply With Quote
Old 26th October 2002, 21:22   #4  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,924
Make a source VOB fragment available and I will develop a solution for you. The logos are an obstacle to the workaround, I agree.
Guest is offline   Reply With Quote
Old 27th October 2002, 01:12   #5  |  Link
Xenoproctologist
Registered User
 
Join Date: Apr 2002
Posts: 66
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\decomb.dll")
mpeg2source("F:\Mpeg\musicvideo\eur.d2v")
bordertop = crop(10,0,700,43)
borderbottom = crop(10,490,700,0)
crop(10,44,700,489)
Telecide()
stackvertical(bordertop,last,borderbottom)
BicubicResize(576,368,0,0.5)


Tweak bordertop and borderbottom to taste.
Xenoproctologist is offline   Reply With Quote
Old 27th October 2002, 23:55   #6  |  Link
Swan
It's more fun to compute
 
Swan's Avatar
 
Join Date: Apr 2002
Location: Scandinavia
Posts: 536
Now I understand that I can't escape learning how to calculate crop values and resize values "by hand".
I use GordianKnot for that.

On the clip I uploaded (original was 720 x 576), I set the following parameters in GordianKnot:

Crop:
top 44
bottom 43
left 10
right 10

Output resolution:
576 x 368

In the avs script, this became:
crop(10,44,700,489)
BicubicResize(576,368,0,0.5)

Looking in the Avisynth manual on www.avisynth.org I read the following:

Crop(clip clip, int left, int top, int width, int height)
Crop(clip clip, int left, int top, int -right, int -bottom)

How does that become:
crop(10,44,700,489)

I also ran into more trouble. Another video I encoded was hybrid, meaning it had both full screen 4:3 video and letterboxed content. This is becoming a large problem for me. I always use either telecide or Fielddeinterlace and because of the positioning of the logos, I think it's more aesthetically pleasing to keep them than crop them. But the "ants" are ruining the videos. :-(

Thanks for the script suggestion, Xenoproctologist. It looked very weird when I tested it (doubled logos), but I assume you just wanted to show me the filter to use?
Can you please explain in plain words what the script does?
You crop the border first, right?
Then stack something... I'm lost, as you can see.

/Swan
Swan is offline   Reply With Quote
Old 28th October 2002, 02:29   #7  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,924
@Swan

I don't see any clip attached or any URL. Did you put up a clip somewhere?
Guest is offline   Reply With Quote
Old 28th October 2002, 02:31   #8  |  Link
Aktan
Registered User
 
Join Date: Feb 2002
Posts: 258
crop(10,44,700,489):

10 = 10 left pixels
44 = 44 top pixels
700 = 700 width total pixels ( 720 - 10 (left) - 10 (right) )
489 = 489 total height pixels ( 576 - 44 (top) - 43 (bottom) )

crop can also be written like this:

crop(10,44,-10,-43)

Note: it is recommended that heights is even (mod 2)
Aktan is offline   Reply With Quote
Old 28th October 2002, 03:50   #9  |  Link
Xenoproctologist
Registered User
 
Join Date: Apr 2002
Posts: 66
Quote:
Thanks for the script suggestion, Xenoproctologist. It looked very weird when I tested it (doubled logos), but I assume you just wanted to show me the filter to use?
Can you please explain in plain words what the script does?
You crop the border first, right?
Then stack something... I'm lost, as you can see.
[EDIT] Gah. The cropping error thing was due to my mistaking the behavior of the crop function. I usually use the crop(x,y,-x,-y) notation. ^^; [/EDIT]




This script should result in cleaner output than the previous one and corrects for the error.

Code:
############################################################
#                                                          #
# Plugins are loaded here:                                 #
#                                                          #
                                                           #
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")            #
LoadPlugin("C:\PROGRA~1\GORDIA~1\decomb.dll")              #
                                                           #
############################################################
#                                                          #
# This is your source file:                                #
#                                                          #
                                                           #
mpeg2source("F:\Mpeg\musicvideo\eur.d2v")                  #
                                                           #
############################################################
#                                                          #
# Left and right borders are cropped here:                 #
#                                                          #
                                                           #
crop(10,0,700,0)                                           #
                                                           #
############################################################
#                                                          #
# This runs telecide without postprocessing:               #
# (Postprocessing is what's causing the lines to shimmer.) #
#                                                          #
                                                           #
telecide(post=false)                                       #
                                                           #
############################################################
#                                                          #
# This splits the top border, the bottom border, and       #
# the part between them into three separate clips:         #
#    [EDIT] Drivel removed. [/EDIT]                        #
#                                                          #
                                                           #
bordertop = last.crop(0,0,0,44)                            #
center = last.crop(0,44,0,489)                             #
borderbottom = last.crop(0,533,0,0)                        #
                                                           #
############################################################
#                                                          #
# This postprocesses the part between the borders:         #
#                                                          #
                                                           #
center = center.fielddeinterlace()                         #
                                                           #
############################################################
#                                                          #
# This re-stacks the top border, center,                   #
# and bottom border into one image:                        #
#                                                          #
                                                           #
stackvertical(bordertop,center,borderbottom)               #
                                                           #
############################################################
#                                                          #
# Resizing:                                                #
#                                                          #
                                                           #
BicubicResize(576,432,0,0.5)                               #
                                                           #
############################################################

Last edited by Xenoproctologist; 28th October 2002 at 10:42.
Xenoproctologist is offline   Reply With Quote
Old 28th October 2002, 10:17   #10  |  Link
Swan
It's more fun to compute
 
Swan's Avatar
 
Join Date: Apr 2002
Location: Scandinavia
Posts: 536
Xenoproctologist, thanks again. And thanks, Aktan for the explanation of cropping in Avisynth. I will learn how do it and you helped me to get started.

Xenoproctologist, I opened your modified .avs in VirtualDub and the "ants" are still there. Both areas, top and bottom, where the video meets black order are still affected.

I have uploaded a short mpg (eur.mpg)
A screen shot of your .avs opened in Vdub (eur.jpg)
A screen shot of the first workaround .avs (the strange doubled logos) called "first_workaround.jpg".

A troublesome "hybrid" clip (marvin.mpg)
Screenshots of your .avs loading the "hybrid" clip in Vdub (marvin1.jpg, marvin2.jpg)
In the "hybrid", there are "ants" in the non-full screen 4:3 scenes, where black meets the image content. I hope it shows well enough. Otherwise, I'll DivX encode a short example and upoad.

Here are the examples:
http://w1.837.telia.com/~u83704167/clip/

I appreciate your help.
/Swan
Swan is offline   Reply With Quote
Old 28th October 2002, 11:09   #11  |  Link
Xenoproctologist
Registered User
 
Join Date: Apr 2002
Posts: 66
Having looked at eur.mpg, I can see that your borders are too small. When I'm talking about borders, I mean all of the black letterboxing, including the station callsigns. Thus, you'll need to change the part of the script which splits the video to:
Code:
bordertop = last.crop(0,0,0,79)
center = last.crop(0,79,0,425)
borderbottom = last.crop(0,504,0,0)
I also noticed that the image in that clip is actually rotated a degree or so. You might want to consider running it through a rotation filter to fix that. Your call.


The marvin.mpg clip there's no easy fix for. You can isolate scenes with letterboxing via [trim(0,beginscene-1) + trim(beginscene,endscene) + trim(endscene+1,0)] (etc...) and try disabling postprocessing on those [telecide(post=false)], or tweak the Decomb postprocessing settings. (Read the Decomb help file. It'll do you good.)
Xenoproctologist is offline   Reply With Quote
Old 28th October 2002, 18:35   #12  |  Link
Swan
It's more fun to compute
 
Swan's Avatar
 
Join Date: Apr 2002
Location: Scandinavia
Posts: 536
@Xenoproctologist Both these clips seem particularly difficult. Eur.mpg does not have a straight, clear border between the black "matte" and the video itself. I've noticed that too. I'll test some more letterboxed videos and see if I can find a pattern as to when I get those artifacts and when I don't.

Your modification to the script

bordertop = last.crop(0,0,0,79)
center = last.crop(0,79,0,425)
borderbottom = last.crop(0,504,0,0)

did remove the majority of unwanted artifacts in the border-meets-video area, but not all of it. Perhaps due to the rotation you mentioned. It was not properly cropped at the top (some junk left there) and I think it added too much black matte. I don't want that amount when I DivX encode. I'd rather put the bits on the video than wasting them on black matte. I want to make it clear that I *do* appreciate the help you've given me.

I am confused when you say "Having looked at eur.mpg, I can see that your borders are too small.". If you mean that I cropped too near the station logo at the bottom (Vh1) and the program logo (So 80's) than I can say that I cropped on purpose so that there would be as little black matte as possible left. I cropped the bottom first, so that the Vh1 logo was not cropped, and had a tiny amount of black below it. I then cropped the top to match that, so that the amount of black matte would be approximately the same on the top and bottom of the final DivX-encoded video. I used GordianKnot, as I wrote before, and I trust that the Wef knows what he's doing, so I get correct AR.
Are you saying I should leave more black matte above and below the logos? So they are surrounded by more of the video's orginal black matte?

If so, isn't it up to me to decide how much I want to leave or crop?
I don't think a behavior in a filter should dictate such a thing.
If I misunderstood you, then please ignore what I just wrote.

@Neuron2
Is this problem "fixable"? Or will this always be a problem with (certain) letterboxed videos, when using Decomb?

Quote:
(Read the Decomb help file. It'll do you good.)
Trust me, I have read it. How else would I know how to use telecide() on my PAL clips instead of using Fielddeinterlace all the time?
But I'll read it again. And I'll experiment with (post=false).

/Swan

Last edited by Swan; 28th October 2002 at 18:38.
Swan is offline   Reply With Quote
Old 28th October 2002, 22:17   #13  |  Link
Xenoproctologist
Registered User
 
Join Date: Apr 2002
Posts: 66
Quote:
Originally posted by Swan
Your modification to the script

bordertop = last.crop(0,0,0,79)
center = last.crop(0,79,0,425)
borderbottom = last.crop(0,504,0,0)

did remove the majority of unwanted artifacts in the border-meets-video area, but not all of it. Perhaps due to the rotation you mentioned.
Yes.

Quote:
It was not properly cropped at the top (some junk left there) and I think it added too much black matte. I don't want that amount when I DivX encode. I'd rather put the bits on the video than wasting them on black matte. I want to make it clear that I *do* appreciate the help you've given me.

I am confused when you say "Having looked at eur.mpg, I can see that your borders are too small.". If you mean that I cropped too near the station logo at the bottom (Vh1) and the program logo (So 80's) than I can say that I cropped on purpose so that there would be as little black matte as possible left. I cropped the bottom first, so that the Vh1 logo was not cropped, and had a tiny amount of black below it. I then cropped the top to match that, so that the amount of black matte would be approximately the same on the top and bottom of the final DivX-encoded video. I used GordianKnot, as I wrote before, and I trust that the Wef knows what he's doing, so I get correct AR.
Are you saying I should leave more black matte above and below the logos? So they are surrounded by more of the video's orginal black matte?
No, I'm saying the exact opposite: for the purposes of this particular image processing case, you need to crop more. That script modification crops off all of the letterboxing (including the VH1 and "totally 80's" logos), fielddeinterlaces what's left, then reattaches the borders (and accompanying logos).

There's absolutely nothing precluding you from replacing the BicubicResize(576,432,0,0.5) at the end of the script with:
crop(0,44,0,489)
BicubicResize(576,368,0,0.5)
Xenoproctologist is offline   Reply With Quote
Old 29th October 2002, 01:04   #14  |  Link
Swan
It's more fun to compute
 
Swan's Avatar
 
Join Date: Apr 2002
Location: Scandinavia
Posts: 536
Thanks for all the time you spent clarifying this.
I will try to get a better hang of Avisynth. You're obviousy a master.

But this is sort of a bug in Decomb, right? In the postprocessing. Is there any way this problem could be eliminated in the next version?

/Swan
Swan is offline   Reply With Quote
Old 29th October 2002, 05:18   #15  |  Link
Xenoproctologist
Registered User
 
Join Date: Apr 2002
Posts: 66
It's less a bug in Decomb than a conceptual flaw in the method it uses to fielddeinterlace. It has to do with the way it thresholds--if you turn dthreshold (I think...) all the way up, that wavering would go away, but then you end up completely blending the fields together. It just happens that, in this case, Decomb introduces more problems than it solves, and you need to expend effort to work around them.

Decomb is a damn good tool for deinterlacing, but it's not the only tool for the job, nor is it always the best tool for the job. If it were, we would all need only one kind of screwdriver in our toolboxes.
Xenoproctologist is offline   Reply With Quote
Old 24th May 2003, 10:58   #16  |  Link
cipher
Registered User
 
Join Date: Feb 2003
Location: Atlantis
Posts: 88

I've linked an image, and hopefully this is what you were talking about. (dunno if the link would always work)

From the image, we can see the "ants"(dots, short lines, waves...) at the top and bottom lines.
As long as there is one single black line that hasn't been cropped, this may occur. In other words, cropping out all the black borders can completely solve this. But sometimes if we insist on mod 16 in height, we have to leave some black borders where they are;

Incresing "threshold" can solve this, but as a treadoff, a lota bad scenes may sneak out, as Xenoprodctologist metioned
Quote:
It has to do with the way it thresholds--if you turn dthreshold (I think...) all the way up, that wavering would go away, but then you end up completely blending the fields together
;

After doing a lot of tests I knew it was decomb that caused this but wasn't able to figure out exactly which para, thx to Xenoprodctologist who pointed out
Quote:
(Postprocessing is what's causing the lines to shimmer.)
now we can be more focused.
Sounds like I'm just summing up what you guys were talking about. Well, I like decomb a lot, so I want more people to look at it and find a way to improve it.
cipher is offline   Reply With Quote
Old 24th May 2003, 19:24   #17  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,924
This is a known issue that bothers me. See my Journal at my web site where I discuss it as a deficiency of Decomb. I am currently making a new-generation Decomb. That is one of the issues that will be addressed. For now, crop off the letterboxing and then put it back afterwards if you need it.

The solution will allow specification of exclusion bands for the letterboxing scenario, and it will add an edge avoidance term to the comb detection metric for static logos and other such scenarios.
Guest is offline   Reply With Quote
Old 24th May 2003, 23:57   #18  |  Link
cipher
Registered User
 
Join Date: Feb 2003
Location: Atlantis
Posts: 88
Quote:
This is a known issue that bothers me. See my Journal at my web site where I discuss it as a deficiency of Decomb. I am currently making a new-generation Decomb. That is one of the issues that will be addressed
neuron2, it's really good to hear that! Thanks!!
cipher is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.