render codec を毎回入力しなくて良いスクリプト
※今のところMobu2009じゃないと機能しません・・・。
■File->Render でムービーを書き出す
このときMotionBuilderではなぜか圧縮方式を毎回聞いてくる・・・。
たいていの場合一度圧縮形式を決めたら、それを変更することはないので、
これは面倒くさい。
なんとか以前の設定を使ってレンダリングできないものかと、pythonスクリプトを調べてみると・・・
■codecExamples.py
サンプルファイルに codecExamples.py を発見。
中を覗くと、どうやら一度目はcodecの設定画面が出るが、二度目以降は以前の設定でレンダーするというもの。
これだ!
ただ、AVI形式が指定される点、一度は必ず設定を聞かれる点が不満。
二度目以降は常に同じ設定でレンダーをしてくれる仕様にしたい。
というわけで、ちょこっと書き換えました。
ボタンだけだけど、ついでにUIも作ってみた。
■ポイント
mgr = FBVideoCodecManager()
mgr.VideoCodecMode = FBVideoCodecMode.FBVideoCodecStored
ポイントは FBVideoCodecStored というオプション。以前レンダーをした時に記憶した設定を利用するようになる。
FBVideoCodecAsk というオプションもあり、こちらは毎回 codec を聞いてくる。
■codecStoredRender.py
レンダー設定はオリジナルUIで行い、レンダーのみ作ったUIのボタンで行うという、プログラムとしてはスマートじゃない感じになったけど、売り物でもないし、、、、いいか。
以下スクリプト↓
from pyfbsdk import * from pyfbsdk_additions import * import sys #################### ## Main Scripts ## #################### def renderUseSameSetting(control, event): try: mgr = FBVideoCodecManager() lApp = FBApplication() if (control.Caption == "Render Movie"): print "Render video with previous settings." mgr.VideoCodecMode = FBVideoCodecMode.FBVideoCodecStored lOptions = FBVideoGrabber().GetOptions() lApp.FileRender( lOptions ) else: print "Render video with new settings." mgr.VideoCodecMode = FBVideoCodecMode.FBVideoCodecAsk except Exception, e: FBMessageBox( "ERROR", "Unknown error encountered. Aborting! " + str(e), "OK", None, None ) ################# ## Create UI ## ################# def PopulateLayout(mainLyt): x = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"") y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"") w = FBAddRegionParam(-5,FBAttachType.kFBAttachRight,"") h = FBAddRegionParam(-5,FBAttachType.kFBAttachBottom,"") mainLyt.AddRegion("main","main", x, y, w, h) lyt = VBoxLayout() mainLyt.SetControl("main",lyt) label = FBLabel() label.Caption = "- Use [File>Render] for set options." lyt.Add(label,15) b = FBButton() b.Caption = "Render Movie" b.Justify = FBTextJustify.kFBTextJustifyCenter lyt.AddRelative(b) b.OnClick.Add(renderUseSameSetting) def CreateTool(): # Tool creation will serve as the hub for all other controls t = CreateUniqueTool("Render +CodecStoring") t.StartSizeX = 200 t.StartSizeY = 100 PopulateLayout(t) ShowTool(t) CreateTool() #END OF SCRIPT#
<追記>
HTMLの <pre> タグを覚えました。
プログラムのインデントなどがこれで見やすくなったかな。
特に python ではインデントでブロック管理するみたいで、pre が無いとコピペしてもエラーが出てしまいます。
だいたい必要なものって用意されているものですね。