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 ASP

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th December 2006, 18:11   #1  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
avs2qxvid.bat [AVS to Quality XviD]

You wrote an AVS. You wanna encode it to a good quality XviD file. But you don't like GUI. This batch script is for you.

Download the full package (version 2.5h) here:
http://www.sendspace.com/file/ni08oz
(7zip compressed twice with password XviD_presets)

The main purpose of my batch script is to implement Teegedeck's XviD presets using squid_80's version of xvid_encraw. The main features are:
  1. Automatic preset selection through 3% compressibility test
  2. Audio encoding using LAME, OggEnc2 and BePipe (which requires MS .NET framework)
  3. Single audio track muxing (mp3, ogg and ac3) with audio time shift support (in DGIndex naming style)
  4. MKV chapter support via zone definitions
  5. Progressive & interlaced encoding
  6. Anamorphic encoding (PAL_16:9, NTSC_4:3, etc.)
  7. Target size or bitrate by KB, MB, GB, Kbps and bppx (audio size included for KB, MB & GB, yet no overhead calculation)
  8. Batch AVS encoding, with independent settings for each AVS
  9. Zone weights ... useful for credits (experimental, potential interference with presets)
  10. (Newer) standalone support (also experimental; customized from Teegedeck's Fast & HQ presets ~~ custom matrix warning), plus plugh's alt 2-pass mode (read bin\xvid_presets_25h.csv)
  11. Kopernikus's HVS mods & custom params (read bin\xvid_presets_25h.csv)
  12. Free creation of your own presets (read bin\xvid_presets_25h.csv)
  13. Free choice of custom matrix (read bin\xvid_presets_25h.csv)

This is how you use this batch script: Say, you have abcdef.avs ready in certain directory. Now make a plain text file abcdef.enc.txt in the same directory with one single line reading "TGHQ-CT 1.45GB". NTSC 16:9 footage? Make it "TGHQ-CT 1.45GB NTSC_16:9" Interlaced encoding? Append "TFF" or "BFF" at the end of the line. Audio track? Put it inside the AVS or make a separate mp3 or ogg in the same directory. OGM chapters? Create another plain text files abcdef.zones.txt listing the frame numbers (The default zone weight is 1.0 and you can put something like 0.1 next to the frame number for credit zones). When all is ready, drop abcdef.avs onto avs2qxvid.bat and then wait for your CPU load to drop to zero. ^_^ You can at most drop 9 AVS files onto the batch at a time.

The following Teegedeck presets are supported: TGHQ-CT, TGFAST-CT, TGEDIT-00 and TGANIME-00. I have hacked a MTK-CT for standalones. If you know your source's compressibility, you can specify the levels directly (-30, -45, -58 or -90), e.g. TGHQ-58, MTK-45, etc. Note that if the target size or bitrate is too high or too low, it may not be respected, especially if you skip the compressibility test and levels directly.

To activate Kopernikus's HVS mods in your own presets, name them with prefix "HVS" and then specify the HVS params in the last column of bin\xvid_presets.csv, substituting the required double-quotes with single quotes.

Giving your own presets a suffix of "MTK" will enforce some standalone friendly parameters such as VBV and -alt2pass. Other options like QPel and b-frames are still at your own discretion. BTW, If you use the MTK presets, the batch script will always split your movies into AVI file(s) of 2000MB@ unless an OGG audio file or a zone list file is found in the same directory (in such cases a MKV file will be muxed.)

Last edited by henryho_hk; 2nd August 2011 at 17:10.
henryho_hk is offline   Reply With Quote
Old 26th December 2006, 15:39   #2  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Version 2.4a is now obsolete.

Last edited by henryho_hk; 30th December 2006 at 12:15.
henryho_hk is offline   Reply With Quote
Old 26th December 2006, 16:06   #3  |  Link
buzzqw
HDConvertToX author
 
Join Date: Nov 2003
Location: Cesena,Italy
Posts: 6,552
sorry henryho_hk but why compress twice and to password protected ? 7zip is a good archive program and i think your work is pubblic accessible...

BHH
__________________
HDConvertToX: your tool for BD backup
MultiX264: The quick gui for x264
AutoMen: The Mencoder GUI
AutoWebM: supporting WebM/VP8
buzzqw is offline   Reply With Quote
Old 26th December 2006, 16:42   #4  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Version 2.5

Muxing is now performed using AVIMux_GUI, producing:
1. AVI for standalones (through MTK-nn presets).
2. OpenDML AVI (when zone file is not present).
3. MKV (when zone file is present).
4. Sorry that OGM support is removed.

Note: Version 2.5 is now obsolete.

Last edited by henryho_hk; 30th December 2006 at 12:46.
henryho_hk is offline   Reply With Quote
Old 26th December 2006, 16:43   #5  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Quote:
Originally Posted by buzzqw View Post
.... why compress twice and to password protected? ....
Just for a false sense of security. ^_^
henryho_hk is offline   Reply With Quote
Old 26th December 2006, 18:03   #6  |  Link
elguaxo
Registered User
 
elguaxo's Avatar
 
Join Date: Jun 2006
Posts: 260
Kopernikus's HVS mods & custom params

Quote:
11. Kopernikus's HVS mods & custom params
I started reading the HVS mods thread. The concept sounds great, but all those parameters were too much for me to start testing... I was waiting for some presets and here they are.

I see you use 2 options:
Code:
"-hvs_aq 'lc_lum 130 - theta lc_lum 140 - theta + lc_lum 40 - theta - lc_lum 50 - theta - 80 gl_lum - theta * quant +'"
"-hvs_aq 'quant 1 + lc_lum gl_lum 2 / - theta - lc_lum gl_lum 7 * 8 / - theta - lc_lum gl_lum 7 * 8 / 32 + - theta + lc_lum gl_lum 2 / 128 + - theta +'"
What is the idea behind these settings? Thanks!
elguaxo is offline   Reply With Quote
Old 27th December 2006, 16:07   #7  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Quote:
Originally Posted by elguaxo View Post
I started reading the HVS mods thread. ... I was waiting for some presets and here they are.
These presets are primarily for Teegedeck's (non-HVS) quality presets. I created the so-called HVS presets solely for experiments. I need the double-quotes to enclose the "columns" and therefore single-quotes are used within the column values. When I construct the real command-line, the single-quotes are changed back to double-quotes.

As for the ideas behind the HVS params, let's discuss in the HVS mods thread.
henryho_hk is offline   Reply With Quote
Old 27th December 2006, 21:19   #8  |  Link
ChrisW77
Registered User
 
Join Date: Sep 2006
Posts: 72
This looks great, but can anyone help a newbie ?

Lets say I have a simple script

Code:
LoadPlugin("C:\AviSynth\plugins\DGDecode.dll")
LoadPlugin("C:\AviSynth\plugins\MVTools.dll") 

video=mpeg2source("D:\video\project1.d2v", cpu=4, iPP=true, idct=5, info=3)
audio=MPASource("D:\video\project1 T01 DELAY 0ms.mpa")
AudioDub(video, audio)
ColorMatrix(hints=true)
ConvertToYV12(interlaced=false)
Crop(2,2,-2,-2,align=true)
Lanczos4Resize(640,360)
It's progressive, 16:9 720x576 Mpeg2 25fps PAL file.
Saved as simpletest.avs.
What would I add to simpletest.enc.txt ?
And how do you know what to add to simpletest.zones.txt

I just need a example, then hopefully I can figure out other tests from a example.

Any help, most appreciated, cheers.
ChrisW77 is offline   Reply With Quote
Old 28th December 2006, 01:24   #9  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
I have put some online help and usage samples in the batch script. You can read it by running the batch script without any parameters (double-click on the batch script). The default settings are pretty good actually and you can simply drag and drop your AVS on the batch script.

The format of simpletest.enc.txt is, for example,
-----start------------------------------------------------------
TGHQ-CT 0.147bppx VGA_1:1
-----end--------------------------------------------------------
or if you want to specify in kbps
-----start------------------------------------------------------
TGHQ-CT 1200kbps VGA_1:1
-----end--------------------------------------------------------
or if you want to specify a preset level (over/under-size warning)
-----start------------------------------------------------------
TGHQ-45 1200kbps VGA_1:1
-----end--------------------------------------------------------
or if you want anamorphic encoding (i.e., no resize inside AVS)
-----start------------------------------------------------------
TGHQ-45 1200kbps PAL_4:3
-----end--------------------------------------------------------
or if it is an interlaced footage
-----start------------------------------------------------------
TGFAST-45 1200kbps PAL_4:3 TFF
-----end--------------------------------------------------------

As for zone file, you simply list the zone points (frame numbers) on every line, e.g.:
-----start------------------------------------------------------
0
104435
298597
403768
-----end--------------------------------------------------------

BTW, since your footage is progressive, you should remove "iPP=true" in your AVS script.
henryho_hk is offline   Reply With Quote
Old 28th December 2006, 01:29   #10  |  Link
pancserzso
Registered User
 
Join Date: Oct 2004
Posts: 123
Good idea, but it's still buggy on my xp64 machine.

It says
Quote:
'Files' is not recognized as an internal or external command,
operable program or batch file.

Files was unexpected at this time.
I think it's a C:\Program Files\, just an idea

Last edited by pancserzso; 28th December 2006 at 01:34.
pancserzso is offline   Reply With Quote
Old 28th December 2006, 01:35   #11  |  Link
pancserzso
Registered User
 
Join Date: Oct 2004
Posts: 123
FIX:

I moved it onto the root of the drive and now it works!
pancserzso is offline   Reply With Quote
Old 28th December 2006, 01:48   #12  |  Link
ChrisW77
Registered User
 
Join Date: Sep 2006
Posts: 72
Thanks for your help, henryho_hk
I'll have a closer look at the batch script.

Oh, and thanks for pointing out the "iPP=true", I didn't spot that.
ChrisW77 is offline   Reply With Quote
Old 28th December 2006, 15:58   #13  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
BTW, ChrisW77, although I've included audio encoding from AVS, I suspect that it may lower the video encoding speed. Hence, I suggest you to encode the audio separately and let my script to do the muxing only.
henryho_hk is offline   Reply With Quote
Old 28th December 2006, 16:13   #14  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Thank you for pointing out this bug, pancserzso.

The script was designed to allow spaces in the batch or the script filename/paths but the recently added codes have some quotation marks missing. Hopefully I have put in all necessary ones now and it will work again.

Note: Version 2.5a has been replaced by 2.5b.

Last edited by henryho_hk; 30th December 2006 at 12:17.
henryho_hk is offline   Reply With Quote
Old 28th December 2006, 21:03   #15  |  Link
ChrisW77
Registered User
 
Join Date: Sep 2006
Posts: 72
Still couldn't get it to work, it seems to say something in the DOS window, then closes. Perhaps, it was a similar message pancserzso's, but it was too quick to see.

I just named a .enc.txt file the same as the .avs file, and added

TGFAST-CT 1300kbps PAL_16:9 test.avs

to it, and it just disappears. If I take out test.avs, it acts just like when you double-click your batch file, and gives the same info thats in the batch file.
I didn't use a zones.txt file, in the end, as it looked like you didn't actually require it unless you need to specify key points ?

When that new attachment has been verified, I'll try that one, and see how it goes. Damn, I hate being a newb, at time.
ChrisW77 is offline   Reply With Quote
Old 29th December 2006, 00:16   #16  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
It should be:

TGFAST-CT 1300kbps PAL_16:9
or
TGFAST-CT 1300kbps PAL_16:9 PRO

"PRO" means progressive. As for zone file, you can also specify the zone weights such as credits. I have not tried to test it much and you can help to evaluate it.

BTW, does the included sample work for you?

Last edited by henryho_hk; 29th December 2006 at 01:16.
henryho_hk is offline   Reply With Quote
Old 29th December 2006, 01:59   #17  |  Link
ChrisW77
Registered User
 
Join Date: Sep 2006
Posts: 72
Quote:
BTW, does the included sample work for you?
It does, yes. Comes up with "Checking Source....", Streaming Frame 0, and ends up with "All Completed......" "Press any Key to Continue", and you end up with 2 files sample_MTK-45_br_1381.avi, and sample_MTK-45_br_1381.stl.avi.

As I type this, I've used your "TGFAST-CT 1300kbps PAL_16:9 PRO", but this time I copied the 2 files, test.avs and test.enc.txt, to the actual directory i put avs2qxvid_25, which is simply C:\avs2qxvid_25, and now it works
If I keep the 2 files in a different directory, it doesn't work, but in the same directory, it works. I can live with that, as long as I have the space on the c: drive.

Thanks again, henryho_hk

Just to add, the original file, using the script in my first post, was 720x576, with a DAR of 1.778 (16:9). Now, after using "TGFAST-CT 1300kbps PAL_16:9 PRO", I'm left with a nice looking xvid, but the DAR is now 2.586 (31:12), yet the SAR remains 1.778 (16:9). Weird. Any ideas ?

Last edited by ChrisW77; 29th December 2006 at 02:08. Reason: add result
ChrisW77 is offline   Reply With Quote
Old 29th December 2006, 15:30   #18  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
ChrisW77, version 2.5a should allow you to put the batch script directory and the AVS directory anywhere you like (as long as the directory & file names are supported by the system code page). Actually, 2.5 works too (although you can't have any space character in the names).

The ARs are indeed correct. Unlike monitor pixels being squares (VGA_1:1), the TV pixels are rectangles. NTSC_16:9, PAL_4:3, and so on are called "pixel aspect ratio" (PAR) or "sample aspect ratio" (SAR), as reported in the form of "Video Type" and "Aspect Ratio" by DGIndex.exe. "Display aspect ratio" (DAR) is a combination of the resolution and SAR, e.g.:

2.586 = (640 / 360) * (16 / 11)

Yes, PAL_16:9 has pixels in 16:11. It's ~~REALLY~~ confusing. As for your script, since you have performed a resize operation already, you should perform a "square pixel encode" and use VGA_1:1. On the other hand, you may consider keeping the vertical resolution at 576 (humans are more sensitive to vertical resolution) and then either:

1. encode at PAL_16:9 without any resize; or
2. encode at VGA_1:1 while stretching the width (ouch.... I hate these calculations)

BTW, you can also use MPEG4Modifier to correct your encoded footages by setting their PAR as "Square Pixels". There won't be any re-encode and it runs fairly fast.

Last edited by henryho_hk; 29th December 2006 at 16:39.
henryho_hk is offline   Reply With Quote
Old 29th December 2006, 20:27   #19  |  Link
ChrisW77
Registered User
 
Join Date: Sep 2006
Posts: 72
Thanks again, henryho_hk. I'll get the newer file, and will have a few tests using this. Thing is, it's still waiting for approval.

Quote:
It's ~~REALLY~~ confusing. As for your script, since you have performed a resize operation already, you should perform a "square pixel encode" and use VGA_1:1. On the other hand, you may consider keeping the vertical resolution at 576 (humans are more sensitive to vertical resolution) and then either:
It is confusing, but I see what you are saying. I'll have to have a read up about PARS and DARS.

Quote:
1. encode at PAL_16:9 without any resize; or
2. encode at VGA_1:1 while stretching the width (ouch.... I hate these calculations)
I mostly resize when I use filters, as it's a nice speed up as the filters can work on a smaller frame size, as opposed to filtering 720x576. I need a faster CPU.

I'll have a look at MPEG4Modifier, as that sounds a great program.

Thanks again for your help.
ChrisW77 is offline   Reply With Quote
Old 30th December 2006, 07:41   #20  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Quote:
Originally Posted by ChrisW77 View Post
it's still waiting for approval.
I've just updated the links in the 1st post. You can download the latest version there.

I forgot to put the DAR (no, not PAR this time) value in the MKV header when muxing. This is corrected in version 2.5b.

Last edited by henryho_hk; 30th December 2006 at 12:54.
henryho_hk 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 11:02.


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