Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AvisynthNeo-r2822におけるAutoVfrのログ出力について #2

Open
tokohito opened this issue May 22, 2019 · 5 comments
Open

AvisynthNeo-r2822におけるAutoVfrのログ出力について #2

tokohito opened this issue May 22, 2019 · 5 comments

Comments

@tokohito
Copy link

こんにちは、よろしくお願いします。

AviSynth CUDA Filters関係を使ってみたいと思い
Avisynth2.6.0(32bit) -> AvisynthNeo-r2822(32bit) に変更してみたのですが、
AutoVfrのログが正しく出力されない症状が発生しました。
(Avisynth2.6.0時点では正常に処理されていたスクリプトです)

スクリプト中でプラグイン読み込みエラーや書式エラーは発生していません。
またAvsPModNeoのプレビューなどでも特におかしな挙動はありませんでした。
何かお分かりになりますでしょうか?

AutoVFR_log_temp.avs: スクリプトファイル本体
AutoVFR_log_temp1.txt: AutoVfrの出力先ログファイル

AutoVFR_log_temp.avs


※LoadPlugin関係省略
function Auto_VFR(clip c,string file,int "cut",int "number"
,int "cthresh",int "mi", bool "chroma", int "blockx", int "blocky"
,bool "IsCrop",int "crop_height",bool "IsTop",bool "IsBottom",bool "show_crop"
,bool "IsDup",int "thr_m",float "thr_luma"){
h=c.height()
count=c.framecount()
dwc=c.DoubleWeave()
dcount=dwc.framecount()
Iscut=Defined(cut)?true:false
Isnumber=Defined(number)?true:false
Assert(Iscut==Isnumber,"specify 'cut' and 'number'")
start=Isnumber?int(dcount*float(float(number-1)/float(cut))):0
end=Isnumber?int((dcount *float(float(number)/float(cut))))-1:0
dwc=Iscut?dwc.Trim(start,end):dwc
HDsize=720
IsDup=default(IsDup,false)
cthresh_default=(IsDup==true)?7:(h>=HDsize)?9:7
mi_default=(IsDup==true)?50:(h>=HDsize)?80:50
blocks_default=(h>=HDsize)?16:32
cthresh=default(cthresh,cthresh_default)
mi=default(mi,mi_default)
chroma=default(chroma,false)
blockx=default(blockx,16)
blocky=default(blocky,blocks_default)
crop_height=default(crop_height,(h==HDsize)?280:120)
mod=(IsYV12(c)==true)?4:2
Assert((h-crop_height)%mod==0,"crop_height is invalid.")
IsCrop=default(IsCrop,false)
IsTop=default(IsTop,false)
IsBottom=default(IsBottom,true)
show_crop=Default(show_crop,false)
thr_m=default(thr_m,10)
thr_luma=default(thr_luma,0.010)
int_t=( IsCrop==true && IsTop==true)?crop_height:0
int_b=( IsCrop==true && IsBottom==true)?crop_height:0
ScriptClip(dwc,"""
prg="0"
cmb="1"
start="""+string(start)+"""
count="""+string(count)+"""
dcount="""+string(dcount)+"""
file=""""+file+""""
cth="""+string(cthresh)+"""
mi="""+string(mi)+"""
chrm="""+string(chroma)+"""
bx="""+string(blockx)+"""
by="""+string(blocky)+"""
int_t="""+string(int_t)+"""
int_b="""+string(int_b)+"""
show="""+string(show_crop)+"""
isDup="""+string(IsDup)+"""
thr_m="""+string(thr_m)+"""
thr_luma="""+string(thr_luma)+"""
crnt=current_frame+start
str_num=string(crnt)
str_line=string("-")
str_total=(start==0)?string("total_f-")+string(count):""
str_dtotal=string("doubleweave_f-")+string(dcount)
(current_frame==0)?WriteFile(last,file,"str_total",append=false):nop
(crnt==0)?WriteFile(last,file,"str_dtotal",append=true):nop
str_main=(IsCombedTIVTC(last,
\cthresh=cth,MI=mi,chroma=chrm,blockx=bx,blocky=by)==true)?cmb:prg
str_crop=(int_t>0 || int_b>0)?(IsCombedTIVTC(last.crop(0,int_t,0,-int_b),
\cthresh=cth,MI=mi,chroma=chrm,blockx=bx,blocky=by)==true)?cmb:prg
:str_main
str_motion=(isDup==true && crnt%2 == 0)?
(Interleave(SelectEven().mt_motion(thY2=thr_m),SelectOdd()).AverageLuma() >thr_luma)?cmb:prg
:prg
result=str_num+str_line+str_main+str_line+str_crop+str_line+str_motion
(show==false)?WriteFile(last,file,"string(result)",append=true,flush=false):last
""")
return (show_crop==true)?last.crop(0,int_t,0,-int_b):last
}

