AWS Thinkbox Discussion Forums

Question/Request: Draft API & Shotgun Filmstrip Rendering

Hi, I already posted this on the Deadline6 beta forum and Ryan asked me to post it here. I have two questions concerning Draft:
(1) Is or will there be an API for Draft besides the cookbook? We’d like to convert tiled EXRs to scanline EXRs with parameters for compression and bit depth, but I couldn’t find any documentation for the WriteToFile function.
(2) We’d also like to create Shotgun Filmstrip Thumbnails via Draft and my question is if you are already planning on implementing this function in your scripts. Otherwise this would be feature request :wink:

Thanks,
Chris

An API reference is in the works, and I’ve poked Ian to bump it up in the queue. :slight_smile: He said to reply that it is coming soon.

EDIT: Doh… I meant to paste in the part of the API about the requested function:

WriteToFile
Type: Member
Description: Writes the image to a file on disk, (supports various image types determined by file extension).
Arguments:
Filename – A string value indicating where to save the file to.
Usage:

someImage = Draft.Image.CreateImage( 800, 600 ) someImage.WriteToFile( "//path/to/save/location.png" )
If you have any further questions on how this (or any other) function works while the API Documentation is not yet up, let me know!
END EDIT

I’m fairly new to the company, and am still learning all the different software out there (given how much there is, I suspect that’ll be true even when I’m not new!)… if you’re able to describe what it means to create “Shotgun Filmstrip Thumbnails”, I’m sure I can whip something up. :slight_smile:

Cheers,
Andrea

Hi Andrea,

thanks for your quick reply! It’s good news to have an API soon!

The part you pasted in is like the code I found in the cookbook. I was hoping that there are more parameters for this function like compression and bit depth of the rendered image. Of course this depends on the file type, but it would be very nice to have.

Draft is new to everyone of us of course, but there is a lot of potential in it in combination with Deadline and Shotgun! There is already a communication between Deadline6 and Shotgun implemented (Event Plugin in Deadline6) and when activated, it’s possible to automatically add rendered shots to the Shotgun database with thumbnails created by Draft. Our idea is to use this functionality to create advanced thumbails for Shotgun. They are called filmstrip thumbnails. The advantage is that you can see a whole sequence in Shotgun on mouse over on the standard thumbnail. What Shotgun needs therefor is one extra image where the desired sequence images are all placed side by side. We thought this could be an additional feature to the Shotgun Event Plugin of Deadline6.

Here’s the part of the Shotgun API concerning the filmstrip thumbnails with a description on how the extra image has to look like:
github.com/shotgunsoftware/pyth … _thumbnail

If you have any further questions, let me know!

Thank you,
Chris

Those features aren’t yet implemented, but they’re on our wishlist. I’ll add a note that you’ve made a user request as well.

Heh… Draft was the first thing I was working on here, it’s Shotgun that I’m not familiar with. :wink: (And I’m still learning the ropes with Deadline, but I’ve at least used it a bit.)

I’ll chat with the deadline folks about whether they want to add it to the plugin itself, but I can certainly write a little script that you can either run on its own, or add to any of your custom Drfaft shotgun scripts.

Perfect! That’s precisely the information I need to start a script for you.

Will do! I’ll try to have a trial script to you soon. :slight_smile:

Cheers,
Andrea

Nice! Thanks a lot, Andrea!

Sounds like a great idea, I didn’t know Shotgun supported this :slight_smile: Shouldn’t be too bad to include, I’ll add it to the Deadline wishlist.

Cheers,

  • Jon

Okay, working on the script now, and have a question for you… how do you select which frames to use for the preview? Which of the following would be best, or would you prefer something else?:

  1. use the existing frameList parameter,
  2. use a custom frame list parameter, or
  3. use every “nth” frame from the existing frameList parameter, where “n” is either some constant, or a custom parameter?

Cheers,
Andrea

Hey Andrea,

I think ist would be best to have a custom parameter for n. This way it’s possible to use the whole sequence (n=1) or just a few (n>1) for large sequences.

Cheers,
Chris

Sure thing! I’ll make that change now.

What did you want to use for the output file name, or would you be putting in something that sent it directly to Shotgun?

Cheers,
Andrea

The file name shouldn’t be that important because the file hast to be uploaded to Shotgun either way with the upload_filmstrip_thumbnail function.

Cheers,
Chris

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

Thanks Andrea. This looks good! I’d like to use the script without Deadline first and I imported the Draft folder from the repository. The Draft.so file is imported, but I get an error that the *.dylib’s in the same folder are not found.

Traceback (most recent call last):
  File "/Users/chris/Documents/Job/omstudios/mainline/draft/CreateShotgunFilmstripThumbnail.py", line 15, in <module>
    import Draft
ImportError: dlopen(/Users/chris/Documents/Job/omstudios/mainline/deadline/DeadlineRepository6/draft/Mac/Draft.so, 2): Library not loaded: /usr/local/lib/libavcodec.54.dylib
  Referenced from: /Users/chris/Documents/Job/omstudios/mainline/deadline/DeadlineRepository6/draft/Mac/Draft.so
  Reason: image not found

Do I need to install them locally or is there another solution? It would be great to get it working on the command line without Deadline. Am I missing something here?

Cheers,
Chris

You’ll need to set a few environment variables to use Draft outside of Deadline. On Mac:

export DYLD_LIBRARY_PATH=/path/to/Draft/Mac export MAGICK_CONFIGURE_PATH=/path/to/Draft/Mac export PYTHONPATH=/path/to/Draft/MacWhere /path/to is the path to your Draft installation.

Privacy | Site terms | Cookie preferences