史萊姆論壇

返回   史萊姆論壇 > 教學文件資料庫 > 多媒體影音轉檔燒錄技術文件
忘記密碼?
論壇說明 標記討論區已讀

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


 
 
主題工具 顯示模式
舊 2004-03-06, 02:41 PM   #1
psac
榮譽會員
 
psac 的頭像
榮譽勳章
UID - 3662
在線等級: 級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時
註冊日期: 2002-12-07
住址: 木柵市立動物園
文章: 17381
現金: 5253 金幣
資產: 33853 金幣
預設 把你常用的Avisynth的Script及其功能,濾鏡寫在這裡

越來越多的人開始使用大有前途的 Avisynth,既然 shooter 上的教材沒有提太多此軟體,本論壇也談論得不多(雖然doom9的avisynth版塊很熱鬧),加之 Avisynth 的filter,plugin 滿天飛,大家就在這裡把你認為好(或不好的)的 filter 或者 plugin 及其功能,scrip,bug 問題等寫下來給大家分享,此帖就是為了分享!期望此帖後面有高人分析和總結。謝謝!
下面將提到的, 和其他很多很好的, plugin 和 filter, 您可以在這裡找到相關下載地址和鏈接(不保證是最新版本 )

好吧,小的丟磚了,最最最最最最最最簡單的,接住阿,不要砸到頭了 :

1.LoadPlugin(載入執行插件),internal.
語法:
LoadPlugin("path")
例: 加入你硬碟上D:\Aviplugins\Decomb\decomb.dll和D:\Aviplugins\MPEG2Dec3\MPEG2Dec3.dll 這兩個plug-ins.
LoadPlugin("D:\Aviplugins\decomb.dll")
LoadPlugin("D:\Aviplugins\MPEG2Dec3\MPEG2Dec3.dll")
這裡使用的是絕對路徑,也可以使用相對路徑。


2.mpeg2source, external: D.G.(neuron2)的mpeg2dec3dg.dll, Nic的MPEGDecoder.dll, Marc FD的mpeg2dec3.dll(要求YUY2輸入)

若是 film 型的 dvd 推薦使用 Nic 的 yv12的 MPEGDecoder.dll, 或者 DG 修改過的mpeg2dec3dg.dll
若是interlaced的dvd則不推薦用yv12的mpeg2dec3.dll和mpeg2decdg.dll, 因為其chroma upsampling是錯誤的. 詳情請看這貼Silky兄的解釋, 還有這裡, 最好使用mpeg2dec3.dll的yuy2版本(Marc FD的). (實際上最好使用m2v.aui, 但用法有點複雜, 請參見這裡)

語法:
mpeg2source("path")
例:解碼 e:\Studio\01.d2v,
mpeg2source("e:\Studio\01.d2v")

同樣,你也可以使用相對路徑。並且內嵌的 AviFileSource, DirectShowSource, AviSource, OpenDmlSource都有相似的使用方法(他們自己可能還有參數).


crop 和 resize 是 DVDRip 的必要的步驟, 而且可能遇到的問題會很多, 這裡只是最簡單的,更多的請看Silky兄在這裡的說明
3. crop(裁邊),internal
語法:
Crop(clip, int left, int top, int width, int height)或者
Crop(clip, int left, int top, int -right, int -bottom)
例: 720x480 裁到 704x352, 打算左裁8,右裁8,上裁64,下裁64:
Crop(8,64,704,352)或者
Crop(8,64,-8,-64)


4.調整大小,推薦使用 LanczosResize,internal
語法:
LanczosResize(clip clip int target_width, int target_height)
例: 原704x480(這個在此也沒什麼用) 打算resize到 640x480:
LanczosResize(640,480)


5.用 Decomb 做 NTSC 或 Pal 制式 DVD 的 IVTC ,及其 Telecide 做deinterlace, External: decomb.dll.
[Edit: 現在推出了Decomb 5, 語法有很多改變, 功能的強大和精確已經遠勝過我當初寫此文時的 Decomb 4, 推薦用 Decomb 5, 以下設置介紹由於 Decomb 5 的更新於12月5日修改]

常用語法:
I) Telecide (order, guide, vthresh, dthresh, chroma, post, blend, show)
常用參數:
a) order(0, 1, 無 defualt 設置)您必須手動設置此參數, order=1 代表您的 dvd 是 top field first(tff), order=0 則是 buttom field first(bff) 的. 如何判斷您的 dvd 是 tff 還是 bff 呢? 將下列腳本寫入另一avs檔案, 並導入進 vdmod(當然, 路徑和檔案名用您的):



代碼:--------------------------------------------------------------------------------mpeg2source("yourd2vfile.d2v")
AssumeTFF().SeparateFields()--------------------------------------------------------------------------------


然後預覽, 若播放正常(當然,畫面會很扁)則是 tff 的, 若播放時畫面很抽搐, 動作不連貫甚至順序顛倒等, 則dvd是bff的 .

b) guide(0-3, default 0):當已知 DVD 是 NTSC 或者 Pal 時,使用此參數可以大大提高 field matching[場的搭配]。
關閉此功能, 設guide=0;
是 NTSC 24fps-->30fps的DVD, 設guide=1;
對於簡單的 Pal DVD, 設guide=2;
是 NTSC 25fps-->30fps的DVD, 設guide=3.

c) vthresh (0.0-255.0, default 50.0): 設定一個閥值,超過此閥值telecide便認為它是有橫紋的禎,將在後面被deinterlace.增大這個值如果過多的好禎被deinterlace,減小此值如果一些地方的橫紋沒有被探測到。

d) dthresh (0.0-255.0, default 7.0): 當一禎被認為是有橫紋的時候便會被deinterlace,此參數設置 deinterlace 的強度, 越低的閥值 deinterlace 得越厲害。

e) chroma(true/false, default true): 開啟後,在檢測哪部分是交錯的時候,不僅計算亮度 bytes,也計算色度的 bytes. 尤其對動畫片有用。

