digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Video Encoding and Conversion (http://www.digitalfaq.com/archives/encode/)
-   -   Mencoder: Move the noise parameter to the beginning of your script! (http://www.digitalfaq.com/archives/encode/10027-mencoder-move-noise.html)

kwag 06-01-2004 09:37 PM

Mencoder: Move the noise parameter to the beginning of your script!
 
Please make the following changes to your scripts.

Move the "noise" parameter" to the beginning of your script, before the crop parameter.

If you don't, the noise is inserted on the complete frame. The following noise generated images show what happens:

With this line (pre crop noise):
Code:

vf=yuvcsp,noise=99th,scale=720:360::0:9,crop=672:360:24:0,expand=704:480:16:60,pullup,softskip,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5
You get this:
http://www.digitalfaq.com/archives/i.../2004/06/1.png


But with this line (post crop noise):
Code:

vf=yuvcsp,scale=720:360::0:9,crop=672:360:24:0,expand=704:480:16:60,pullup,softskip,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,noise=99th
You get this:
http://www.digitalfaq.com/archives/i.../2004/06/2.png

-kwag

Dialhot 06-01-2004 09:52 PM

I don't understand why you (and others) changed your way of processing.

Before mencoder we always crop / filters / add borders. Here you do all resizing/borders BEFORE to do any filters. That is why you have noise in the borders when you add it at last pos.

Personally I continue to crop the frame, then filter, then scale/expand it. As I always did :!:

This is my line :
Code:

-vf yuvcsp,pp=hb:100:100/vb,crop=564:304:-1:-1,hqdn3d=10:12:8,noise=3th,scale=528:336::0:9,expand=544:480
As you can see, the border are in the end. And noise is ONLY on the picture area of the frame (between the crop and the scale but I can also do crop -> scale -> filter). I just tested with 99th like you did to be sure.

:arrow: Let represent the filter chain as an avs script if it can help you.

My line does the same as :

Code:

Mpeg2source()
Blindpp(cpu=4)
Crop(...)
Deen()
Blockbuster(noise)
Lanczosresize(...)
Addborders(...)

For sure if you put "noise" after "expand" it's like if you add "blockbuster(noise)" after "addborders".

I don't see any surprise in that.

kwag 06-01-2004 10:11 PM

It's no surprice Phil. It's something that normally can't be seen, unless a noise rain is applied, just like I did.
Both MencodeME and PackShot are adding the noise at different places, both before the "crop" command.
The noise should be added before everything, not like we were used to in AviSynth.
Add it at the top level, so when the crop command executes, it will cut everything, including the out-of-bounds noise.

-kwag

kwag 06-01-2004 10:13 PM

Quote:

Originally Posted by Dialhot
Personally I continue to crop the frame, then filter, then scale/expand it.

And that's wrong for mencoder, because noise IS a filter, so you are injecting noise AFTER crop, which results in global noise on the full frame.

-kwag

kwag 06-01-2004 10:18 PM

Ignore previous post. Noise DOES work fine between crop and expand.
:douh:

:oops:

Dialhot 06-01-2004 10:19 PM

Quote:

Originally Posted by kwag
It's no surprice Phil. It's something that normally can't be seen, unless a noise rain is applied, just like I did.
Both MencodeME and PackShot are adding the noise at different places, both before the "crop" command.

Okay so it was not a surprise for you too. That is just something that jumped into my eyes at my first usage of mencoder and the surprise is to see that Inc didn't notice that ;-))

Quote:

And that's wrong for mencoder, because noise IS a filter, so you are injecting noise AFTER crop, which results in global noise on the full frame.
Yes, and that is what we always did (and IMHO the logical way of doing). What is the purpose to put noise on a part of the screen that you will cut with the crop ? Losing time :?:

More : remember that your DVD source always have blackborders hard encoded (only 1.78 source don't have, and 4:3 also of course).
So you are adding noise into this borders too ? Why ?

EDIT: too late for the second post ;-)

kwag 06-01-2004 10:19 PM

And I haven't even had a :drink: yet :!: :Drunk:

Dialhot 06-01-2004 10:21 PM

And I don't even sleep yet.
It's 5:17, the clock is set on 8:00 tomorrow... I think I would go now :-p

See ya.

Prodater64 06-01-2004 10:39 PM

Hi, I know this was posted before, but I don't know what behaviour to have, so:
1 - Should us aply noise always?
2 - It is for deal with min bitrate?
3 - Always must be 3th value?

Thank you.


--------------------------
Visit: Intermediate guide: MencodeMe/Win32 - Avisynth - MakeAvis by Prodater64.
Visit: KVCD - MencodeMe - Auxiliar Task - KVCD Docking Gate by Prodater64.
Visit: Mencoder scripting with AVSEdit and Guide for Multiple Files by Prodater64.
Visit: Mini-guide quick and easy - DVD to (S)KVCD with MencodeMe by Maurus.
Visit: Mencode-me: a newbie oriented GUI - 0.23 is out! by VMesquita.
--------------------------

http://www.digitalfaq.com/archives/error.gif

kwag 06-01-2004 11:06 PM

I guess I wasn't so off anyway :!:

When using this line:
Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=99th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,expand=704:480:16:60
You get this:

http://www.digitalfaq.com/archives/i.../2004/06/3.png

As you can see, there is still noise in the black bars, which result in extra bitrate lost.

What's the solution :?:
Add a crop to exact film pixels, just before the final expand :D
Like this:
Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=99th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,crop=704:270,expand=704:480
And now you get this :cool:

http://www.digitalfaq.com/archives/i.../2004/06/4.png

Which is the same effect of AddBorders in AviSynth ;)

Comments :cool:

-kwag

kwag 06-01-2004 11:11 PM

Quote:

Originally Posted by Prodater64
1 - Should us aply noise always?

Yes.
Quote:

2 - It is for deal with min bitrate?
Exactly.
Quote:

3 - Always must be 3th value?
3th keeps the MIN bitrate aroud 300Kbps, which is perfect for KVCDs and good enough to keep dark areas DCT Blockless, even on KDVDs ;)

