I took the bundled in Draft_CreateShotgunMovie.py and have tweaked the script a little to add audio, but it doesn’t seem like that should have affected the loop over the job’s frames.
Here’s the script:
[code]import os, sys
import Draft
import DraftParamParser
expectedTypes = {
“frameList” : ‘’,
“inFile” : ‘’,
“outFile” : ‘’,
“framerate” : ‘’,
“audioFilepath” : ‘’
}
params = DraftParamParser.ParseCommandLine( expectedTypes, sys.argv )
frames = DraftParamParser.FrameRangeToFrames( params[‘frameList’] )
inputPath = params[‘inFile’]
outWidth = 1280
outHeight = 720
encoder = None
progressCounter = 0
lastPercentage = -1
annotation = DraftParamParser.ParseCommandLine_TypeAgnostic( sys.argv )
note = annotation.get(‘annotation’, ‘’)
for frameNum in frames:
inFile = DraftParamParser.ReplaceFilenameHashesWithNumber( inputPath, frameNum )
frame = Draft.Image.ReadFromFile( inFile )
if not encoder:
ratio = float(frame.width) / float(frame.height)
outWidth = int(ratio * outHeight)
#Prevent an error with rendering to H264 with non even numbers
if outWidth % 2 != 0:
outWidth -= 1
if outHeight % 2 != 0:
outHeight -= 1
framerate = params['framerate']
audioPath = params['audioFilepath']
print "Creating H264 video encoder ({0}x{1} @ {2}fps)".format( outWidth, outHeight, framerate )
if audioPath:
try:
print "Using audio file at " + audioPath
encoder = Draft.VideoEncoder( params['outFile'], framerate, outWidth, outHeight, codec='H264', audioFilename=audioPath )
except:
print "ERROR: Couldn't find audio at " + audioPath
encoder = Draft.VideoEncoder( params['outFile'], framerate, outWidth, outHeight, codec='H264' )
else:
encoder = Draft.VideoEncoder( params['outFile'], framerates, outWidth, outHeight, codec='H264' )
frame.Resize( outWidth, outHeight, 'height' )
if annotation:
textInfo = Draft.AnnotationInfo()
textInfo.PointSize = int( 0.5 * 72 ) # height * ppi
textInfo.DrawShadow = True
textImage = Draft.Image.CreateAnnotation(note, textInfo)
frame.CompositeWithPositionAndAnchor(textImage, 0.15, 0.075,
Draft.Anchor.South,
Draft.CompositeOperator.OverCompositeOp)
encoder.EncodeNextFrame( frame )
progressCounter = progressCounter + 1
percentage = progressCounter * 100 / len( frames )
if percentage != lastPercentage:
lastPercentage = percentage
print "Encoding Progress: {0}%".format( percentage )
print “Finalizing encoding…”
encoder.FinalizeEncoding()
print “Done!”[/code]
I’m not sure if there are videos where this hasn’t happened. It’s so common I think it’s happening in every scene. I have some frames you can use to test though, the zip is here:
https://drive.google.com/file/d/0BysaXQvywjZdZ3lRUDdVSW9maG8/view?usp=sharing
It contains a folder full of PNGs that were used to make a video. As well as the mov that was made by draft. The PNGs are numbered, so it’s easy to see in Quicktime how the end of it has an extra frame when you go through frame by frame (using the arrow keys). There’s also the source Anime Studio file just in case.