f) post(0-5, default=2) postprocessing(後處理)的方法
post=0: 關閉後處理
post=1: 計算並顯示前面的 metrics, 但不作 deinterlace
post=2: 開啟 deinterlacing. 此模式下, 場的搭配(field matching)正常進行, 搭配得最好的幀被 deinterlaced 並輸出.
post=3: 同 post=2, 只是將用白色顯示 deinterlace 的動量圖(用於 debug).
post=4: 同 post=2, 只是不再輸出搭配得最好的幀,, 而是原幀被deinterlaced. 當您的 dvd 是 hybrid 的(即同時是 24fps 和 30fps 轉到 30fps 上的 DVD) 時候您會用到此選項
post=5: 同post=4, 只是將用白色顯示 deinterlace 的動量圖(用於 debug).

g) blend(true/false, defualt false)選擇 deinterlace 的方法是採用 blend 還是interpolation(內插), interpolation 的速度快些, 畫質個人覺得 blend 好些.

h) show(true/false, default false), 用於 debug, 開啟後您可以預覽中看到前面設置產生的效果, 相當有用的選項!
例如, 你打算設置前面的參數, 但不知怎樣的好, 您便將下面的 script 寫入avs, 導入到 vd/vdmod,

代碼:--------------------------------------------------------------------------------
mpeg2Source("yourd2vfile.d2v")
Telecide(order=1,guide=1,post=2,vthresh=30,show=true)--------------------------------------------------------------------------------


您會看到畫面出現"chose=xxxx", 當您找到一個合適的 chosen 的值x, 低於x的畫面是無橫紋的幀, 高於x的是有橫紋的幀, 就選擇此值為"vthresh" . 您不必檢查完所有的幀, 只需預覽幾處便可以(當然也有風險:P ), 並調整其他參數預覽其效果. 當確定好後, 在腳本中改為 show=false 或直接刪除 ",show=true" 就好了)

例, 對一個 NTSC 的 DVD 動畫片, 做 ivtc, dvd 是 top field first 的, 並發現vthresh若為20能很好的區分 progressive 和 interlaced 的幀:
Telecide(order=1, guide=1,thresh=20, post=2, chroma=true)
注意:使用 telecide() 後就不要使用 FieldDeinterlace() 了,因為 telecide()也做deinterlace(post=2,4)。

另外, 對於能用 dvd2avi 做 force film 的就用 dvd2avi 做 force film(大多數anamorphic寬屏的電影都可以), 就不要費勁又費時的用 decomb 了 .

telecide 後要做 decimate 才是完整的ivtc.
II) Decimate(cycle,quality)
常用參數:
a) cycle(2-25, default 5):設定刪除禎的比例,即每一個 cycle 刪除1禎。
b) quality(0-3, default 2):計算探測時的品質,品質越高速度越慢。
quality=0: 部分取樣,為速度著想不考慮色度(最快).
quality=1: 部分取樣,為速度著想並考慮色度.
quality=2: 完整取樣不考慮色度.
quality=3: 完整取樣並考慮色度(最慢).
例: 將 NTSC 的禎率降至 24fps,即5禎裡面刪除一禎,選擇要最好的品質:
Decimate(cycle=5,quality=3)
另外,加入另一個參數 mode=2 通常也是個好選擇,但速度會減慢很多。

還有,如果使用預設值設置,Script中寫入

代碼:--------------------------------------------------------------------------------Telecide()
Decimate()--------------------------------------------------------------------------------


要比

代碼:--------------------------------------------------------------------------------
Telecide
Decimate--------------------------------------------------------------------------------

快很多!

像 Telecide(order=1, guide=1,thresh=20, post=2, chroma=true), 有參數沒有指定, 則這些參數使用預設值值

注意在 crop 和 resize 和其他所有處理之前使用 Decomb 的功能!!

Decomb 還有很多其他選項, 在其說明檔案裡有詳細的介紹, 上文我也是做簡單翻譯和一些註釋而已:P.

其他的:
#
#後此排的所有文本都僅僅是註釋,不會被 Avisynth 及其 filter/plugin 採用
您可以用#來加上註釋或隔離, 讓您的 script 更讓人理解一點, 如

#~~~~~~~~~~ 載入執行 plugin~~~~~~~~~~~~~~~~~~~~~~~~~
Loadplugin("mpeg2dec3dg.dll")
Loadplugin("decomg.dll")
#~~~~~~~ MPEG-2解碼 + IVTC~~~~~~~~~~~~~~~~~~~~~~
mpeg2source("01.d2v")
Telecide(order=1, guide=1,thresh=20, post=2, chroma=true)
Decimate(cycle=5,quality=3)
#~~~~~~ Crop + Resize~~~~~~~~~~~~~~~~~~~~~~~~~~~
crop(8,0,-8,-0)
LanczosResize(640, 480)
加入另一個參數mode=2通常也是個好選擇,但速度會減慢很多。
"加入wav音頻的script"

video = mpeg2source("C:\VOB\FFX2\ffx2-1.d2v")
audio = WAVSource("your.wav")
AudioDub(video, audio)






加一個我長用的計算PSANR的:

orig=avisource("vd.avi")
encoded=avisource("cm.avi", false)
compare(encoded,orig, "rgb")

在這裡VD.AVI和CM.AVI都是我用VD的幀服務輸出的虛擬的AVI檔案
如果想對每個AVI進行其它處理,可參照下面的語句範例:
選段範例:
orig=avisource("vd.avi").trim(100,500)



http://www.shooter.com.cn/?artid=7&show=1

再給你轉一片Doom9上的文章吧.
發信人: idealist (呵呵), 信區: Doom9dotNet
標 題: Avisynth frameserving校驗稿
發信站: BTBBS (2003年03月02日18:21:40 星期天), 站內信件

www.doom9.org/mpg/d2a-mpeg2dec.htm
翻譯: paradiso @2003.2.26
校驗: idealist @2003.2.28

DVD2AVI & MPEG2DEC

