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 > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th January 2006, 03:14   #1  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Need your help with first anamorphic encode

Hi,

I'm encoding my first movie using anamorphic resizing. Howver after reading everything on the forum, I think I'm more confused than ever. So I'm looking for someone to help me out to endode the following movie. I have Red Eye, it's 2:40 Anamorphic, NTSC. I'm using MeGUI, to mkv.

So step 1 go to Tools, AviSynth Script Creator, select my project file.
For Input DAR, I select Custom and do I enter in 2:35?
Check REtain anamorphic resolution and set SAR in Encoder.
AVS Profile just keep at Default?
Click Autocrop, which gives me 60 off the top and 66 off the bottom and 2 off the right.
Go to Output Resolution and select ?? 720?
Resize Filter, not sure what to select here but how about Bicubic Neatrual?
Leave Deinterlace and Noise Filter unchecked.
Mpeg2 Deblocking unchecked.
Do I need Colour Correction checked?

Is that it? I noticed that when I select the Edit tab, it says to "# Set SAR in encoder to 720 : 627"
So now I go to Video and select the AviSynth script, set the output file, set it to mkv.
For Codec set to AVC and here's where I select config and enter in 720:627 for SAR in the Advanced Tab? Is the 627 right?

FYI I usually encode all my movies to about 2GB for a full 2hr movie with the AC3 track.

So do I have this right?
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 17th January 2006, 03:45   #2  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by DigitalDivide
2:40 Anamorphic, NTSC.
...
For Input DAR, I select Custom and do I enter in 2:35?
Do you mean 1:2.35? You aren't allowed to enter : in the custom section.

Quote:
Check REtain anamorphic resolution and set SAR in Encoder.
AVS Profile just keep at Default?
Click Autocrop, which gives me 60 off the top and 66 off the bottom and 2 off the right.
Go to Output Resolution and select ?? 720?
Resize Filter, not sure what to select here but how about Bicubic Neatrual?
Leave Deinterlace and Noise Filter unchecked.
Mpeg2 Deblocking unchecked.
Do I need Colour Correction checked?
A general rule which will get you through quite well: If you don't know whether you should use somethng, leave it at its default value. Anyway, your settings seem fine.

Quote:
So now I go to Video and select the AviSynth script, set the output file, set it to mkv.
For Codec set to AVC and here's where I select config and enter in 720:627 for SAR in the Advanced Tab? Is the 627 right?
Well, if you had checked 'On Save Close and Load to be encoded' in the AviSynth window, you shouldn't have needed to do this. But yes, your settings are right here, as well.

Quote:
So do I have this right?
Yes. But just to make sure, why don't you encode a small sample and see whether it is right. To encode just a little bit, add
Code:
trim(0,5000)
to the end of your AviSynth script. You can change the numbers to whatever you want, of course, but the first number is the starting frame number, and the second number is the finishing number.
berrinam is offline   Reply With Quote
Old 17th January 2006, 04:02   #3  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Thanks good to know I have the process down. When I select custom, the 2:35 shows in the box automically. So I guess that's right.

Just curious can I trust the Edit page where it suggests to use
"# Set SAR in encoder to 720 : 627"? Is it usually right?

Also if my movie is 1:85:1 aspect ratio what do I select in the Input DAR, simply 16:9?
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 17th January 2006, 04:15   #4  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by DigitalDivide
Just curious can I trust the Edit page where it suggests to use
"# Set SAR in encoder to 720 : 627"? Is it usually right?
Would it be in MeGUI if it wasn't usually right?
berrinam is offline   Reply With Quote
Old 17th January 2006, 04:25   #5  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Quote:
Would it be in MeGUI if it wasn't usually right?
lol just checking...the reason I ask is because I read so many posts about what to select which seemed kinda odd to me to worry about it if MeGUI already suggests the size.

Anyhow thanks for the input! Much appreciated.
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 17th January 2006, 05:32   #6  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by DigitalDivide
lol just checking...the reason I ask is because I read so many posts about what to select which seemed kinda odd to me to worry about it if MeGUI already suggests the size.
Yes, it is odd.