-kwag

kwag 06-01-2004 11:55 PM

I just HAD to post this here :lol:
Here's the complete 46 second clip, weighting at only 5,138KB, at 704x480 using an average bitrate of 905Kbps (with CalcuMatic) to target the movie on one CD-R :D

http://www.kvcd.net/red-planet-1CD-704x480-mencoder.m2v

The configuration file used was this:
Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=3th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,crop=704:272,expand=704:480
of=rawvideo=1
ovc=lavc=1
nosound=1
sws=9

lavcopts=vcodec=mpeg2video:vrc_eq=tex:vmax_b_frames=2:vrc_maxrate=2500:aspect=1.3333:keyint=18:vrc_buf_size=1835:preme=2:precmp=2:vstrict=-1:autoaspect=1:scplx_mask=0.3:vqblur=0:mbqmin=1:vqmin=1:mbqmin=1:lmin=1:
intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29,36,39,38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79:
inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44
ofps=23.976

And the batch file was this:
Code:

Mencoder -include temp.conf -lavcopts vbitrate=905:vpass=1 "k:\test.vob" -o "K:\red-planet-1CD-704x480-mencoder.m2v"
Edit: The peak bitrate of that clip is 1,564Kbps :P

-kwag

incredible 06-02-2004 03:13 AM

In Packshot the follwoing order is determinet:

Scale,Crop,Filtering,Expanding! So Theres no noise after expanding! (or I got a mega Bug in Packshots commndline generating 8O )

Phil,

Theres no difference if you first scale, then crop or if you first crop and then scale ... as in avisynth you also do apply gripcrop,Gripsize....Here now you got the effective pixel area only ... then filter, gripborders.

Kwag,

The problem on your sample is that you deal with a2.35:1 source, meas, even in your orig source state you still got black bars on its anamorph input. So an option in Packshot (2.35 yes,no) makes sense as it pre-crops the anamorph image to its effective pixel state!

Dialhot 06-02-2004 03:21 AM

Quote:

Originally Posted by kwag
I guess I wasn't so off anyway :!:

I think that is it but you are to tired to catch it the first time ;-)