A recently released MPEG-2 decoding plugin for Avisynth makes it
possible to speed up DVD2AVI frameserving quite a bit by keeping the
video data in the DVD-native YUV2 colorspace (VFAPI operates in RGB so
everything has to be converted which of course takes time). Furthemore,
combined with a MMX optimized Avisynth version, we can expect a
considerable performance gain. On my machine I got 4 fps more using this
combination to encode a DivX compared to the results using the
traditional VFAPI way. But while it's faster it's also yet another level
of complexity so unless you're familiar with the VFAPI way (explained
in every guide that uses DVD2AVI) I suggest that you do not touch this
method.
最近出的一個Avisynth的Mpeg-2解碼插件通過把視頻資料保留在DVD原始的YUV2
colorspace使得DVD2AVi Frameserving的速度大為提高(VFAPI是在RGB
colorspace中操作,因此什麼東西都必須轉換為RGB,造成速度極慢)。另外,結
合MMX優化的Avisynth版本也能有速度提高。在我的機器上,用這個組合壓縮DivX
相對於傳統的VFAPI方式每秒提高了4幀。但是他雖然更快,也更複雜。所以除非你
已經很熟悉VFAPI的方法(每個DVD2AVI的指南裡都提到過),我還是建議你不要用
這種方法。

Since we're going to use avisynth in this tutorial, and not only as a
simple frameserving mechanism but to crop and resize as well I
strongly suggest that you visit the Avisynth homepage and check out
the Avisynth tutorial and the Avisynth scripting reference. While you
can get along without having read these it's as with any advanced
program: You can only properly master it by having RTFM!
由於我們在這個演示中要是用avisynth,而且不是僅僅作framserving的機制而也
要進行crop和resize,因此我強烈建議你去Avisynth主頁看看Avisynth tutorial
和Avisynth scripting reference。雖然不
看這些你也能做下去,但是對於任何比較複雜的程序來說:你必須通讀手冊才能恰
當的掌握它。
(譯註:You can only properly master it by having RTFM!,RTFM=read the
fine manual)

You need the following software in this guide:
本指南中需要以下軟體:

Avisynth
DVD2AVI 1.76 or later
MPEG2DEC Avisynth plugin.

Now let's get started
現在我們可以開始了。

Step 1: Create a DVD2AVI Project
第一步:建立DVD2AVI工程

At first you'll have to load your VOB files. If the files are
consecutively named selecting the first VOB will load all the others.
首先你必須載入VOB檔案。如果這些檔案是連續命名的那麼只要選擇第一個就會自
動新增後面的。

The next step is finding out what kind of movie we're dealing with.
Press F5 to start the preview. Let it run for a bit and watch the status
window.
下一步是看看我們在處理什麼格式的電影。按F5開始預覽。讓它執行一會兒,觀察
status視窗。

Here's two thing you may want to write down: The first is Aspect Ratio.
Here you'll either get 16:9 or 4:3. The other is the frame type.
這裡有兩個你需要記住的東西:第一個是Aspect Ratio,要麼是16:9要麼是4:3,
另一個是frame type。

Frame Rate = 25.000 fps: your source is PAL and you can skip the
following step.
Frame Rate = 25.000 fps: 視頻源是PAL制式的。你可以跳過下面的步驟。

Frame Rate = 29.970 fps: Let the preview run for a couple of minutes,
then take a look at the Video Type: If it's FILM at a percentage
higher or equal to 95% you can activate Forced FILM as shown below.
Otherwise you will have to perform IVTC.
Frame Rate = 29.970 fps: 預覽幾分鐘,看Video Type:如果是FILM,百分比高於或等
於95%或者只顯示FILM那麼你就開啟Forced FILM(如下圖所示),否則就
要進行IVTC(過程在後面詳述)。

The next step is audio decoding. Depending on your favorite audio
decoder you can let DVD2AVI decode your audio track.
下一個步驟是對音頻解碼。你可以選擇自己喜歡的解碼器,也可以用DVD2A
VI解碼音軌。

As I prefer to let Graphedit do this task I always select None here.
Just select the right track if you want DVD2AVI to decode the audio.
If you need downsampling you can activate downsampling in the 48 -> 44.
1KHz submenu. I suggest you use High quality when using that feature.
我喜歡用Graphedit做這一步,因此我在這裡選擇None。選擇你希望DVD2AVI解碼的
音軌,如果需要降低采樣率你需要在48 -> 44.1KHz子表單中啟動他。我建議你使
用High quality進行這一步。

Finally in the Dolby Digital submenu activate decode.
最後在Dolby Digital子表單中選擇decode。

Now we have to make sure that the video data stays in YUV format. Make
sure that YUV is checked, otherwise we're going to lose our speed
advantage.
現在我們必須確保視頻資料是YUV格式的。確定選擇了YUV,否則速度會很慢。

The next step is finding out the parameters for the cropping operation
which we're going to perform later on (not that VCD&SVCD creation
don't need this). Move the slider of DVD2AVI to a position where you can
see a picture, then activate the Clip & Resize window from the Video
submenu and check the checkbox in the upper right of the window:
下一步是找出進行crop操作所需的參數(注意,(S)VCD不需要這一步)。移動
DVD2AVI的進度條,看到畫面後從Video子表單中啟動Clip & Resize視窗,鉤選窗
口右上角的框。

Note that certain options of this window don't work, but they eventually
will in the next full release.
注意,這個視窗的一些選項還不能工作,但在下一個完整版本裡面就會有
了。

Move the Top and Bottom sliders until the black bars on top and bottom
have disappeared. Unfortunately it's not possible at the moment to
crop by 1 pixel, so if you thing that one value leaves a black line
and a higher value crops into the picture just take the value in the
middle.
移動Top和Bottom的滑塊,直到上下的黑邊消失。不幸的是目前還沒有按像
素crop的方法,所以如果一個取值還沒有完全去除黑邊兒而大一點的值會
摳進圖像的話就折中一下好了。

The values shown in the screenshot are for a 1:2.35 16:9 movie, but
not all movies are transferred in the same way so you better do this
step instead of just using some values you found somewhere on the web.
截圖中所示的值是對一個1:2.35 16:9的電影來說的,但並不是所有的電影都是同
樣的處理方法,所以你必須作這一步而不是僅僅用一些在網上找到的值。

Once you've found the right values uncheck the checkbox again.
得到正確的值以後就可以取消框的選擇。

