LIPS Corner 新天藍 » 數碼影音 - Digital A/V » 認識 Avisynth (updated 5/13 Post 11)


2007-3-1 10:04 AM agelessoldman
認識 Avisynth (updated 5/13 Post 11)

AVISynth 基礎及初步運用功能

筆者還是在學習階段﹐只不過覺得 avisynth 這個軟件功能非常強大﹐效果很好﹐所以借這裡跟大家討論研究和分享心得。熟於運用 avisynth 程式的朋友們也請多多賜教分享一下。

首先是我要跟那些對 avisynth 不認識的朋友簡單講一下這個 avisynth 的用途﹕

Avisynth 是一個影音檔的 frameserver (以下所有應用名詞我都會儘用英文﹐以免翻譯錯誤有所混肴)。
Frameserver 是一個『仲介』﹐作用是將一個影音檔以極快的速度一幁一幁( video frames )解碼至易於讀取的數位影像﹐同時亦可添加有需要的 filters (濾鏡),作出 editing (編輯)﹐送到轉檔軟件裡。這樣可以解決許多轉檔程式不能讀取多種編碼的困難和減少轉檔程式運作時的負擔﹐從而減低轉檔時間。而 avisynth 這個 frameserver 更是功能多多。在世界各地每天都有網友自己寫出一些新的 filter plugins﹐使它功能更加擴大。

Avisynth 這個『軟件』是沒有界面(GUI)的。用的時候就打開 notepad, 填上應用的 syntax 後存檔為 .avs  就成為一個『script』。我會對那些從沒接觸過 avisynth 的朋友﹐一步一步講解最基礎的步驟和應用。

深入運用 avisynth 的高級功能是有一定程度的難度﹐是沒有速成的方法。不過可以透過大家的研究來分享心得﹐就能舉一反三的明白地運用。英文程度比較好的朋友可以自己到網上搜集各種不同的 scripts, 應用後亦希望可以在這裡和大家分享心得。

Avisynth 下載﹕
[url]http://www.free-codecs.com/download/AviSynth.htm[/url]

官方網頁: ( 這裡附有多種 filter plugins )
[url]http://avisynth.org/[/url]

安裝 avisynth﹕
[IMG]http://i3.tinypic.com/33vozzn.jpg[/IMG]


基本用法:
(1)
[IMG]http://i2.tinypic.com/2hnz0o1.jpg[/IMG]

打開 notepad, 依照圖樣將需要轉的檔案途徑填寫好. 注意從途徑到檔案名稱都只能用英文及數字。

(2)
[IMG]http://i18.tinypic.com/2cfccie.jpg[/IMG]

[IMG]http://i10.tinypic.com/344v0h5.jpg[/IMG]

將填寫好的文件另存 (Save As) (All Files), xxx.avs。注意 extension 是 .avs 。

(3)
[IMG]http://i4.tinypic.com/2eat5bb.jpg[/IMG]

[IMG]http://i11.tinypic.com/44rhc9j.jpg[/IMG]

在這個 avs 文件用滑鼠右按﹐選擇由 Media Player Classic 打開測試能否成功播放影片。

如遇到不能打開影片的問題時﹐請將 error message 錄下和問題一起貼上來。

因為 directshow 解碼不是很 framerate accurate, 所以建議一定要填上影片的 framerate : fps=25, 為了更確定輸出率而加寫 : convertfps=true﹐ 這樣可以防免影音不同步問題發生。

要注意片源的來處﹐確定是 ﹕香港﹐大陸﹐新加坡﹐歐洲﹐等地製作的﹐ framerate 是 25﹐ 其它如 ﹕日本﹐韓國﹐台灣﹐美國﹐的地方製作是 29.97。( 容後再討論這個題目)

2007-3-1 10:04 AM agelessoldman
[b]我 會 不 時  在 這 帖 內 添 加  一 些 簡 化 了 的 基 本 有 用 指 令 用 法 。所 示 範 的 指 令 主 要 是 針 對 rmvb 格 式 轉 mpeg 的 用 法 。 所 以 有 些 地 方 解 釋 會 有 所 不 全 。 還 是 那 句 ﹐ 如 有 什 麼 地 方 需 要 改 良 的 ﹐ 請 不 吝 賜 教 ﹗ [/b]

***************************************************************************************************

[size=5][b][size=4]3/1 [color=Red]Resizing[/color][/size][/b][/size]