Quote:

Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=99th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,expand=704:480:16:60
What's the solution :?:
Add a crop to exact film pixels, just before the final expand :D
Like this:
Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=99th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,crop=704:270,expand=704:480

And can you explain to me why you cut in the first place to 672:360 as obviously your picture area is far smaller than this (as you can see on your first picture) ?
Why the hell don't you cut DIRECTLY the film area, and ONLY it, with the first crop ?
This way you won't have ANY border left and you won't have ANY point in them (for sure as they do not exist anymore)

I'm starting to ask myslef if anyone cutted really the film area before as it should always be done :?:

Dialhot 06-02-2004 03:27 AM

Quote:

Originally Posted by incredible
Theres no difference if you first scale, then crop or if you first crop and then scale ...

For sure it is :!:

Take a 400x400 pixel square then scale it to 720*576 and crop to 300x300. You obtain a 300x300 square, right ?
Take a 400x400 pixel square, crop it to 300x300 and scale it to 720*576. What do you guess you obtain :?: :?:

Quote:

as in avisynth you also do apply gripcrop,Gripsize....Here now you got the effective pixel area only ... then filter, gripborders.
Yes : crop THEN scale.
You will never have scale THEN crop ! Do you :?:

I think you all need vacations :-P

Koekies 06-02-2004 05:06 AM

So should I change my MencodeMe DVD.fil to

Code:

vf=%%FORCEDFILM%%yuvcsp,pullup,softskip,%%CROP%%scale=%%CROPPED_WIDTH%%:%%CROPPED_HEIGHT%%:0:0:60,noise=3th,unsharp=l3x3:0.6,hqdn3d=3:6:8,unsharp=l3x3:-0.7:c3x3:-1.5,expand=%%WIDTH%%:%%HEIGHT%%:-1:-1:1

incredible 06-02-2004 05:46 AM

Quote:

Originally Posted by Dialhot
I think you all need vacations :-P

And I think you need more sleep as you dont look whats going on really in Mencalc (and therefore my way and also suggested by the reference link) :P

For shure in the case of first scaling and then cropping a different scaling value! is applied!

The case 720x576 to 352x288:

Mencalc:
scale to 360x288! then crop at the sides by 4 pix which gives you a perfect 352x288!
Fitcd/MS: Crop by 8px to 704x576 and then scale to 352x888

Both do end up in EXACT the same image! With exact the same PAR!

Means after the scale/crop or crop scale process you got the SAME image data, ... then you can apply the filters and then you can addborders/expand if needed :!:

The Problem Kwag explained IS DUE that a 2.35:1 source still comes with black bars and these also WOULDNT be respected by FitCD or MS If you WOULDNT enter the active picture area.
( And thats finally the "quintessence" of the "problem" in here :!: as we "thought" that mencoder could be intelligent to "not affect" the totally black area ;-) :arrow: Theres the error in effective! )

So the Problem above is not mencoder or mencalc routine/way related but Source related.

Quote:

Take a 400x400 pixel square then scale it to 720*576 and crop to 300x300. You obtain a 300x300 square, right ?
Take a 400x400 pixel square, crop it to 300x300 and scale it to 720*576. What do you guess you obtain :?: :?:
See my exlanation above as in the way of scale/crop other scale params are used which do ENDUP in the exact same image.

Quote:

a
Quote:

as in avisynth you also do apply gripcrop,Gripsize....Here now you got the effective pixel area only ... then filter, gripborders.
Yes : crop THEN scale.
You will never have scale THEN crop ! Do you :?:
In case of mencalc usage I DO! And NEVER had problems as BEFORE expanding I got the exact same picture data/size/PAR as if I would crop/scale ..... see my explanantion above related to diff sclaing params when first scaling .... do have a look at that reference link, please.
THERE ITS EXPLAINED THAT ALSO THE CASE OF FIRST SCALING THEN CROPPING GIVES YOU ALSO THE CORRECT PICTURE DATA.

Example2 720x576 to 528x576:
Mencalc: scale to 544x576, crop to 528x576 - ready
FitCD/MS: Crop to 704x576, scale to 528x576