Now you'll just have to create a DVD2AVI project file which can then
be processed further.
現在你只需要新建一個預備役後處理的DVD2AVI工程檔案就可以了。

Step 2: Avisynth setup & script creation
第二步:Avisynth設置及script的新建

First of all comes the installation. After unpacking you have to copy
AVISYNTH.dll to the following directory:
首先當然要安裝。解壓後把avisynth.dll拷貝到如下目錄:

Windows 9x/ ME: c:\windows\system
Windows NT / 2000: c:\winnt\system
Windows XP: c:\windows\system32

Then double click on install.reg and just to make sure reboot your
machine.
然後雙擊install.reg,再重啟電腦。

Now let's verify that Avisynth is properly installed by creating the
following script:
現在新建如下一個腳本來測試avisynth是否被正確安裝了:
AviSource("c:\temp\test.avi")

Type this line in Notepad, then save it as c:\test.avs. Make sure that
the filetype field in the save dialog box says All Files (*.*) and NOT
Textfile (*.txt). Now right click on c:\test.avs in explorer, select
open-with and select the Media Player from the list. If it plays,
everything is good and we can proceed.
在記事本中輸入這一行,儲存為c:\test.avs。確保儲存檔案對話視窗的檔案類型一
欄是所有檔案(*.*)而不是文本檔案(*.txt)。在Explorer中右擊c:\test.avs,選
擇開啟方式,然後選擇列表中的Media Player。如果播放正常,那麼我們就可以繼
續了。

To load the MPEG2Dec plugin you have to use the LoadPlugin command and
give it the full path and filename of the plugin to load as argument.
The next step is loading your DVD2AVI project file using the mpeg2source
command. Note that MPEG2Dec provides this function so if you forget
LoadPlugin it won't work. The following is a sample scrip which simply
opens the d2v file.
我們以插件的完整路徑和檔案名為參數使用LoadPlugin命令,來載入Mpeg2Dec插件
。下一步就是用mpeg2source命令載入DVD2AVI工程檔案。注意這個函數是
MPeg2Dec提供的,所以如果你忘了寫LoadPlugin他就不會工作了。下面是一個開啟
d2v檔案的腳本例子:

LoadPlugin("c:\temp\MPEG2DEC.DLL")
mpeg2source("D:\matrix\matrix.d2v")

If you load this script into any encoding program that can read avs
files you'll get the output of DVD2AVI, that is the decoded MPEG-2
data without any resizing applied (so the aspect ratio will be off).
如果你在任何可以讀取avs檔案的編碼程序中載入這個腳本,你會得到DVD2
AVI的
輸出。這是沒有變形的解碼後的MPEG-2資料(所以縱橫比將不起作用)。

The next step is cropping. You can skip it for SVCD creation. Now the
values you wrote down when working in DVD2AVI become useful again.
Cropping works by the use of the Crop function in Avisynth. It takes 4
arguments: Left, Top, Horizontal output size and vertical output size.
Here's an example which crops a 16:9 1:2.35 NTSC stream:
下一個步驟是Crop(摳取)。如果是做SVCD可以跳過這一步。現在你剛才用
DVD2AVI的時候記下來的值有用了,我們通過使用Avisynth的Crop函數來進行crop
,它有四個參數:左,上,水平輸出大小,垂直輸出大小。這是一個摳取16:9 1:
2.35 NTSC視頻流的例子:
Crop(0,60,720,360)

This will crop the top 60 line of the video, plus the bottom 60 lines
(remember that the video stream originally was 720x480, so if you crop
the top 60 lines away and take the next 360 lines that cuts off the
bottom 60 as well - 60 (black) + 360 (video) + 60 (black) = 480) If
you add this line to the script above you'll now get a 720x360 video
stream which has no black bars, just the video data.
這樣會把上下60行都摳掉(注意,視頻流原本是720x480,所以去掉上面60,加上360,
下面就等於也摳掉60--60 (black) + 360 (video) + 60 (black) = 480)
。如果你把這一行加入上面的腳本中你就會得到一個沒有黑邊的720x360的
流,只有視頻資料。

DivX resizing
DivX 調整大小(resize)

Now we come to the last operation: resizing. Avisynth offers both
Bilinear and Bicubic resize. Bicubic is more accurate and hence slower,
and it should be used for higher quality output (2 CD DivX and SVCD).
The arguments are the same for both resizing methods: You specify
horizontal and vertical output size. For instance to resize your video
stream to 640x272 using Bilinear resizing you'd add the following line
to your script:
現在我們到最後一步了:調整大小。Avisynth提供Bilinear resize和Bicubic
resize。Bicubic更精確一些,因此也更慢,所以在輸出高清晰度檔案(雙CD
DivX和SVCD)時應該使用它。兩種調整大小的方法的參數都是相同的:需要設定輸
出的長度和寬度。舉個例子:如果你要把視頻流使用Bilinear Resize調整到
640x272,那麼你需要在腳本中加入如下一句:
BilinearResize(640,272)

For Bicubic Resize the line would be: BicubicResize(640,272).
如果是Bicubic Resize,那麼應該是:BicubicResize(640,272) 。

So a full script that would load the d2v project, crop and resize it
to 640x272 would be:
因此,一個讀取d2v,進行crop然後調整到640x272的腳本是這樣的:

LoadPlugin("C:\temp\MPEG2DEC\MPEG2DEC.DLL")
mpeg2source("d:\matrix\matrix-unresized.d2v")
Crop(0,60,720,360)
BilinearResize(640,272)

Note: It's also possible to do resizing and cropping using the regular
filters. In order to do this simply place all the crop parameters
after the resize parameters. Example:
注意:也可以用同一個filter做resize和crop,只要把crop參數放到resize參數後
面就可以了,比如:
BilinearResize(640,272,0,60,720,360)

SVCD resizing
SVCD 調整大小