為 什 麼 要 做 resize?  主 要 是 因 為 電 腦 所 用 的 pixel  是 正 方 形 的 ﹐要 調 改 到 電 視 所 接 納 的 解 像 規 格 才 可 以 在 電 視 上 播 放 。雖 然 很 多 轉 檔 程 式 都 有 本 身 的 畫 面 調 整 功 能 ﹐但 是 很 多 效 果 都 不 好 而 且 不 準 確 。 Resize  功 能 好 不 好 是 直 接 影 響 壓 出 來 影 片 的 效 果 。

還 有 更 重 要 的 是 添 加 黑 邊 ﹐ 原 因 是 電 腦 所 顯 示 的 畫 面 是 完 完 整 整 的 ﹐如 果 不 把 畫 面 稍 為 改 小 再 加 黑 邊 ﹐會 有 看 不 到 字 幕 情 形 發 生 。 電 視 機 製 造 商 都 會 在 電 視 機 屏 幕 加 上 over scan,  把 四 邊 都 有 不 同 程 度 地 掩 蓋  掉 ﹐而 你 所 看 到 的 叫 safe area.  目 的 是 防 止 analog  電 視 臺 廣 播 時 所 連 帶 的 噪 音 (noisy signals) 顯 露 在 家 用 的 電 視 機 上 。

[IMG]http://i13.tinypic.com/2a4ofoh.jpg[/IMG]

在 上 圖 中 (1) 的 LanczosResize 是 幾 種 調 整 畫 面 尺 寸 之 中 是 目 前 效 果 比 較 最 好 的  filter 。 括 內 的 第 一 個 數 目 是 代 表 影 片 的 橫 值 解 像 度 (horizontal resolution), 第 二 個 數 目 是 代 表 直 值 解 像 度 (verticle resolution)。

圖 (2) 是 在 調 整 後 的 畫 面 加 上 黑 邊 。括 內 順 序 數 目 是 代 表 ﹕  
左 邊 ﹐ 上 邊 ﹐ 右 邊 ﹐ 下 邊 。

把 橫 值 的 672  加 上 左 24 ﹐右 24  的 總 和 是 = 720
把 直 值 的 544  加 上 上 16﹐ 下 16  的 總 和 是 = 576
這 是 PAL 電 視 制 的 符 合 標 準 full D1 解 像 度 。
NTSC 制﹕ LanczosResize(672,448), AddBorders(24,16,24,16).

*這 裡 所 示 範 的 都 是 默 認 片 源 的 屏 幕 比 例 (aspect ratio) 是 4 比3 (4:3).

注 意 1﹕ 確 定 影 片 是 PAL (25fps) 用 720X576﹐ NTSC (29.97) 的 用 720X480。
注 意 2﹕ 用 full D1 (720x576) 解 像 度 在 轉 檔 時 用 的 時 間 比 half D1 (352x576) 或 quarter D1 (352x288) 長 一 倍 。
而 且 很 多 朋 友 在 壓 制 rmvb 檔 時 都 捨 不 得 用 高 一 點 的  bitrate,  把 影 片 很 多 細 節 (detail)  都 壓 失﹐這 時 再 將 影 片 畫 面 放 得 太 大﹐ 不 單 祇 不 會 顯 得 更 清 晰 ﹐ 反 而 會 顯 露 出 像 macroblocks 的 artifacts. 這 種 低 bitrate 的 檔 在 電 腦 上 看 是 很 不 錯 的 ﹐ 因 為 電 腦 用 的 video card (硬 件) 在 幫 助 解 像 ﹐用 軟 件 程 式 轉 檔  是 根 本 不 可 以 比 。   

下 面 有 幾 個 用 細 一 點 的 解 像 指 令 例 子 ﹕

[IMG]http://i17.tinypic.com/2cfa1ki.jpg[/IMG]

圖 A  和 B  的 解 像 度 均 是 352*288﹐圖 A  的 實 際 解 像 面 積 336*264 是 比 圖 B  的 336*272  小 一 點 ﹐比 較 適 合 家 裡 用 multi system NTSC 電 視 制。 NTSC  制 電 視 屏 幕 比 PAL  制 是 細 一 點 。   

圖 C  是 PAL 的 half D1  尺 寸﹐ 336*544 也 可 以 調 整 到 336*536﹐ 相 對 下 ﹐ 在 AddBorders  的 指 令 也 要 修 改 至 (8﹐ 20﹐ 8﹐ 20)。
NTSC half D1 = LanczosResize(336,448), AddBorders(8,16,8,16)

圖 D  是 NTSC  quarter D1 (352*240) 的 resize 指 令 。

