# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Shows how to specify codec and pop codec selection dialog.
#
# Topic: FBVideoCodecManager, FBVideoGrabber
#
from pyfbsdk import *
import sys

try:
    mgr = FBVideoCodecManager()
    # By specifying Codec stored, the first time we render a scene, the codec dialog
    # will ve available if user press con configure
    # the second time a scene is rendered, the same settings will be used.
    mgr.VideoCodecMode = FBVideoCodecMode.FBVideoCodecStored

    # Will print the list of all available codec id
    print mgr.GetCodecIdList( "AVI" )

    # Get the current default codec id for AVI file
    print mgr.GetDefaultCodec( "AVI" )

    lApp = FBApplication()
    lOptions = FBVideoGrabber().GetOptions()
    # render first time: user can specify rendering params
    lOptions.OutputFileName = "c:/ouput_1.avi"
    lApp.FileRender( lOptions )

    # render second time: the same params are used for rendering
    lOptions.OutputFileName = "c:/ouput_2.avi"
    lApp.FileRender( lOptions )

except Exception, e:
    # Unkown error encountered... Maybe from the 'listdir' call failing...
    FBMessageBox( "ERROR", "Unknown error encountered. Aborting! " + str(e), "OK", None, None )