As mentioned before here no cropping is necessary. But once again we
have to do the letterboxing on our own. As people who have used
VirtualDub for SVCD frameserving already know what we have to do is to
resize to 480x362, then add some black bars. To add black borders we use
AddBorders which takes the following 4 arguments: left, top, right
and bottom. In Avisynth language that would become the following:
如上所述,這裡並不需要做crop。但是我們再次需要自己做letterbox。用
VirtualDub做SVCD framserving的人已經知道我們需要把它調整到480x362,然後
加上黑邊。加黑邊要用到AddBorders,有四個參數:左,上,右,下。Avisynth裡
面是這樣表述的:

BicubicResize(480,360)
AddBorders(0,60,0,60)

So the script would become
因此腳本變為:

LoadPlugin("C:\temp\MPEG2DEC\MPEG2DEC.DLL")
mpeg2source("d:\matrix\matrix-unresized.d2v")
BicubicResize(480,360)
AddBorders(0,60,0,60)

Please note that for PAL the script would be
注意,對於PAL制式,腳本應該是這樣的:

LoadPlugin("C:\temp\MPEG2DEC\MPEG2DEC.DLL")
mpeg2source("d:\matrix\matrix-unresized.d2v")
BicubicResize(480,432)
AddBorders(0,72,0,72)

Audio:
音頻

If you have done audio in DVD2AVI you might want to add this to your
Aviynth script. In order to do this you make use of the WavFile function
which takes the path and name of the WAV file as argument. And now we
get a little more into programming. I don't know if this is completely
accurate but it appears to me as if mpeg2source would return the mpeg2
stream and all the following operations would be applied to this
returned stream. If you'd add wavsource("d:\matrix\audio.wav") after
mpeg2source you'd end up with some errors, as now Avisynth would try
to apply the cropping to you wave source, which of course won't work.
What you have to do instead is to define temporary variables for both
video and audio. Here's an example:
如果你在DVD2AVI中已經處理完音頻現在也許你希望在Avisynth腳本中加上這個
部分。你需要以wav檔案的路徑名和檔案名為參數使用WavFile函數。我們現在做的
事情有點像是在編程。我不知道我的感覺是否準確,但似乎mpeg2source會返回
mpeg2視頻流,之後的所有操作都會被應用到這個流上。如果你在mpeg2source之後
加上wavsource("d:\matrix\audio.wav")將出現錯誤,因為avisynth會試圖對音頻
流也進行crop,這當然會失敗。你要做的就是給音頻和視頻分別定義臨時變量,例
如:
video=mpeg2source("d:\matrix\matrix-unresized.d2v")
audio=wavsource("d:\matrix\audio.wav")
audiodub(video,audio)

where the last line adds video and audio stream to one stream and
returns it. Now you can place your crop & resize lines.
最後一行返回音頻流和視頻流合成以後的流。現在你就可以寫crop和resize了。
LoadPlugin("C:\temp\MPEG2DEC\MPEG2DEC.DLL")
video=mpeg2source("d:\matrix\matrix-unresized.d2v")
audio=wavsource("d:\matrix\audio.wav")
audiodub(video,audio)
Crop(0,60,720,360)
BilinearResize(640,272)

Is the final result for a DivX Avisynth script.
這就是最終的DivX Avisynth腳本。

You can now load your avs file into the encoding program of your choice.
Note that to prevent confusion I won't link to all the possible
guides where you could continue now but if you've made it so far I'm
sure you'll manage to find the right place to continue.
你現在可以在編碼程序中載入這個avs檔案。注意,為了防止迷惑我在這裡沒有聯
接任何可以繼續做的指南。但是如果你已經作了這麼多了,我想你自己能夠找到你
要的東西,繼續下去。

A last word for the DivX crowd: In VirtualDub you have to set video to
Fast Recompress to profit from the speed increase. This means that you
can't use additional filters :/
最後一句:在VDub中你需要把Video設為Fast Recompress來加快速度,代價是不能
使用VDub附加的filter。:/

This document was last updated on January 5, 2003
英文文檔更新於Jan 5,2003
中文文檔翻譯於Feb 26,2003
--
加入字幕、設置音頻的錯位時間可以有軟體代勞嗎??


去裝一個VobSub,用裡面的TextSub可以加入ssa,ass,srt字幕
用vobsub.dll可以加入sub字幕。

音頻錯位分離時DVD2AVI會標出的,注意有正負之分。
然後用AviSynth的DelayAudio就可以了。
這樣吧,乾脆我來個徹底的算了。

#
# PLUGINS
LoadPlugin("E:\Tools\DivX\Plugin\AviSynth\MPEG2Dec3.dll")
LoadPlugin("E:\Tools\DivX\Plugin\AviSynth\Decomb.dll")
LoadPlugin("E:\Tools\DivX\Plugin\AviSynth\TextSub.vdf")
#
# SOURCE
Video=MPEG2Source("路徑\XXX.d2v")
Audio=WAVSource("路徑\XXX.wav").DelayAudio(-0.224)
Movie=AudioDub(Video,Audio)
#
# IVTC
Telecide(Movie,guide=1,chroma=true)
Decimate(Movie)
#
# CROP
Crop(Movie,8,0,704,480)
#
# RESIZE
LanczosResize(Movie,Movie,640,480)
#
# SUBTITLE
TextSub(Movie,"路徑\XXX.ass")
#
# FINISH
return Movie

當然了,裡面的Crop和Resize以及DelayAudio要按照實際情況來做。
加入的音頻檔案一定要是wav嗎??可以是ac3或mp3嗎??
還有這一段:
# IVTC
Telecide(Movie,guide=1,chroma=true)
Decimate(Movie)
#
# CROP
Crop(Movie,8,0,704,480)
#
# RESIZE
LanczosResize(Movie,Movie,640,480)
#
# SUBTITLE
TextSub(Movie,"路徑\XXX.ass")


裡面的IVTC的設置語法是什麼意思可以詳細解釋一下嗎??還有那個crop和resize的詳細解釋也請麻煩一下吧~~ 對這個AviSynth我還真是很不上手~

這個東西的設置有沒有GUI界面的小工具??


下面這個好像是個GUI界面的小工具:

AvisynthEditor 0.3 beta
AvisynthEditor 0.3 beta