如 有 需 要 另 行 調 過 任 何 尺 寸 時 ﹐ 儘 量 用 mod16  或 以 上 。 最 少 也 儘 量 不 低 于 mod4.  Mod* 的 意 思 是 值 數 除 得 盡 的 ﹐譬 如 352÷16=22﹐  是 沒 有 餘 數 。 16 就 是 mod16.  [336÷16=21﹐544÷16=34﹐ 等 等 ]
所 有 指 令 都 可 以 寫 大 小 楷 英 文 ﹐ 沒 分 別 。

關 於 half D1  的 解 釋 ﹐ 雖 然 轉 完 片 後 在 電 腦 看 或 許 看 到 影 片 拉 長 了 ﹐ 但 因 為 在 轉 檔 時 轉 檔 程 式 會 在 mpeg  上 加 了 一 個 4:3  的 指 令﹐ 播 映 機 會 自 動 將 影 片 還 原 的 。

****************************************************************************************************

[b][size=5]3/2 下面的兩個 syntax 我想有很多人會感興趣﹕[/size][/b]

[b][size=4][color=Red]Crop[/color][/size][/b]


[quote]
DirectShowSource("D:\Test.rmvb")
Crop(0,32,0,0)
AddBorders(0,16,0,16) [/quote]

這個 (Crop ) 指令是將畫面頂上一直滾動的廢話給砍掉。位置是 Crop(左﹐上﹐右﹐下)。

切多少視乎個別的需要. 跟著在 AddBorders 指令裡加回去﹐每邊上下 平 均 加 回 所 減 去 的 pixels,

當要切的 pixels 需要加或減的時候﹐注意要保持 mod16 的倍數。 如果不能時候﹐可以在指令尾加一句 align=true.
就是 ﹕Crop(0,28,0,0,align=true). 這個 28 就是你想要砍掉的 pixels 數目。

注意﹕這個 crop 的指令是用于裁剪四邊週圍畫面﹐當需要裁剪右和下邊時﹐一定要用負數。
Example: Crop(0,0,0,-32), 這個是把畫面底剪去 32 pixels, 已用負數。只有 0 (不作任何剪裁) 時可以不用寫正負符號。
如果不加負數符號﹐這個指令會變了另一個功能。這個暫時不作討論。

=edited 3/2=
編輯原因﹕之前的例子對初用者比較複雜﹐已簡化指令。並添加注意事項。

[quote]
DirectShowSource("D\Test.rmvb")
GetLeftChannel() [/quote]

這個指令是只用左邊的音軌。 對付只要雙語檔其中的一條語音﹐非常簡便。
同樣如果寫這樣﹕GetRightChannel(), 就代表拿右邊的音軌。

***************************************************************************************************


[size=5][b]3/3 以下兩個指令不常用﹐但需要起用來亦非常方便﹕[/b][/size]


[color=Red][size=4][b]Trim[/b][/size][/color]

[quote]
DirectShowSource("D:\Test.rmvb")
Trim(0,250) [/quote]

Trim 顧名思義是修輯或修剪的意思。 當有需要在影片中 cut 某一段片段時﹐可以用這個指令。
只不過 Avisynth 沒有預覽功能﹐只有在影片頭﹐尾﹐大概的修剪。如果要從影片當中剪取的話﹐要另外用 Virtualdub 這個軟體來幫助計算。

這裡只討論簡單的影片頭尾編輯功能。 括內第一個數字是代表影片的第一幀 ( first frame ) =0﹐最後一幀 ( last frame ) 是第 249 幀。 假設影片是 PAL 25fps 的話﹐也即是每 25 幀就是一秒﹐250 幀就是 10 秒。NTSC 是用每一秒 30 幀來算。

在影片中第 50000 幀到影片完的指令是 ﹕Trim(50000,-0). 注意是修剪時候需要下剪的前一幀﹐和最後一幀的後一幀作算。 假若想在影片尾加上 fade out (逐漸退淡)﹐在指令後加上如下﹕
[quote]
DirectShowSource("D:\Test.rmvb")
Trim(50000,-0). Fadeout(25) [/quote]
這樣就會在最後一秒時開始淡出和在影片尾加上一個全黑的 frame.

[color=Red][size=4][b]Subtitle[/b][/size][/color]

這個 Subtitle 跟平常所用的 Vobsub,textsub 等不同。 這是個很簡單的一個內設 filter﹐作用只可以用一句單行句子﹐ overlay 在畫面上。曾經有一位網友問可不可以在影片開頭加上一句 - 第幾集 - 的簡單辦法。 這個指令就可以實現。

[quote]
DirectShowSource("D:\Test.rmvb")
Subtitle("Episode 1", align=5) [/quote]

"Episode 1" ﹕  可以改成你想的句子。
align=5 : 是字幕的位置。