MPEG2VIDEO("C\src\clip.ts")
clip0.AssumeTFF()
Trim(598,951)
Auto_VFR("C:\temp\AutoVFR_log_temp1.txt", cut=1, number=1, cthresh=80, mi=60, blockx=16, blocky=32, chroma=false, IsCrop=true, crop_height=136, IsTop=false, IsBottom=true, show_crop=false)


AutoVFR_log_temp1.txt


I don't know what 'str_total' means.
I don't know what 'str_dtotal' means.
I don't know what 'str_total' means.
I don't know what 'str_dtotal' means.
I don't know what 'str_total' means.
I don't know what 'str_dtotal' means.
I don't know what 'result' means.
I don't know what 'result' means.
I don't know what 'result' means.
I don't know what 'result' means.
I don't know what 'result' means.
I don't know what 'result' means.
(以下繰り返し、略)


以上、よろしくお願いします。

@nekopanda
Copy link
Owner

Neoでは、ランタイムスクリプト系の挙動が変更されています。GRunTのlocal=true相当の挙動になっているので、local=false前提で書かれたスクリプトは動きません。

なぜこの変更をしたかと言うと、以下のスクリプトで3と表示される挙動が許せなかったからです。

function PrintFoo(clip c) {
    foo = 2
    c.ScriptClip("Subtitle(string(foo))")
}
Version()
PrintFoo()
foo = 3
last

AutoVfrについては、Neo用に書き換えたバージョンを使っていただくか、WriteFileのところを自分でfunction使って書き換えるかしてください。

@tokohito
Copy link
Author

早速回答いただきありがとうございます。
こちらのAvisynthNeo対応版AutoVfrは非公開ツールでしょうか?(ファイル名でググっても出てこなかったので)

頂いたAvisynthNeo対応版Auto_Vfr.avsを試してみたところ、一応正常にログが出力できました。
「一応」と書いた理由ですが、ログの出力先を絶対パスで表記した場合は問題ないものの、
私が普段使っている相対パスの書式でエラーになった為です。


avs2pipemod[error]: Write: File 'C:\work\tmp\tmp\AutoVFR_log_temp.txt' cannot be opened.
(.\tmp\AutoVFR_log_temp1.avs, line 190)
(.\tmp\AutoVFR_log_temp1.avs, line 195)
(.\tmp\AutoVFR_log_temp1.avs, line 220)


※line 190: WriteFileStart(file, "str_total", append=false)
※line 195: }
※line 220: Auto_VFR()

上記の例ですと、いつもは"C:\work"をカレントディレクトリにした状態で
以下のように相対パス書式で記述しています(本家Auto_Vfr.avsはこれでも出力できました)
上記のエラー文に含まれる"C:\work\tmp\tmp"というディレクトリは、実際には存在しません。


Auto_VFR(".\tmp\AutoVFR_log_temp1.txt", cut=1, number=1, cthresh=80, mi=60, blockx=16, blocky=32, chroma=false, IsCrop=true, crop_height=136, IsTop=false, IsBottom=true, show_crop=false)