Quote:
Anyhow thanks for the input! Much appreciated.
It's ok. Maybe you could even give something back by writing a guide based on your findings
berrinam is offline   Reply With Quote
Old 17th January 2006, 05:40   #7  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Well I'm not there yet, I'm getting the following error when trying to encode

avis[error]: unsupported input format(DIB)
could not open input file d:\projects\Red Eye\Red Eye.avs.

I used the Avisynth Script Creator in MeGUI. It contains the following info.

LoadPlugin("C:\Program Files\GordianKnot\DGMPGDec\dgdecode.dll")
mpeg2source("D:\red.d2v")
ColorMatrix()
#deinterlace
crop(0,60,-2,-66)
LanczosResize(720,352)
Undot()

# Set SAR in encoder to 720 : 627

I usually use Gordian Knot to create my avisynth script then open it up with MeGUI. I've never had any problem. This is the first time I tried creating one using MeGUI. I checked the settings and the path is correct.

Edit: I get the following ouput using Gordia Knot. I noticed that the cropping and resizing are different.
# Created with Gordian Knot
#
# http://gknot.doom9.org

# PLUGINS
LoadPlugin("C:\Program Files\GordianKnot\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\UnDot.dll")

# SOURCE
mpeg2source("D:\Projects\Red Eye.d2v")

# TRIM
#trim(startframe,endframe)

# IVTC
#Telecide(order=1,guide=1).Decimate()
# or use
#IVTC(44,11,95)
#GreedyHMA(1,0,4,0,0,0,0,0)

# DEINTERLACING (1)
#FieldDeinterlace()
#FieldDeinterlace(blend=false)
#TomsMoComp(1,5,1)

# DEINTERLACING (2)
#KernelDeInt(order=1,sharp=true)
# or maybe
#DGBob(order=1,mode=0)

# DEINTERLACING (3) - special requests
#GreedyHMA(1,0,0,0,0,0,0,0)
#Telecide()
#SeparateFields()

# CROPPING
crop(8,64,704,348)

# SUBTITLES
#VobSub("FileName")

# RESIZING
LanczosResize(672,272)

# DENOISING: choose one combination (or none)
Undot()
__________________
Toronto,ON

Last edited by DigitalDivide; 17th January 2006 at 05:47.
DigitalDivide is offline   Reply With Quote
Old 17th January 2006, 09:13   #8  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by DigitalDivide
Well I'm not there yet, I'm getting the following error when trying to encode

avis[error]: unsupported input format(DIB)
could not open input file d:\projects\Red Eye\Red Eye.avs.
It sounds like you are missing Undot.dll in your AviSynth plugins directory. You should take Undot.dll (located in C:\program files\gordianknot\avisynthplugins\undot.dll) and put it in the avisynth plugins dir (normally c:\program files\avisynth\plugins\)

Quote:
Edit: I get the following ouput using Gordia Knot. I noticed that the cropping and resizing are different.
Cropping is surprising, but resizing is expected: firstly, you are going to a different resolution, and secondly, you are doing anamorphic encoding.
berrinam is offline   Reply With Quote
Old 17th January 2006, 11:48   #9  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
DigitalDivide, try using the following script (based on the crop settings you got from megui):

# PLUGINS
LoadPlugin("C:\Program Files\GordianKnot\DGMPGDec\DGDecode.dll")

# SOURCE
mpeg2source("D:\Projects\Red Eye.d2v")

# CROPPING
crop(0,60,-2,-66)

