Python Reference Guide
 
Loading...
Searching...
No Matches
Tasks\JpegRender.py
1# Copyright 2009 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# Topic: FBVideoGrabber, FBVideoGrabber.GetOptions, FBApplication.FileRender
7#
8
9from pyfbsdk import *
10
11import tempfile
12import os
13import os.path
14
15# Create an application object.
16lApp = FBApplication()
17
18# We need the full path of the output file.
19if lApp.FBXFileName!="":
20 lDstFileName = lApp.FBXFileName.replace( '.fbx', '.jpg' )
21else:
22 lDstFileName = os.path.join( tempfile.gettempdir(), 'Default.jpg' )# WARNING: If the current scene has yet to be named (i.e. after a File->New), this script will set the render path to TEMPDIR/Default.jpg
23
24# Get the default rendering options, which are saved in the FBX file.
25lOptions = FBVideoGrabber().GetOptions()
26
27# Set the name of the rendered file.
28# The rendering will be done in the same folder as the original FBX file.
29lOptions.OutputFileName = lDstFileName
30
31# Setup the compression level.
32# The value should be between '1' and '100', and indicates the size of
33# the compressed rendered file vs the size of an uncompressed rendered
34# file. In other words, '100' means 'no compression'.
35# As the value tends towards 1, the quality of the rendered frame will
36# decrease.
37lOptions.StillImageQuality = 40
38
39# Enable audio rendering. The file name will be the same as the FBX file,
40# but will have a .wav extention.
41lOptions.RenderAudio = True
42
43# Do the render. This will always be done in uncompressed mode.
44if not lApp.FileRender( lOptions ):
45 print('An error was found rendering : ' + FBVideoGrabber().GetLastErrorMsg())
FBApplication is used mainly to manage files.
Definition: pyfbsdk_generated.h:801
Video Grabber class.
Definition: pyfbsdk_generated.h:20875