Okay, how does this script fit your needs?:
[code]# Create a Shotgun filmstrip thumbnail from a sequence of frames
Assumes the standard deadline parameters are used to specify the input file name pattern,
and what otuput file name to save the thumbnail image as. A custom parameter, ‘stepSize’,
is used to specify a subset of the frames (from frameList) to use for the thumbnail. For
example, if stepSize=10 and frameList=0-99, then the frames used will be 0, 10, 20, …, 90
(assuming the frame list starts at 0 and doesn’t skip any).
import Draft
import sys # To access commmand line arguments. Deadline sends script parameters as command line arguments.
from DraftParamParser import * # Functions to process command line arguments for Draft.
SHOTGUN_THUMBNAIL_FRAME_WIDTH = 240
def MakeShotgunFilmstripThumbnail( inFilePattern, thumbnailOutFile, frames, thumbnailHeight ) :
thumbnail = Draft.Image.CreateImage( SHOTGUN_THUMBNAIL_FRAME_WIDTH * len( frames ), thumbnailHeight )
thumbnail.SetChannel( ‘A’, 1.0 ) # make sure transparent areas composite properly on background
# composite each frame on the thumbnail image
xOffset = 0
xDelta = 1.0 / len( frames )
for frameNum in frames:
filename = ReplaceFilenameHashesWithNumber( inFilePattern, frameNum )
frame = Draft.Image.ReadFromFile( filename )
frame.Resize( SHOTGUN_THUMBNAIL_FRAME_WIDTH, thumbnailHeight, 'fit' )
thumbnail.Composite( frame, xOffset, 0, Draft.CompositeOperator.OverCompositeOp )
xOffset += xDelta
return thumbnail
figure out the thumbnail height, if the frames aren’t all the same aspect ratio
def ComputeThumbnailHeight( inFilePattern, thumbnailOutFile, frames ) :
height = 0
for frameNum in frames:
filename = ReplaceFilenameHashesWithNumber( inFilePattern, frameNum )
frame = Draft.Image.ReadFromFile( filename )
scaling = float( SHOTGUN_THUMBNAIL_FRAME_WIDTH ) / frame.width
outHeight = int( round( frame.height * scaling ) )
if outHeight > height :
height = outHeight
return height
select every nth frame from the list
def SubsetFrames( frames, n ) :
return frames[::n]
Example on how to use the above functions:
The argument name/types we’re expecting from the command line arguments or Deadline.
expectedTypes = dict()
expectedTypes[‘inFile’] = ‘’
expectedTypes[‘outFile’] = ‘’
expectedTypes[‘frameList’] = ‘’
expectedTypes[‘stepSize’] = ‘’
Parse the command line arguments.
params = ParseCommandLine( expectedTypes, sys.argv ) # params now contains a dictionary of the parameters initialized to values from the command line arguments.
inFilePattern = params[‘inFile’] # The pattern that the input files follow, for example frame_name_###.ext, where ### represents a three digit frame number.
thumbnailOutFile = params[‘outFile’]
frames = FrameRangeToFrames( params[‘frameList’] ) # Get a list of the individual frames we are to process
n = params[‘stepSize’]
frameSubset = SubsetFrames( frames, n )
height = ComputeThumbnailHeight( inFilePattern, thumbnailOutFile, frameSubset )
thumbnailImage = MakeShotgunFilmstripThumbnail( inFilePattern, thumbnailOutFile, frameSubset, height )
thumbnailImage.WriteToFile( thumbnailOutFile )[/code]
Note: I’ve used outFile as the file name for the thumbnail, but you’ll want to change that if you’re also saving a movie or something else. (You could hard code the thumbnail name, use another custom parameter, or add onto the outFile name.)
Cheers,
Andrea