Avisynth 在這個指令字體﹐大小﹐顏色默認 (default) 是﹕
字體= Arial
字形大小= 18
顏色=黃字捆黑邊

字體和字形都可以改﹐就改顏色比較複雜﹐因為是用 HEX 來計算﹐這裡不討論。
改字體﹕只要在 “Episode 1" 後﹐隨便那裡位置加上﹕font="Times New Roman" 或任何 True Type Fonts. 要注意是不能用中文字。
改大小﹕size=36 或任何數目。

當然﹐你可能祇想這句字顯露一個短暫時間﹐那指令就有加上﹕first_frame=1, last_frame=125
這個是用 PAL 25 fps 來計算﹐125 = 5 秒。

至於字幕的位置是依照電腦或普通計算機的數字鍵盤來排﹕
7   8   9
4   5   6
1   2   3

不過除了 5 ( 正中 ) 之外﹐其它的位置都太過貼近畫面的邊緣﹐會可能被電視機的 over scan 蓋掉。
下面是一個比較完整的指令﹕

[quote]
DirectShowSource("D:\Test.rmvb")
Subtitle("Episode 1", first_frame=1, last_frame=125, font="Tahoma", size=36, align=5) [/quote]

***************************************************************************************************


[b][size=5]3/13  幾個簡單內建調校光暗、顏色和銳化的濾鏡[/size][/b]


[b][size=4]Color Brightness[/size][/b]

[b][size=4][color=Red]Levels[/color][/size][/b]

這個本來是在RGB顏色空間運作的濾鏡﹐在影音檔常用的YUV顏色空間裡﹐祇能利用它的亮度 (Luma) 功能。

[quote]
DirectShowSource(“D:\Test.rmvb”)
Levels(0, 1, 255, 16, 235, coring=false) [/quote]

這是將片源的顏色 scale 從電腦屏幕用的 0~255 轉成為電視用的 16~235。
跟 ColorYUV(levels="PC->TV") 的指令相同。在 16 的數字可以試調改成 8﹐讓顏色較為深一點。


[b][size=4][color=Red]Tweak[/color][/size][/b]

[quote]
DirectShowSource(“D:\Test.rmvb”)
Tweak(0,1,0,1)[/quote]


括號內數字代表﹕

第一個數字 = hue﹐默認是 0.0 ﹐調校從 -180 至 +180, 負數是趨向綠色﹐加數是趨向紅色。

第二個數字 = saturation ﹐ 默認是 1.0 ﹐調校空間是     0.0 至 10.0                  
                        
第三個數字 = bright , 默認是 0.0 , 調校空間是 -255.0  至 255.0

第四個數字 = contrast , 默認是 1.0 ﹐調校空間是 0.0  至 10.0

*所說的默認都是片源原來的度數﹐沒作任何改動。這個指令默認顏色 scale 是 16~235 (TV Scale)。如果覺得太亮﹐祇想稍微調整的話﹐可以在最後數字後面加上一句﹕coring=false。

[quote]
DirectShowSource(“D:\Test.rmvb”)
Tweak(0,1,1,1,coring=false)[/quote]

這個指令祇是將 bright 和 contrast 加強,不容許濾鏡自動調至 TV Scale (16,235)。不過如果片源本身已經是 TV Scale 的話﹐這個 coring=false 就變成無用。當有需要的時候﹐也可以加上﹕ColorYUV(Levels=“TV->PC”)

要注意的是每當調整 bright 的時候﹐也需要適當地調整 contrast.


[b][size=5]Sharpening[/size][/b]

[b][size=4][color=Red]Sharpen[/color][/size][/b]

這個簡單的銳化濾鏡功能很強﹐它跟 Virtual dub 和 ffdshow 裡的 unsharp mask plugin 功能相若﹐但運用時比起來更簡單直接。它的調校空間祇有 10 度﹐從 0.0 到 1.0。要小心運用﹐0.5 以上可能會出現反效果﹐令到效果更差。

[quote]
DirectShowSource(“D:\Test.rmvb”)
Sharpen(0.3)[/quote]

2007-3-1 11:35 AM mickeyGoUp
唔該晒 ageless!   期待您第二個帖既內容!!  :)

係唔係安裝左 AVISynth 後﹐就連 Windows Media Player 都可以打開 .avs 檔呢?  還是只有 Media Player Classic 識得解讀 .avs 內既 scripts?  換句話講﹐係唔係好似裝左 d codecs 咁﹐d player 會自動連上呢?  

可能我安裝後就會明白﹐而家有少少斷估。 :P