お手数ですが、修正いただけますと助かります。
蛇足かもしれませんけれども、AvisynthNeo対応版AutoVfrの同梱バージョンが
ver0.1.1.0になっていますが、私の知りうる限り最新のAutoVfrはver0.1.1.1になります。
http://putin999.blog.fc2.com/blog-entry-31.html
(Auto_Vfr.avsファイルの方はver 0.1.0.6で変わりありません)

以上、よろしくお願いします。

@nekopanda
Copy link
Owner

nekopanda commented May 22, 2019

こちらのAvisynthNeo対応版AutoVfrは非公開ツールでしょうか?(ファイル名でググっても出てこなかったので)

ダウンロードできるページは作っていませんが、Amatsukazeからダウンロードできるようになっています。公開ツールと考えて問題ありません。

ログの出力先を絶対パスで表記した場合は問題ないものの、
私が普段使っている相対パスの書式でエラーになった

相対パスの起点が、ランタイムスクリプト内と通常とで異なるので、挙動が変わったものと思います。avisynthでは通常、avsファイルのある場所を相対パスの起点とします。ただし、ScriptClip等のランタイムスクリプト内では、プロセスのカレントディレクトリが相対パスの起点になります。仕様が一貫していないのは、多分、実装上の都合でしょう。

今回の場合、avsファイルは.\tmp\AutoVFR_log_temp1.avsなので、.\tmpが相対パスの起点となります。なので、相対パスを使う場合は、Auto_VFR(".\AutoVFR_log_temp1.txt" ...と書けばOKです。

AutoVfrの元のバージョンは、ScriptClipを使っているので、相対パスの起点がプロセスのカレントディレクトリとなり、Neo対応版と挙動が異なりますが、Neo対応版は元のAutoVfrと挙動が完全一致することを目指しているわけではないので、修正しないこととします。

AvisynthNeo対応版AutoVfrの同梱バージョンが
ver0.1.1.0になっていますが、私の知りうる限り最新のAutoVfrはver0.1.1.1になります。

そのリンク先からダウンロードできなくなっていたので、入手できませんでした。もし、ver0.1.1.1をお持ちでしたら、私がver0.1.1.1を同梱できるように、どこかに上げていただけると助かります。

@nekopanda
Copy link
Owner

元のAutoVfrと挙動が完全一致することを目指しているわけではない

ここについて少し補足。ScriptClipからWriteFileすると、フレームごとにファイルを開く操作が入るので遅くなります。Neo対応版では、ScriptClipを使っていません。1度ファイルを開くだけなので、速くなっています。1並列だと、あまり変わらないかもしれませんが、複数並列(4並列とか6並列)で実行すると結構変わるようです。

@tokohito
Copy link
Author

tokohito commented May 22, 2019

回答ありがとうございます。
AVSスクリプトとランタイムスクリプトの実装差異による挙動の
違いとの事で了解しました。相対位置を変更するか、絶対パスを得てから
渡すようにするなどして対処したいと思います。

ここについて少し補足。ScriptClipからWriteFileすると、フレームごとにファイルを開く操作が入るので遅くなります。Neo対応版では、ScriptClipを使っていません。1度ファイルを開くだけなので、速くなっています。1並列だと、あまり変わらないかもしれませんが、複数並列(4並列とか6並列)で実行すると結構変わるようです。

論理CPU数まで並列化しても遅いと感じていたので助かります。
余裕があれば比較してみたいと思います。

ver0.1.1.1についてはこちらで公開されています。
http://putin999.web.fc2.com/plugin.html
※手元で常用しているものと.Its.dll以外のハッシュ値は一致しました
※Its.dllは複数のビルドを入れ替えて検証した経緯があり私の環境と一致しませんでしたが、これもオリジナルだと思います。

ちなみに…
AutoVfrは60i横スクロールテロップはうまくFunc_6to2で処理してくれるのですが
30pのテロップは通常の24fps/30fps混在と認識してしまい困っています。
Func_3to2相当に24p化してくれると嬉しいのですが、そのような方法を
ご存じないでしょうか?
(AvisynthNeoとはもはや関係なくてすいません)

以上、よろしくお願いします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants