跳轉到內容

MeGUI/AviSynth 指令碼中的縱橫比訊號

來自華夏公益教科書,開放的書籍,開放的世界

MeGUI 支援在 AviSynth 指令碼中縱橫比 訊號,這將允許 MeGUI 讀取您在指令碼中設定的縱橫比,而無需您告訴 MeGUI。這類似於 MatroskaMP4 中的 AR 訊號;但是,由於 AviSynth 透過模擬 AVI 檔案(沒有對 AR 訊號的原生支援)來工作,因此需要一種解決方法。

在 MeGUI 中哪裡可以找到縱橫比設定

[編輯 | 編輯原始碼]

MeGUI 目前不允許您設定 SAR - 您必須設定 DAR。此設定可在主窗體中的影片預覽視窗中找到。

在 AviSynth 指令碼中設定 DAR

[編輯 | 編輯原始碼]

您可以使用兩個專門命名的全域性變數將 DAR 訊號直接新增到您的 Avisynth 指令碼中:MeGUI_darxMeGUI_dary。例如,您可能擁有

# Set DAR in encoder to 4 : 3. The following lines are for automatic signalling
global MeGUI_darx = 4
global MeGUI_dary = 3
# other stuff which actually is the script
...

MeGUI 將與 Avisynth 互動以獲取變數的值。因此,您甚至可以執行一些有趣的操作,例如

global MeGUI_darx = my_avs_func_x()
global MeGUI_dary = my_avs_func_y()
...

允許 AviSynth 進行一些 DAR 計算。

一些輔助函式

[編輯 | 編輯原始碼]

由於裁剪保留 SAR,而調整大小保留 DAR,因此能夠為您的任何計算使用最適合的選項非常有用。這些 AviSynth 函式在 SAR 和 DAR 之間轉換,並設定 DAR 以便 MeGUI 可以將其讀出。

# gets the DAR from the SAR
function getDAR(clip c, float SAR)
{
    return Float(c.width) * SAR / Float(c.height)
}

# gets the SAR from the DAR
function getSAR(clip c, float DAR)
{
    return DAR * Float(c.height) / Float(c.width)
}

# sets the DAR
function setDAR(float DAR)
{
    global MeGUI_darx = Round(1000 * DAR)
    global MeGUI_dary = 1000
}

在指令碼中使用這些函式的示例

# input the video
DGDecode_mpeg2source("input.d2v")

# set the DAR to the input's DAR
DAR = 1.3672 # suppose we know the input is ITU 4:3

# calculate the SAR, because that doesn't change when cropping
SAR = last.getSAR(DAR)
crop( 10, 0, -10, -2)

# calculate the DAR, because that shouldn't be changed when resizing
DAR = last.getDAR(SAR)
LanczosResize(300,300)

# signal the DAR to MeGUI
setDAR(DAR)

# ensure that we are actually returning a video
return last
華夏公益教科書