2007-3-3 06:32 AM mickeyGoUp
終於今日有機會試左喇!!!  :)

非常易用!  用左就明白個原理!  其實即係用個 player 開 .avs 檔時﹐個 player 就識得開 AVISynth﹐跟住讀 scripts 內每行指令﹐續一解讀運行!

我試左您所講既幾個指令 (Crop, AddBorders)﹐AddBorders 響電腦要加到好粗先睇到個效果。

我諗下一步就係要識得去搵人地既 scripts﹐一邊用一邊睇一邊研究一邊學。  當掌握到勒﹐就去睇下 d Documentations (user manual 之類)。  當安裝 AVISynth 時﹐已經跟埋個 AVISynth Documentation 既 HTML 檔﹐裡面有逐一講每個 functions 或者 filter 係做咩既﹐雖然唔算好詳盡﹐但都好整齊!  :)  正喎!

2007-3-3 11:55 PM mickeyGoUp
咁您有冇邊個 site 係有好多人 post d 唔同效果效用既 scripts 上去架呢?  雖然我未必有時間即刻去睇﹐但您貼定出黎﹐我或者其他有興趣既會員可以隨時去望下喎。 :)  唔該您!!

2007-3-4 07:30 AM agelessoldman
[quote]原帖由 [i]mickeyGoUp[/i] 於 2007-3-3 11:55 PM 發表
咁您有冇邊個 site 係有好多人 post d 唔同效果效用既 scripts 上去架呢?  雖然我未必有時間即刻去睇﹐但您貼定出黎﹐我或者其他有興趣既會員可以隨時去望下喎。 :)  唔該您!! [/quote]

首先答你問題﹕咁您有冇邊個 site 係有好多人 post d 唔同效果效用既 scripts 上去架呢?

有幾個外國論壇都會有一條專門 thread 來討論 avisynth﹐大部份都是在問有疑難的問題。當有會員知道解決辦法後會作出回應。跟這裡一樣。不過上這類論壇的人﹐對 avisynth 和其它的基本影像知識都達到某程度。他們所提及的可能我們有些會員不太明白。 Doom9.org 差不多是全 avisynth 宇宙的集中地。

所有應用的 syntax 都可以在 avisynth 附帶的 User manual 裡找到。怎樣運用才是關鍵。

至於像我現在這樣像教學方式的要 google 到很多私人網頁﹐或許會找到一些。加上我現在所講的只是皮毛﹐我正在循循善誘那些在看這篇帖的會員 :D﹐希望他們有興趣學而達到我的目的 (我目的是想多些人壓多些質素好的影片﹐益我 :D )。 所以我會在適當時在示範某例子時﹐會連上別人有用的 syntax 例子。

深入進階程度時要對顏色空間 ( color space )有某程度的理解。因為到時候是須要用到插件 ( third party plugins ),而每一種插件所支援的顏色空間都可能有不同﹐本身的片源是屬那一類也要認識。這些也是冰山一角而已。

不要被我嚇倒了﹐當你迷上了這個東西﹐就會覺得也不是很難嘛。
這裡有一篇關於 colorspace 的﹐我覺得寫得很簡潔﹐容易明﹕
[url]http://www.animemusicvideos.org/guides/avtech/colorspace.html[/url]

