Samples/Video/VideoInput.py

# Copyright 2010 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.
# ...
# This script shows how to setup a cube with a live video input.
# ...
#
# Topic: FBVideoIn, FBMaterial, FBTexture, FBMaterialTextureType
#

from pyfbsdk import FBSystem, FBModel, FBModelCube, FBMaterial, FBTexture, FBVector3d, FBColor, FBMaterialTextureType

# for directory access
import os

# Create a cube
lCube = FBModelCube("My Cube")
lCube.Scaling = FBVector3d(40, 40, 20)
lCube.Show = True
lCube.Visible = True

# Create a material
lMaterial = FBMaterial("My Material with live video")

# Create a video live input
videoInList = FBSystem().VideoInputs
if(len(videoInList) > 0):
    videoInput = videoInList[0]

    #set some properties of the video input
    print videoInput.LiveGetCompressorCount()
    if(videoInput.LiveGetCompressorCount() > 1):
        print videoInput.LiveGetCompressorName(1)
        videoInput.LiveSetCompressor(1)
        
    print videoInput.LiveGetResolutionFRCount()
    if(videoInput.LiveGetResolutionFRCount() > 1):
        print videoInput.LiveGetResolutionFRName(1)
        videoInput.LiveSetResolutionFR(1)    
        
    videoInput.Online = True
    videoInput.Recording = True
    videoInput.RecordAudio = True
    videoInput.FilePath = "C:\\test.avi"

    # Create a texture
    lTexture = FBTexture("Video live input")
    lTexture.Video = videoInput
    
    # Set texture to material's diffuse channel.
    lMaterial.SetTexture(lTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)
    
    # Attach material to cube
    lCube.Materials.append(lMaterial)