Encode this in megui (of course you can add other filters for denoising or smoothing like undot if you want) and save as mkv or mp4. Than after the encoding is finished open the file with mkvmergeGUI, select the video stream and at display width/height put 850/354 and remux under a different name.
I usually use this method because I get confused with those settings in megui. In case you don't understand how I got that aspect ratio, I explain it here: you take the resolution after cropping (in your case 718/354 (2.028)), you take the DAR of 1.77 of the original and the AR (1.5) and make the following calculus:
718/354(2.028).........x
720/480(1.5).....1.7777
and you get x. You multiply x with the height resolution and get 850/354 wich keeps the DAR and doesn't lose res by resizing. I hope I was clear (when I read it it confuses me). The resize settings in megui have no importance since you don't resize, that's the point of anamorphic display.
And one last advice: after the autocrop in megui or gknot you should crop a bit yourself to make the resulting height/width both multiples of 16. It helps compression (but don't leave any black borders).
__________________
zzz
Daodan is offline   Reply With Quote
Old 17th January 2006, 13:49   #10  |  Link
Benedikt
Registered User
 
Join Date: Oct 2005
Posts: 20
-> I think it's important to note that you can (and you should) deactivate any resizing filters, because they may affect quality and speed. With anamorphic rips resizing is generally not necessary.

-> Also important is a little bit of "playing" with MeGUIs crop and resizing sliders, because there's some kind of bug in MeGUI: MeGUI only calculates the correct SAR if you adjust the resizing values at least once. Sometimes gives me rather odd results, if I don't change the resizing or cropping values a bit.
Benedikt is offline   Reply With Quote
Old 17th January 2006, 20:54   #11  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Hey all, thanks for the help. I will give this another try when I get home from work tonight.
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 17th January 2006, 21:41   #12  |  Link
lenouch
Registered User
 
Join Date: Dec 2003
Posts: 15
A "simple" question :

What is the difference between "Sample Aspect Ratio" set in x264 encoding and "Aspect ratio" set in MKV ?


Instead of applying 2 successives resize (one at encode and one at decode), why not setting encoding SAR is 1:1, and calculate the AR for display (stored in MKV container) ?

Example :
1) for a PAL DVD, native resolution (anamorphic) is 720x576
2) I perform a crop to remove black border : reso is 720x560

In this case, how should I set SAR in x264 and AspectRatio in Matroska ?
SAR=1:1 ?
AR=16/9 ?

Help, I'm very confuse about this ...

Last edited by lenouch; 17th January 2006 at 22:17.
lenouch is offline   Reply With Quote
Old 18th January 2006, 00:08   #13  |  Link
Benedikt
Registered User
 
Join Date: Oct 2005
Posts: 20
Quote:
Originally Posted by lenouch
A "simple" question :

What is the difference between "Sample Aspect Ratio" set in x264 encoding and "Aspect ratio" set in MKV ?


Instead of applying 2 successives resize (one at encode and one at decode), why not setting encoding SAR is 1:1, and calculate the AR for display (stored in MKV container) ?

Example :
1) for a PAL DVD, native resolution (anamorphic) is 720x576
2) I perform a crop to remove black border : reso is 720x560

In this case, how should I set SAR in x264 and AspectRatio in Matroska ?
SAR=1:1 ?
AR=16/9 ?

Help, I'm very confuse about this ...
The SAR would be, I think 2.28571429 (=DAR*height/width)
The relevant SAR parameters for x264* would be 8960:6480. Or, some nicer values to fill in: 112:81.
Put that in the corresponding input boxes and you're fine.


*calculation: 720*16:560*9=1,382716...
Benedikt is offline   Reply With Quote
Old 18th January 2006, 01:23   #14  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Quote:
I explain it here: you take the resolution after cropping (in your case 718/354 (2.028)), you take the DAR of 1.77 of the original and the AR (1.5) and make the following calculus:
718/354(2.028).........x
720/480(1.5).....1.7777
and you get x. You multiply x with the height resolution and get 850/354 wich keeps the DAR and doesn't lose res by resizing.
Okay you lost me here. I can see 718/354 = 2.028 and 720/480 = 1.5. The 1.777 I understand but when you say I get X and I should mulitply it with the height resolution and get 850/354 you lost me. As far as I can see I don't know what X... and I don't know what I'm muliplying it with to get 850/354....I feel dumb but honestly I don't see it...
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 18th January 2006, 03:13   #15  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Quote:
It sounds like you are missing Undot.dll in your AviSynth plugins directory. You should take Undot.dll (located in C:\program files\gordianknot\avisynthplugins\undot.dll) and put it in the avisynth plugins dir (normally c:\program files\avisynth\plugins\)
Tried that but it gave me the same error. The only way I was able to get it was to create an AVS file from Gordian Knot, then modify the file. That works.