2007-3-6 01:54 AM kinh
agelessoldman, I also follow you instruction to install avisynth software version 2.5.7, then write my first scripts( just one line "DirectShowSource("c:\Download\Naruto.rmvb", fps=25, convertfps=true)". I try to open with window media clasisic. It did play the rmvb file instead of  a message (unexpected character " "). I try different file and different fps value, even take out fps. It still report that message. What did I do wrong or what I am missing??

2007-3-6 03:01 AM agelessoldman
Unexpected character follow by a description is telling you where the script went wrong.
In your case, the text in side the " " might need to be retype due to whatever reasons, like unwarranted spacing, or you had just copied the title from the file and pasted onto the command, the original file name mightbe written in unicode which Avisynth does not support.

try this for solution:
Rename the original file. Using only Alphabets and/or numbers. Then write another script.
Please let me know how it turns out.

If still no go, try copy and paste my script. Providing the name of the file is still the same.

[quote]
DirectShowSource("C:\Download\Naruto.rmvb", fps=25, convertfps=true)[/quote]

Ah, I see your problem, you put the " " on the whole line. This is your script, is it?
[quote]
"DirectShowSource("C:\Download\Naruto.rmvb", fps=25, convertfps=true)" [/quote]
This is wrong.

By the way, the file you have, Naruto.rmvb, are you sure it is not NTSC? ( NTSC=29.97 fps )

2007-3-6 06:29 AM kinh
I understand it could be an unexpected character ""(a space) in the script that the software doesnot want it; but where??
First I try the solution you mention (rename the file to 151.rmvb) doesnot work. I changed the fps to 29.97; did not work.
I cut and paste the file into the run command (start--run) and it comes up fine (start play with media window classis); I just want to prove no typing error on the path and the file works. Then I try to give a wrong directory path to see if it comes out different error. BooM!! same error. It seems to me that the software fails before it gets to the directory or the file.
I try to find out if there is any frequency ask question area on the official web site, I have not find a way to ask (contact or submit) my problem to the company. If you know a way, please let me know.

regards to your questions.
First, The line in my scripts is not quoted. I quote it on my message is just to seperate it out from my message.
Second, I am not sure the original name is unicode or not. I download this anime file through Xenterum >> Anime Xenter... and the filename is already set.
Third. Since this is an Anime file, I beleive it is original comes from Japan (fps=29.97), then it added with subtitles.
Fourth, I use the latest version of Avisynth 2.5.7

2007-3-6 07:24 AM agelessoldman
I'm thinking it all comes down to your messed up system. Something is wrong with your system, I don't think even a good registry cleaner could solve your dilemma.

I had suggested a reinstall of your window system over at the other thread. I'm pretty sure if you do it, the problems will be solved.

Go Google and type : winxp torrent. (do it at your own risk)

On second thought, it could very well be some sorts of Trojans/spywares, your system  maybe infested.

2007-3-23 03:58 PM agelessoldman
[b][size=5]3/23 [/size][/b]

[b][size=4]當需要用到各種美化影片濾鏡時候﹐而覺得 Avisynth 的內設濾鏡不夠完全﹐這時可以用第三者插件來加強功能。 [/size][/b]

這個網頁收集不少濾鏡插件﹐請在這裡下載需要的 filters :
[url]http://avisynth.org/warpenterprises/[/url]

下載插件後﹐先解壓然後把所有解壓出來的檔案放在 Avisynth 的 plugins 文件夾內。這個文件夾的途徑應該是﹕C:\Program Files\Avisynth 2.5\Plugins .(如果解壓出來是一個文件夾﹐將裡面所有的檔案都移到 Avisynth plugins 夾內)。

在用外建插件時﹐都要加一句 'LoadPlugins("C:\Program Files\Avisynth\Plugins\xxxx.dll")' 指令﹐很繁瑣。可以利用下面這個 Registry Editor 將所有存在 plugins 文件夾內的濾鏡自動‘叫' (call)上來。

[quote]
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Avisynth]
"plugindir2_5"="c:\\program files\\avisynth 2.5\\plugins" [/quote]

將上面文字複製到 notepad 裡﹐另存為 AutoLoadAVS.reg。雙按這個 reg 檔再按 ok 就行。這樣在 script 裡只需要寫出濾鏡名稱和指令就可以。

[b][size=4][color=Red]Leak Kernel Deinterlace  拉絲插件[/color][/size][/b]

這是個很普遍但效果很不錯的一個高級『拉絲』濾鏡。使用比好幾個同類的插件簡單。有時候因為某種原因在某些畫面出現 interlace 的鏡頭時﹐這個濾鏡大致上都可以幫助解決。

這個是我很多時都用的 syntax:

[quote]
DirectShowSource("D:\Test.rmvb")
LeakKernelDeint(Order=0,threshold=10,Sharp=true,twoway=true)[/quote]


Order : (0) 是 top field first 或 odd field, (1) 是 bottom field     
             first,或 even field. 這個很重要﹐如果搞錯會使到壓出來的影片
             不停的跳動。

Threshold : 濾鏡默認是 10, 調校範圍是 0 至 255。
                   假使 interlace 太厲害時﹐可以試試調高一點。

Sharp=true : 濾鏡默認是 false。目的是因為 deinterlace 在有些時候是
                      會將上下 field 融合一起 (blend),會使到畫面有一些模糊﹐
                      所以稍為加強銳化。

Twoway=true : 濾鏡默認是 false。這個可以不用﹐我用這個原因是要影片比較流暢一點﹐
                          不過代價是沒那麼清晰和轉檔稍微慢一點。
                          其實假若片源不是太糟的話﹐是不需要用的。

詳細的 parameters 請在 Avisynth Manual 裡找。

****************************************************************************************************


[b][size=5]3/31[/size][/b]

[b][size=4][color=Red]Decomb   高級拉絲插件[/color][/size][/b]

