Add a Slate Frame to a Movie Clip

Problem

You want to add a slate frame to a movie clip.

Solution

The first step is to either load a standard slate frame or create a new image to insert in front of the existing frames. You can even add text to this image to incorporate meta-data like shot information or project information.

slate = Draft.Image.CreateImage( outWidth, outHeight )
slate.SetToColor( Draft.ColorRGBA( 0.0, 0.0, 0.0, 1.0 ) )

#sets up the text on the slate frame
slateText = [("SHOW", jobParams.get('ExtraInfo1', '')), #skipped if no ExtraInfo1
        ("EPISODE", params.get('episode', '')), #skipped if 'episode' not in extra args
        ("SHOT", params['entity']),
        ("FRAMES", params['frameList']),
            ("HANDLES", params.get('handles', '')), #skipped if 'handles' not in extra args
        ("VERSION", params['version']),
        ("",''),
        ("",''),
        ("ARTIST", params['username']),
        ("DATE/TIME", datetime.datetime.now().strftime("%m/%d/%Y %I:%M %p") )]

#comp the annotations over top the slate frame
skipLines = 0
for i in range( 0, len( slateText ) ):
    if ( slateText[i][1] == "" ):
        skipLines += 1
        continue

    lineNum = i - skipLines
    if ( slateText[i][0] != "" ):
        txtImg = Draft.Image.CreateAnnotation( slateText[i][0] + ": ",
                annotationInfo )
        slate.CompositeWithPositionAndAnchor( txtImg, 0.45, 0.7 - (lineNum * 0.06),
                Draft.Anchor.SouthEast, Draft.CompositeOperator.OverCompositeOp )

    if ( slateText[i][1] != "" ):
        txtImg = Draft.Image.CreateAnnotation( slateText[i][1], annotationInfo )
        slate.CompositeWithPositionAndAnchor( txtImg, 0.46, 0.7 - (lineNum * 0.06),
                Draft.Anchor.SouthWest, Draft.CompositeOperator.OverCompositeOp )

Once the slate frame is created, you simply need to encode this image before feeding the rest of the frames into the VideoEncoder. By re-encoding the image multiple times you can hold the slate for as long as you desire. For example if we wanted to hold our slate for half a second in a 24 frames per second clip, we would encode the slate 12 times.

numberOfSlateFrames = 12 # hold for half a second @ 24fps
#encode the slate frames at the start of the video
for i in range( 0, numberOfSlateFrames ):
    encoder.EncodeNextFrame( slate )
#encode the rest of the video after this

Discussion

The first two lines of the solution create a black frame for our slate information to be written on. The next part is when we set up all the information that will appear on our slate. All of this info comes from Deadline (See Deadline Integration and Param Parsing for more details). The next parts will create the text images and composite them onto our black slate so that the titles (like SHOW or ARTIST) appear on the left and the values appear on the right.

The last part of the solution encodes the slate frame to the start of our video. Set numberOfSlateFrames to be the number of frames you want your slate to be.