However I noticed the following locations for the file.
C:\Program Files\X264
C:\program files\avisynth 2.5\plugins
C:\program files\gordianknot\avisynthplugins
c:\program files\godianknot\dgmpgdec
Not really sure which I should be using but I tried putting the settings to c:\program files\avisynth 2.5\plugins and it still didn't work.
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 18th January 2006, 03:24   #16  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Ok, here's the standard thing you do when an avisynth script doesn't load: open it with VirtualDubMod. It will tell you what the error is (almost all of the time), and then you can go about remedying it. I was just making a guess, but it seems it didn't work.
berrinam is offline   Reply With Quote
Old 18th January 2006, 04:26   #17  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Okay figured out the error. I had two project files and it was looking for the wrong one.

I fnished encoding a small test. To be honest I don't see any difference between it using the SAR and the same movie I encoded without the SAR. Should I be able to see a difference?
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 18th January 2006, 09:18   #18  |  Link
lenouch
Registered User
 
Join Date: Dec 2003
Posts: 15
Quote:
Originally Posted by Benedikt
The SAR would be, I think 2.28571429 (=DAR*height/width)
The relevant SAR parameters for x264* would be 8960:6480. Or, some nicer values to fill in: 112:81.
Put that in the corresponding input boxes and you're fine.


*calculation: 720*16:560*9=1,382716...
Ok. So, I have to enter SAR=8960:6480 in meGui.

1) From a technical point-of-view, is SAR just a flag in the encoded stream or is there an internal resize in x264 before encoding ?

2) In this case (SAR=8960:6480), what is the value I have to enter as DAR ? 16:9 again, or 1:1 because AR is "managed" in x264 stream ?

This is definitly confuse for me

Last edited by lenouch; 18th January 2006 at 09:24.
lenouch is offline   Reply With Quote
Old 18th January 2006, 11:16   #19  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
Quote:
Originally Posted by DigitalDivide
Okay you lost me here. I can see 718/354 = 2.028 and 720/480 = 1.5. The 1.777 I understand but when you say I get X and I should mulitply it with the height resolution and get 850/354 you lost me. As far as I can see I don't know what X... and I don't know what I'm muliplying it with to get 850/354....I feel dumb but honestly I don't see it...
That X is the display aspect ratio of your encoded movie (2.4 in your case). You should be able to see an increase in the image quality (if you use a high enough bitrate, otherwise that extra resolution will only lead to blocking). At least in PAL dvds the difference is very clear (but here the loss of height resolution is much bigger at resizing than in the case of NTSC). Of course this anamorphic thing was made mostly for widescreens but in the case of monitors the resolution is big enough to take advantege of this even if they aren't widescreen.

Quote:
Originally Posted by lenouch
Ok. So, I have to enter SAR=8960:6480 in meGui.

1) From a technical point-of-view, is SAR just a flag in the encoded stream or is there an internal resize in x264 before encoding ?

2) In this case (SAR=8960:6480), what is the value I have to enter as DAR ? 16:9 again, or 1:1 because AR is "managed" in x264 stream ?
Yes, it's just a flag, otherwise this hole anamorphic thing would be almost pointless. Let's say you have a PAL dvd with no borders in 16:9. To keep the hole details you should resize to the enourmous size of 1020/576 wich would take a lot to encode and a lot to decode. In case of anamorphic the decoded resolution is 720/576.
For question number 2 I'm not sure what you mean, you use either SAR OR DAR because they are related (height/width=SAR/DAR). (As I said before, it's less confusing if you just enter the DAR in matroska muxer after making an encode without resizing).
__________________
zzz
Daodan is offline   Reply With Quote
Old 18th January 2006, 11:47   #20  |  Link
lenouch
Registered User
 
Join Date: Dec 2003
Posts: 15
Thanks, it's more clear for me

In my case, anamorphic resolution is 720x576 => DAR is (576x16)/(720x9) = 9216/6480 = 64/45 = 1.422

Then, according to your last sentence, it's not necessary to modify SAR in x264 encoding (keep 1:1), but I have to set 64/45 (in mkvmerge. Fine ?

In this case, decoder will decode my movie as 720x576, but will stretch it to display as (720*1.422) x 576 = 1024 x 576. Is that right ?

Last edited by lenouch; 18th January 2006 at 11:50.
lenouch 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 15:38.


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