Decomb 是一個幾種不同拉絲濾鏡的 package (包裹)。包括有 Telecide, Decimate, Iscomb 和 FieldDeinterlace 。其中 field deinterlace 濾鏡是祇針對完全 interlace 的影片﹐非常適合 PAL 制的 TVcap 影片作拉絲程序。

[code]
DirectShowSource(“D:\test.rmvb”)
FieldDeinterlace() [/code]

這個例子是全用濾鏡本身默認的度數。參考以下 parameters (參量)來做需要的調整。

Full : 默認是 full=true, 意思是濾鏡程式會處理每一幁 (frame)畫面。
        full=false 就要濾鏡祇計算出所需要拉絲的畫面作出處理。

Threshold : 默認是 20﹐調整範圍是 0-255。當 full=true 時﹐
                  這個指令就會自動設定。用來設定偵測拉絲程度的上限。

Dthreshold : 默認是 7﹐調整範圍是 0-255。因為拉絲濾鏡是不需要把所有 frame 都作拉絲處理﹐
                    ( 在動作快速的畫面﹐interlace 的 frames 會效果更好 )
                    而這個指令是將已經作了拉絲的畫面作出處理的上限。
                    這是對付一些很頑固的 combing effects 作出調整。

Blend : 默認是 blend=true。把上下 fields 融合一起。

Chroma : 默認是 Chroma=false。這是把亮度和顏色作出分開 deinterlace 處理。


***************************************************************************************************


[b][size=5]4/1

去除 『Blocks』 的插件[/size][/b]

Blocks 就是影片偶爾在或多或少的時候出現的『格仔』。當轉 mpeg 時常見的 blocks 有兩種﹐一種是 macro block,另一種叫 DCT block。

Macro blocks 通常都是在壓縮 VCD (mpeg1) 時﹐因為畫面中有快速度的動作而壓縮程式分配 bitrate 時不很理想﹐另一個原因是調整 contrast 太過時也會顯現出來。
在壓縮 mpeg2 時會比較好一些﹐因為通常都會用高一點的 bitrate 來壓。

DCT blocks 通常是在原檔的 bitrate 不夠下﹐壓縮軟件讀不到原來的細節從而將部份畫面『磨』掉(smooth)所形成的效果﹐它不像 macro blocks 所呈現像『格仔』的 block﹐而會有一大片不同顏色的突然呈現出來。很多時都會在人面大特寫或一片背景牆壁﹐又或是一片天空、海洋畫面中上顯出。
這種 blocks 在 mpeg4 (avi, divx, xvid) 用過低 bitrate 來壓縮時也會產生。

所有去除 blocks 的濾鏡多多少少都會增加 bitrate 到部份需要的 pixels, 轉出來的影片會比較大一點。

[b][size=4][color=Red]Blockbuster  去除 DCT blocks 的濾鏡[/color][/size][/b]

這個濾鏡除了上述功能之外﹐有一個效果很不錯﹐就是當轉 TV rip 時而製作者 沒有做過任何畫面過濾﹐當畫面有煙霧的場面時﹐這個濾鏡就很管用。尤其是在比較黑暗的場面﹐譬如演唱會等。

[code]
Blockbuster (method="sharpen", block_size=4, strength=25)[/code]


Method = dither,noise,blurr,sharpen
我一直祇用(銳化) sharpen, 其他沒試過。可能用 blurr 在高 bitrate 的片源效果也許會不錯。

Block Size = 默認 8。最少 3。這個參數是代表濾鏡在每一幁片(frame)用多大的 block 來計算。每個參數都是高x寬 (H*W). 8x8 可能計算面積大了一點﹐不夠集中 ﹐做成在很多時候煙霧之外的 pixels 也算進去。我覺得效果比較不甚理想。
(這是本人自己的見解﹐不一定準確)。

Strength = 默認 25。這個是調整所用 method 的強弱﹐調整範圍是 1-100。

還有其他 parameters 我都不曾用﹐有興趣研究的朋友可以自己去看看這插件的說明。


**************************************************************************************************

[b][size=5]5/13[/size][/b]


[b][size=4][color=Red] DeBlock , TemporalCleaner[/color][/size][/b]

在眾多畫面『清潔』『清理』濾鏡之中﹐這兩個也是筆者比較多用。速度快而效果明顯。我不說“常用”而說多用是因為每一個濾鏡都會產生某程度的副作用﹐像 blurring,ringing,halo 之類等等。可以不需要時就儘量不用。最好是用於在壓縮高壓度之類的檔案(RMVB)之前。(DV-AVI/DVDRIP --> RMVB)