# .def files replaced with DVX .xml files (great work Dolemite!)
# 'Save As' bug should be fixed
# Comment/Uncomment block (need some fixes)
# Recent files
# Filter description/help window
# Filter Treeview modes: Plugins and Categories
# commandline args:
# -i: input filename
# -ot: opener title (for external call)
# -oh: opener text handle (use Spy++ to test)
# Example:
# "C:\Program files\AvisynthEditor\AvisynthEditor.exe" -i "C:\tmp\script.avs" -ot "VirtualDubMod" -oh 001059C
# -> Start AvisynthEditor, edit script then click "Back to VirtualDubMod".

@sh0dan: I still have problem with TAB key, I'll try to find a way to handle your request

have fun !!

Screenshot: http://www.lalternative.org/img/AvisynthEditor.gif
Download: http://www.lalternative.org

Best regards,


__________________
akabob
mailto:akabob@lalternative.org
x2real - AvisynthSwitcher - AvisynthEditor
http://www.lalternative.org
http://www.autorv9.fr.st

Q:
裡面的IVTC的設置語法是什麼意思可以詳細解釋一下嗎??還有那個crop和resize的詳細解釋也請麻煩一下吧~~ 對這個AviSynth我還真是很不上手~~

A:
AviSynth 教程


一、簡述

AviSynth是AVI SYNTHesizer的縮寫,意思就是AVI和成器,是一個Frameserver。(Frameserver就是一個把影像檔案從一個程序轉換到另外一個程序的過程, 其間沒有臨時檔案或中介檔案產生)

AviSynth是由Ben Rudiak-Gould首創的一種非常有用的工具,能夠提供各種方式來合併和濾鏡處理影像檔案。最獨特的就是AviSynth並不是一個孤立的影像處理程序,而是在影像檔案和應用程序之間擔任「中間人」的角色。

AviSynth的基本工作原理是這樣的:
首先建立一個包含特定命令的文本,稱之為「腳本」(後綴為avs),這些命令指定要執行處理的影像檔案和濾鏡;
然後執行影像應用程序,比如VD或ND,開啟腳本。此時AviSynth就開始工作了,開啟腳本中指定的影像檔案,執行特定的濾鏡,並把輸出結果提供給影像應用程序。但影像應用程序並不瞭解AviSynth在後台所做的處理,而認為是直接開啟了一個「被處理過」的影像檔案。

因此使用AviSynth有5大優勢:
1. YUV支持:內建濾鏡可以在YUV環境下執行,第三方濾鏡幾乎也相容YUV,所以比起VD、ND的內嵌濾鏡必須在RGB環境下執行要快很多。省卻了一個轉換的過程,將來還可以支持YV。
2. 濾鏡處理:內建許多影像處理濾鏡,比如Resizing,Cropping等。還有大量的第三方強力濾鏡,並可以使用VD以及AviUtl的第三方濾鏡。
3. 突破2G限制:通過AviSynth開啟影像檔案就相當於應用程序直接開啟,這樣就可以使本身有2G限制的程序也能突破2G的限制。
4. 開啟格式:AviSynth可以開啟幾乎所有影像檔案,包括MPEG和QuickTime。所以當影像應用程序通過AviSynth開啟這些檔案時,會被認為是開啟標準的AVI,這樣就可以處理影像應用程序本身並不支持的格式。
5. 節省硬碟空間:AviSynth處理的影像檔案在執行過程中直接導入應用程序,沒有臨時檔案,所以節省硬碟空間。

AviSynth現在有3個版本,第一個是Ben Rudiak-Gould的首先編譯的AviSynth v1.0b;在Ben Rudiak-Gould停止開發後,Edwin van Eggelen繼續開發,最新的版本是AviSynth v1.0b6;在2002年7月第二次源碼編寫計劃開始,目前最新的版本是AviSynth v2.0.6,新的v2.5版還在開發中。
最後一個版本比較強大,更新速度快,增加了許多實用的命令,也吸收了一些優秀的第三方濾鏡成為內建濾鏡,強力推薦使用。

二、安裝

AviSynth的安裝可謂簡單,先下載AviSynth,然後解壓縮,把AviSynth.dll複製到Windows\System下(W98,ME)或Windows\System32下(W2K,XP),然後執行INSTALL.REG就完成安裝了。


三、內建濾鏡

AviSynth內建了數目繁多的濾鏡,所以只能介紹一些最常見實用的一部分。

1、源檔案濾鏡

1 AVISource
導入AVI,對於DivX或XviD,需要安裝相應的Codec。
例:AVISource(「test.avi」)
2 WAVSource
導入WAV
例:WAVSource(「test.wav」)

2、處理濾鏡

1 AddBorders
加邊:給影像加黑邊,尤其適用於對16:9的影像加字幕,希望不影響圖像,把字幕加在圖像的下方的情況。參數是整數,順序是左、上、右、下。
例:AddBorders(0,64,0,64) # 把640*352(16:9)改成640*480(4:3)
2 ConvertToRGB 和 ConvertToYUY2
改變顏色環境:
VD和AviUtl第三方濾鏡有的需要RGB環境才能執行,需要ConvertToRGB來進行切換。
有的RAW檔案是RGB的,但使用的AVISynth濾鏡只能執行在YUV下,就需要用ConvertToYUY2來執行。
例:ConvertToRGB() # 改變成RGB顏色環境
ConvertToYUY2() # 改變成YUV顏色環境
3 Crop
切邊:為了保持比例或切除黑邊,參數是整數,順序是左、上、寬、高。
例:Crop(8,0,704,480) # 左右各切去8,以保持比例
4 Levels
層次:調節亮度、對比度和Gamma值。
例:Levels(0,1.2,255,0,255) # 調整Gamma,使畫面變亮


5 LanczosResize
放大縮小:Lanczos采樣方法可以在圖像處理中看到,是BicubicResize的替代者,提供更精準、更銳利的畫質。本來是日本人開發的第三方濾鏡,在日本普遍使用,歐美使用BicubicResize。自2.05版本開始吸收為內置濾鏡。
例:LanczosResize(640,480) # 把解析度改變為640*480
6 Tweak
調整:可以調節色度,飽和度,亮度,對比度。
色度:-180.0∼180.0,預設值0.0。正數趨向紅色,負數趨向綠色。
飽和度:0.0∼10.0,預設值1.0。0.0為黑白。
亮度:-255.0∼255.0,預設值0.0。
對比度:0.0∼10.0,預設值1.0。

