お知らせ: にーやんのブログ 2 に移転しました。こちらのブログは、2009 年末までに削除します。

スポンサード リンク

CopyFieldCond関数(2): フィルタ適用前のフィールドと置換可能に

CopyFieldCond 関数を少しいじってみました。

前回のスクリプトは CopyField 関数の拡張版ということで、あるフィールドを別のフィールドに置き換えるものでした。今回の修正で、フィルタ適用後のあるフィールドをフィルタ適用前の別のフィールドに置き換えることができるようになりました・・・たぶん。

そもそも前のバージョンがちゃんと動くかどうかもわからない状態なので、今回のも意図したとおりに動作しない可能性があります。よって動作無保証です。

CopyFieldCond関数(改)

function CopyFieldCond(clip clip, string logfile, bool "debug", bool "show_result", string "filter")
{
# デフォルト値などの指定
debug = default(debug, false) # debugのデフォルトはfalse
show_result = default(show_result, false) # debugのデフォルトはfalse
filter = default(filter, "") # filterのデフォルトは""
global FreezeThis = -1 # これは変更しないこと
global video = clip.SeparateFields() # フィールド分離

# filter指定があればfilterを適用してフィールド分離、さもなければvideo
filtered = (filter != "") ? Eval("clip." + filter).SeparateFields() : video

# debug==true&show_result==falseの場合: フレーム番号の表示
video = ((debug == true) && (show_result == false)) ?
\ video.ScriptClip("Subtitle(String(current_frame))") : video

# ScriptClip: フレームごとに評価
copy = video.ScriptClip("FreezeFrame(current_frame, current_frame, FreezeThis)")

# ConditionalFilter/ConditonalReader: FreezeThisが-1より大きいならcopyから取る
ConditionalFilter(video, copy, filtered, "FreezeThis", ">", "-1")
ConditionalReader(logfile, "FreezeThis", false)

# debug==true&show_result==falseの場合: フレーム番号の表示
((debug == true) && (show_result == true)) ?
\ ScriptClip("Subtitle(String(current_frame))") : last

# debug==trueの場合: 各フィールドを選択
even = ((debug == true) && (show_result == false)) ? video.SelectEven() :
\ ((debug == true) && (show_result == true)) ? SelectEven() : NOP
odd = ((debug == true) && (show_result == false)) ? video.SelectOdd() :
\ ((debug == true) && (show_result == true)) ? SelectOdd() : NOP

# debug==trueなら2画面分割表示、さもなければWeave
(debug == true) ? StackVertical(even, odd) : Weave()
}

使用例1: 通常モード(フィルタなし)

CopyFieldCond("CopyFields.txt")

前回と同じ。

!通常モード(フィルタなし)
大きい画像

使用例2: デバッグモード(フィルタなし/フィールド入れ替え前)

CopyFieldCond("CopyFields.txt", true) # または debug=true

前回と同じ。

!デバッグモード(フィルタなし/フィールド入れ替え前)
大きい画像

使用例3: デバッグモード(フィルタなし/フィールド入れ替え後)

CopyFieldCond("CopyFields.txt", true, true)

!デバッグモード(フィルタなし/フィールド入れ替え後)
大きい画像

「show_result=true」なら入れ替え後の状態を表示(debug=true 時のみ)。

使用例4: 通常モード(フィルタあり)

CopyFieldCond("CopyFields.txt", filter="GreyScale()") # filter=でフィルタ指定

!通常モード(フィルタあり)
大きい画像

使用例5: デバッグモード(フィルタあり/フィールド入れ替え前/フィルタ適用前)

CopyFieldCond("CopyFields.txt", true, filter="GreyScale()")

使用例2と同じ。

使用例6: デバッグモード(フィルタあり/フィールド入れ替え後/フィルタ適用後)

CopyFieldCond("CopyFields.txt", true, true, "GreyScale()")

!デバッグモード(フィルタあり/フィルタ適用後)
大きい画像


(追記)フィルタ(filter)はフィールド分離前のクリップに適用されます。

スポンサード リンク

Recent entries from same category
TrackBack ping me at
Trackbacks
[ No TrackBack ]
Comments
[ No Comment ]
Post a comment

writeback message: Ready to post a comment.













Remember the above info?

Preview here...

  • [Preview]ボタンをクリックすると、コメント内容をプレビューすることができます(JavaScript使用)。
  • スパム対策としてリファラチェックを行っています。セキュリティソフトの設定でリファラを無効にしていると投稿できません。
  • エントリの内容と無関係と思われるコメントやトラックバックは削除されます。
  • 当ブログへの言及リンクがないトラックバックはブロックされます。