Samples/Video/VideoInput.py

Samples/Video/VideoInput.py
1 # Copyright 2010 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 # ...
6 # This script shows how to setup a cube with a live video input.
7 # ...
8 #
9 # Topic: FBVideoIn, FBMaterial, FBTexture, FBMaterialTextureType
10 #
11 
12 from pyfbsdk import FBSystem, FBModel, FBModelCube, FBMaterial, FBTexture, FBVector3d, FBColor, FBMaterialTextureType
13 
14 # for directory access
15 import os
16 
17 # Create a cube
18 lCube = FBModelCube("My Cube")
19 lCube.Scaling = FBVector3d(40, 40, 20)
20 lCube.Show = True
21 lCube.Visible = True
22 
23 # Create a material
24 lMaterial = FBMaterial("My Material with live video")
25 
26 # Create a video live input
27 videoInList = FBSystem().VideoInputs
28 if(len(videoInList) > 0):
29  videoInput = videoInList[0]
30 
31  #set some properties of the video input
32  print videoInput.LiveGetCompressorCount()
33  if(videoInput.LiveGetCompressorCount() > 1):
34  print videoInput.LiveGetCompressorName(1)
35  videoInput.LiveSetCompressor(1)
36 
37  print videoInput.LiveGetResolutionFRCount()
38  if(videoInput.LiveGetResolutionFRCount() > 1):
39  print videoInput.LiveGetResolutionFRName(1)
40  videoInput.LiveSetResolutionFR(1)
41 
42  videoInput.Online = True
43  videoInput.Recording = True
44  videoInput.RecordAudio = True
45  videoInput.FilePath = "C:\\test.avi"
46 
47  # Create a texture
48  lTexture = FBTexture("Video live input")
49  lTexture.Video = videoInput
50 
51  # Set texture to material's diffuse channel.
52  lMaterial.SetTexture(lTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)
53 
54  # Attach material to cube
55  lCube.Materials.append(lMaterial)
56 
57