3、編輯濾鏡

FadeIn 和 FadeOut
淡入和淡出:提供淡入和淡出功能,尤其是淡出功能,可以使影片結束地更自然。參數為整數,表示需要編輯的幀數。
例:FadeOut(24) # 影片最後1秒淡出
Trim
截取:決定需要處理的部分。參數為整數,表示需要編輯的開始幀和結束幀。對抽樣做Sample比較有用。
例:Trim(240,480) # 決定處理240∼480這一片斷

4、聲音濾鏡

1 AudioDub
影音合併:可以把影像和聲音合併在一起。適用用用Helix直接做RMVB格式的DVDrip。
例:Video = AVISource("test.avi")
Audio= WAVSource("test.wav")
AudioDub(Video,Audio) # 把test.avi和test.wav合併
2 GetLeftChannel 和 GetRightChannel
獲取聲道:把立體聲的左右聲道單獨返回,適用於左右聲道不同語種的WAV。
例:stereo=WavSource("test.wav")
return GetLeftChannel(stereo) # 返回test.wav的左聲道
DelayAudio
聲音延遲:由於從VOB裡分離的AC3通常有延遲,所以用Azid轉碼得到的WAV也有延遲,在用AudioDub合併時就需要加上這個延遲。
例: WavSource("test.wav").DelayAuido(0.5) # 把test.wav延遲半秒





四、第三方濾鏡

AviSynth最強大之處就是有數目繁多、功能強大的第三方濾鏡;同時還可以使用VD以及AviUtl的濾鏡;甚至還有特別開發的連接頭,可以讓TMPGEnc和AviUtl讀取AVS。
和內建濾鏡不同,第三方濾鏡需要先使用聲明,再可以使用。

1、源檔案濾鏡

1 MPEG2Dec
由dividee編寫的讀取DVD2AVI產生的d2v工程檔案的濾鏡,同時內建去除Noise的TemporalSmoother。
例:LoadPlugin("MPEG2Dec.dll")
MPEG2Source(」test.d2v」)
2 MPEG2Dec2
trbarry在MPEG2Dec的基礎上進行了改進,支持P4的SSE2命令集。用文本編輯工具開啟d2v,把iDCT_Algorithm=?改成5就可以了。速度很快,效果也好,推薦P4 CPU的用戶使用。
例:LoadPlugin("MPEG2Dec2.dll")
MPEG2Source(」test.d2v」)
3 MPEG2Dec3
在MPEG2Dec2的基礎上再進行了改進,加入了Nic的圖像後處理(PP),一定程度上可以減少Noise。好像除了P4的SSE2外,還加入了AMD的3D Now!優化,目前還在開發中,是個非常有前途的濾鏡。
例:LoadPlugin("MPEG2Dec3.dll")
MPEG2Source(」test.d2v」,CPU=4) # CPU=4就是開啟了PP模式

2、處理濾鏡

1 SimpleResize
放大縮小:由trbarry編寫的,由於對SSE進行了優化,所以速度快,效果好。替代了AviSynth中的BilinearResize。和LanczosResize的米切爾雙立方體算法不同,這個是單純的雙線性算法。LanczosResize的畫質更銳利和真實,適合普通電影;而SimpleResize的畫質較柔和,適合動畫。
例:LoadPlugin("SimpleResize.dll")
SimpleResize(640,480)
2 ColorYUY2
顏色補償:Kiraru2002編寫的濾鏡。由於經過編碼,得到的結果和DVD相比較,顏色有所改變,所以要對顏色進行補償。
例:LoadPlugin("ColorYUY2.dll")
ColorYUY2(0,10,0,10,0,0,0,0,0)


3、交錯濾鏡

Decomb
IVTC和Deinterlace濾鏡:由Donald A.Graft編寫,新增加的專門處理NTSC格式動畫的mode=2,要和Avisynth2.05以上版本使用,不然速度會慢一倍。

guide 0~2,預設值0, NTSC用1,PAL用2,可以提高IVTC準確度。
gthresh 0~100,預設值15,控制區分不同幀的程度。
post 預設值true,用來處理IVTC遺漏的細節,使畫面略微模糊。
threshold 0~255,預設值15,控制post的程度。
dthreshold 0~255,預設值9,控制threshold判定IVTC遺漏的程度。
blend 預設值true,在交錯畫面用渲染來替代填充。
chroma 預設值false,在交錯畫面的亮度色度調整。
cycle 2~25,預設值5,每n幀刪除1幀,NTSC選5,PAL選25。
mode 0~2,預設值2。
mode=0 對cycle裡最相近的幀不進行處理。
mode=1 對cycle裡最相近的幀進行處理,用於處理混合幀速。
mode=2 在一個很長的範圍裡進行幀對比,可以正確處理動畫裡由8幀或12幀複製為29.97幀的情況。
Threshold 預設值0,控制mode=1時的處理重複幀的程度,Threshold預設值100,控制mode=2時的處理重複幀的程度。
Quality 0∼3,預設值2,采樣和色度的品質,與速度成反比。

但是最近的幾個版本似乎都存在一個問題,就是處理後的畫面有波動現象,並伴隨影片裡文字閃爍現象,所以還是用老版本的保險。

例:LoadPlugin("Decomb.dll")
Telecide(Guide=1,Gthresh=50,Chroma=True,Quality=3,Post=false)
Decimate(cycle=5) # NTSC 3:2 PullDown

LoadPlugin("Decomb.dll")
Telecide(Guide=1,Gthresh=50,Chroma=True,Quality=3,Post=false)
Decimate(Cycle=5,Mode=2) # NTSC Progressive和Interlaced混合

LoadPlugin("Decomb.dll")
Telecide(Guide=2,Gthresh=50,Chroma=True,Quality=3,Post=false)
Decimate(Cycle=25) # PAL