... as Mencalc uses in its routines a scaling of mod8 a minimal error could result (In the case above 0.5% maybe, wow :lol: .... but show me a resizing in MS/FitCD where you end up in Error=0%! )


:wink:

incredible 06-02-2004 06:00 AM

Quote:

Originally Posted by Dialhot
Quote:

Originally Posted by kwag
I guess I wasn't so off anyway :!:

I think that is it but you are to tired to catch it the first time ;-)

Quote:

Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=99th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,expand=704:480:16:60
What's the solution :?:
Add a crop to exact film pixels, just before the final expand :D
Like this:
Code:

vf=yuvcsp,pullup,softskip,scale=720:360::0:9,crop=672:360:24:0,noise=99th,unsharp=l3x3:0.6,hqdn3d=3:6:2,unsharp=l3x3:-0.7:c3x3:-1.5,crop=704:270,expand=704:480

And can you explain to me why you cut in the first place to 672:360 as obviously your picture area is far smaller than this (as you can see on your first picture) ?

He cuts to 672 width AS HE used ovelayed overscan!

Quote:

Why the hell don't you cut DIRECTLY the film area, and ONLY it, with the first crop ?
This way you won't have ANY border left and you won't have ANY point in them (for sure as they do not exist anymore)

I'm starting to ask myslef if anyone cutted really the film area before as it should always be done :?:
Thats cause (still) no active PixelArea Determiantion in mencalc is included :? And if a second crop is applied well ... and IF that second crop doesnt reduce encoding speed ... than this way isnt that "elegant" BUT the quality will be EXACT the same.
You could say "ok .... but Ill stay on my princips" .... ok, no problem but IF (and that would be interesting) a second crop doesnt affect speed/quality ... then I see no problem. As a crop/scale/expand routine would cost a hell more of generating a mathematical resizing calculation ...

(IF a second crop doesnt affect sped/quality) then We are argumenting in here about "shown" commandline cosmetics which do have NOTHING to do with the "real" result as its still correct.
And IF I got the time when everything is implementated well in PAckshot THEN my next project will be to find out that "hell" mathematical routine for crop/sclae/expand.

Dialhot 06-02-2004 06:49 AM

Quote:

Originally Posted by incredible
For shure in the case of first scaling and then cropping a different scaling value! is applied!

I was figuring that while I was taking my lunch. I found this idea too crazy to be true but I see you are crazy enought :-)
By "crazy" I mean that you should have screwed up your brain to find the correct formula to apply while the other way was straight to the solution, but I agree with you, the result is the same :-).

Quote:

The Problem Kwag explained IS DUE that a 2.35:1 source still comes with black bars and these also WOULDNT be respected by FitCD or MS If you WOULDNT enter the active picture area.
That's what I said : it seems I'm the only one that used this area :!:

Since a long time I'm saying that 1.85 DVD have a 16 pixels border and 2.35 a 72 pixels border that must be cropped before any filtering is applied (except for PP or blindPP of course). That's what I do any time and I just figured that any others 'guru' here did the same. I was may be wrong...

Quote:

So the Problem above is not mencoder or mencalc routine/way related but Source related.
Did I put the guilt on mencoder ?

Quote:

... as Mencalc uses in its routines a scaling of mod8 a minimal error could result (In the case above 0.5% maybe, wow :lol: .... but show me a resizing in MS/FitCD where you end up in Error=0%! )
720*576 to 704*576 is 0% (just a crop is done in this case)
720*576 to 352*288 is also 0%.

Those are two example :-). Okay, these are trivials but you just asked for an example :-p

Dialhot 06-02-2004 06:54 AM

Quote:

Originally Posted by incredible
Thats cause (still) no active PixelArea Determiantion in mencalc is included

I never saw, and didn't know, that Kwag was just referencing a line generated by mencalc .
That's all the mistake causing my "strong" speech and your "self-defense" response.

For me Kwag was using a line he did by himlsef so I didn't understand why he don't just cut the film area. Now I understand easily that this feature is not implemented (yet ? ;-)) in mencalc !


All times are GMT -5. The time now is 08:22 PM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.