在清潔 RMVB 檔時要小心設定每個濾鏡不同的參數﹐將副作用減至最低。每個多媒體檔都有不同程度的需要﹐不能說固定用一個設定就可以全部都通用。

[b][size=4]DEBLOCK[/size][/b]

Deblock 是當畫面出現格仔 (macro blocks) 時候﹐它會將 block 裡的 pixels 模糊掉﹐讓畫面不那麼難看。缺點是設定過高會令不祇是起格的部份﹐而整個畫面都會被模糊掉。添加這個濾鏡後最好再加上銳化濾鏡在 script 的最後。Sharpen(填上).

默認是﹕ Deblock(25,0,0)或 Deblock()。第一個數字是濾鏡強度﹐調整範圍為0-60﹐第二個數字是代表濾鏡的上限﹐調得越高物體的邊線就越模糊。第三個數字是測查 blocks 和應用度數的參數。

下面這個 syntax 是從網上找到﹐可用作參考﹕

[code]Deblock(35,1,1)[/code]


[b][size=4]TemporalCleaner[/size][/b]

清理畫面嘈音的濾鏡有兩大類﹐Spatial 和 Temporal.
Spatial 主要是清潔個別 frame 的嘈音﹐而 Temporal 是以多個 frames 作計算出嘈音的程度﹐從而作出清潔。上面所提及的 Deblock 是屬於 Spatial 的一種。

這個 TemporalCleaner 主要的功能其實可以說是加強影像檔的壓縮度。這個濾鏡用後出來的效果很 subtle (輕微)﹐在觀看時會感覺得好像跟以前沒什麼大分別﹐但是檔的大小會相差 8~10%。這證明濾鏡是有產生效用。

當然﹐加強參數肯定會有顯著的不同﹐祇是副作用也會隨之增加。

下面這個 syntax 例子可以用於甚至正版 DVD 的片源。(所有格式的多媒體都會帶有不同程度的嘈音)

[code]TemporalCleaner(4,6)[/code]

濾鏡作者提議第一個參數不要超過 5﹐第二個參數可以去到 10 而不會令畫面出現反效果情形。

2007-3-28 03:37 PM bahamut0
In Doom9 site, it should have some of the editor for AviSynth scripting, the reason for that is if you use notepad for editing (which is the default editor for AviSynth). you would have some trouble for the script (e.g. typo on the script) until you run the script on a player, to encounter this, people have develop some AviSynth editor, one of them is AvsP, available at Doom9 site or below:

[url=http://avisynth.org/qwerpoi/Download.html][color=Brown][size=4]Download[/url][/color][/size]

it use color syntax for the script, and it has the preview window for previewing the script. so that you can correct it instantly. It might have trouble for matroska video since the decoder eats up resources pretty fast...

but for the new user this would be better then notepad.

I agree with the poster, once you get used to AviSynth, you can open virtually any video format file on your computer using a small size script file, provide that your video file is somewhere of your computer...you would be crazy on the filter once you get to use it.

The main reason for the AviSynth is frameserving, so that it can be frameserve to a video converter without losing quality for the video. the only thing that AviSynth might have trouble open with is the x.264 video. which must use mkv as a container to open it.

for the question above, try this script:

[code]
Version()
[/code]

this would tell you if your AviSynth install correctly or not, it shows you version of your AviSynth, which is 2.5.7

If that works, then try to rename your file to *.rm, and try to see if it plays on your media player, although I highly doubt it is that cause the trouble.

If possible, can you post a screenshot for the error message?

2007-3-28 11:06 PM agelessoldman
[quote]the only thing that AviSynth might have trouble open with is the x.264 video. which must use mkv as a container to open it[/quote]

Use ffdshow to decode x264, install haali splitter to decode mkv [url]http://haali.cs.msu.ru/mkv/[/url]
AVISynth will have no trouble opening either file types.

Reason I didn't suggest using any avs text editors yet, is because my intention was to introduce avisynth to beginners, one must know the fundamental basics of syntaxes,  scripts and the usages before jumping into more advanced features.

The official text editor for Avisynth is : AVSEdit [url]http://sourceforge.net/project/showfiles.php?group_id=57023&package_id=107927[/url]

Although there are few other text editors available, some includes preview ability, I wouldn't recommend using them as yet. Not until you're  more familiar with the functions of various filters.

I'm trying to simplify the learning curve for many that have difficulty with  English language here. If you feel comfortable and ready to adventure onto more advanced tools, by all means, do it. For seasoned avisynth users, I'm sure they already have been using their own favorite Avisynth text editor.

BTW, x264 does not have to be in mkv container.

頁: [1]


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.