4、字幕濾鏡

1 VobSub
Sub字幕:VobSub不但是外掛字幕的好手,內嵌字幕也是一樣的強。
將字幕的2個檔案test.idx和test.sub放在同一個目錄下就可以了。
例:LoadPlugin("VobSub.dll")
VobSub(「test」)
2 TextSub
SSA和ASS字幕:這個也是VobSub自帶的,可以內嵌特效字幕。
例:LoadPlugin("TextSub.vdf")
TextSub(「test.ssa」)



好了,它們都還有很多命令和參數我沒有寫出來,只挑了這幾個最最最基本常用的



avisynth.還有很多非線性編輯的插件,我最常用的
去噪convolution3d,mssoft
銳化mssharpen,asharpen
[url]www.avisynth.org還有更多的。非崙/url]`全。




for cartoon encoding
IVTC:IT/auto24fps/decomb
resize:lanzcos3/simpleresize
NR:C3D/deen("a3d")/_2dcleaner/fluxsmooth/KenKunNRT/KenKunNR
EE:warpsharp/asharp
& coloryuy2/tweak/level for adjusting color

我用的
Unfilter 柔化/銳化
UnDot 去點
還有Mpeg2Dec的LumaFilter


LumaFilter(-2)
Unfilter (3,3)
UnDot()

註冊日期: Jul 2002
來自: 湖南長沙
發帖數量: 231
1 2003-05-25 01:45:42 【討論】用AviSynth2.5.x做內嵌時出現「藍臉」問題原因

--------------------------------------------------------------------------------

小弟在做字幕內嵌時,用VDMOD開啟一些avs檔案(AviSynth2.5,AVI源檔案為DivX5.0.2,自己用的Decodec為DivX5.0.3),預覽時人物皮膚會有不正常的顏色,皮膚都是藍色的,內嵌後顏色也還是一樣不對,似乎是缺少了red channel一樣,後來發現在avs檔案中加上SwapUV()就可以解決。該avs用WMP或者MPC播放正常。某些MJPEG的似乎也有類似問題。

問題是解決了,可原因出在哪?在Doom9上看到有人說這是DivX5的一個Bug,可能錯誤交換了色彩通道,用DivX5.0.5就沒有這個問題了。可我想說的是,在同樣的情況下,我用AviSynth2.0.x時沒有出現過這種問題,這是怎麼回事?難道是YUY2與YV12格式在處理AVISource過程中,DivX5的這個Bug只影響到了YV12?可以這樣解釋嗎?沒錯

另外附上avs腳本
SetMemoryMax(256)
global VirtualDub_plugin_directory = "F:\soft\video\AVIedit\VirtualDub\PlugIns"
AVISource("H:\GB28.avi")
LoadPlugin("F:\soft\video\AVIedit\VirtualDub\PlugIns\VSFilter.dll")
LoadPlugin("F:\soft\video\Avitools\AVIsynth\Filter\CNR2.dll")
LoadPlugin("F:\soft\video\Avitools\AVIsynth\Filter\Deen.dll")
LoadPlugin("F:\soft\video\Avitools\AVIsynth\Filter\Undot.dll")
textSub("H:\GB28.ass")
CNR2()
deen("m2d",1,10,12)
Undot()

PSNR - Peak Signal-to-Noise Ratio
一般的
LoadPlugin("MPEG2Dec3.dll")
LoadPlugin("Decomb.dll")
orig=mpeg2source("yoursource.d2v").Telecide().Decimate(cycle=5).crop(8,0,-8,-0).LanczosResize(640,480).ConvertToYUY2()
encoded=avisource("yourencoded.avi").ConvertToYUY2()
compare(encoded, orig, "Y", "PSNR.LOG")
(一軟體名為PSNR4Avi也可以做類似的工作,)


SNR 比較的時候,是比較「和原始影片的差距」,所以您用來比較的 orig,
必須和壓縮時的原始影片相同才行,如果您壓縮時原始影片是
MPEG2source("sample.d2v")
crop(8,54,704,368)
LanczosResize(640,368)

比較時的 orig 就必須是
orig=MPEG2source("sample.d2v").crop(8,54,704,368).LanczosResize(640,368)

至於為什麼 MPEG2Dec3 輸出需轉為 YUY2,那是因為目前 compare function 的問題,
您可以先轉為 YUY2 再轉回 YV12,不會有誤差,或者是直接在 YUY2 色空間比較。

比較時建議以 Y-PSNR 為主。

我自己計算 PSNR,因為我壓的片子都需要經過 TMPGEnc 的 IVTC 處理,
所以最後都是轉為 VFAPI,為了不同 Codec 比較時有相同基準點,
再用 Avisynth 載入執行這個 VFAPI AVI,統一由 Avisynth 轉成 YV12 的原始影片
avisource("GateKeepers21_OP_aup_vfapi.avi").ConvertToYV12()

比較的時候
orig=avisource("GateKeepers21_OP_aup_vfapi.avi").ConvertToYV12()
encoded=avisource("GateKeepers21_OP_XviD.avi", false, "YV12")
compare(encoded, orig, "Y", "PSNR-XviD.LOG")

比較含有 B-frame 的 AVI,XviD 的 vfw Codec 開頭會固定有一張延遲的 delayed frame,
要將它刪除,刪除以後就可以對齊比較了
encoded1=avisource("XviD.avi", false, "YV12").Trim(1,0)

刪除以後,XviD 的末尾會少一張 Frame,所以若是要和其它 Codec 比較,例如 DivX 5.05,
DivX 5.05 就必須要刪除最後一張 Frame,這樣比較才會公平。
假設總共是 2001 張 Frame,0~2000
encoded2=avisource("DivX.avi", false, "YV12").Trim(0,1999)

PSNR4AVI 算出來的結果,我以前用,有一些怪怪的,可能是 RGB 轉 YUV 的問題。
有 B-frame 的 AVI 一定要用 Avisynth 算,結果才會正確
psac 目前離線  
送花文章: 3, 收花文章: 1631 篇, 收花: 3205 次
 


主題工具
顯示模式

發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 06:10 PM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1