AWS Thinkbox Discussion Forums

Extra ending frames in Quicktime videos

We have a recurring problem with out videos that draft wraps to upload to Shotgun. They double up the final frame of the video. So, for example:

A video that’s 72 frames long (framerange: 1-72) will play as 73 frames long (0-72 in Quicktime, 1-73 in Shotgun).

These are h264 Quicktimes that are taking PNGs and wrapping them with draft to upload to Shotgun. I believe that there are issues generally with Quicktime doing this (not sure if it’s specific to h264 encoding).

My question is if anyone has identified this before and found a solution or a way around it? Some of our reviews use a program that knows what the framerange should be. But for viewing the videos or watching directly on Shotgun this can be a point of confusion for supervisors, and it messes up the timing when watching a loop/sequence of videos.

I wonder if this is an off-by-one in a loop or accidentally injecting an additional frame when we shouldn’t. I don’t have enough practical experience with Quicktime to know if this is common for the format.

Are you using the bundled scripts in Deadline, or have they been tweaked? I think I’ll need a good set of steps to reproduce to see if there’s anything we can do about it. Are you able to reproduce reliably? Is there some test scene or process we can use to reproduce?

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.

Thanks for all the info! This is just about perfect.

I’m not sure when we’ll be able to get to this, but I’ll keep you posted on progress.

Great, thanks! If you need anything else to help, let me know.

Will do!

I can share what we noticed yesterday too. Grant and myself spent some time just playing with the Draft video in various players. It seems like the final frame is a bit messed up. In the QuickTime player, it shows as though there are two frames. Within Media Player Classic, that final frame is very strange as it’s not easily selected.

We’re not quite sure what tools we can use to break this problem down yet, but Draft on the decoder end thinks there is only 100 frames while QuickTime believes there is 101.

Are there any tools in anyone’s arsenal to test this and break it down?

Privacy | Site terms | Cookie preferences