Video¶
-
Draft.
QTFastStart
((unicode)inputFile, (unicode)outputFile) → int :¶ Rearranges the atoms inside the input QT file to enable playback without first loading the entire file.
Arguments:
- inputFile
- The filename of the input .mov file.
- outputFile
- The filename of the output .mov file.
Usage:
Draft.QTFastStart( "/path/to/input.mov", "/path/to/output.mov" )
-
Draft.
ConcatenateVideoFiles
((list)inputFiles, (unicode)outputFile) → None :¶ Concatenate a list of video files.
New in version 1.5.
Arguments:
- inputFiles
- A list of string values indicating paths to the video files to concatenate.
- outputFile
- A string value indicating the path to the concatenated video to create.
Usage:
Draft.ConcatenateVideoFiles( [ "/path/to/input1.mov", "/path/to/input2.mov" ], "/path/to/output.mov" )
VideoEncoder
¶
-
class
Draft.
VideoEncoder
¶ - object __init__(tuple args, dict kwds) :
__init__( (VideoEncoder) arg1, (str)filename [, (object)fps=24 [, (int)width=640 [, (int)height=480 [, (int)kbitRate=None [, (str)codec=’MJPEG’ [, (str)audioFilename=’’ [, (int)audioDelay=0]]]]]]] ) -> None[, (TimeCode)timecode=None
Create a VideoEncoder.
Constructor Arguments:
- filename
- A string value indicating where the video file should be saved.
- fps
- Optional. An integer, float, or Fraction value indicating the framerate to use. (Default is 24.)
- width
- Optional. An integer value indicating the width to use. (Default is 640.)
- height
- Optional. An integer value indicating the height to use. (Default is 480.)
- kbitRate
- Optional. An integer value indicating the kbit rate to use. (Default is None, which corresponds to quality = 85.) Only one of kbitRate or quality can be specified.
- codec
- A string value indicating the Codec to use. (Default is ‘MJPEG’.) Valid codec values are: ‘MPEG4’, ‘MJPEG’, ‘H264’, ‘RAWVIDEO’, and ‘VP8’.
- audioFilename
- A string value indicating the name of an audio file, or a video file with an audio track, to include in the video. This can be an empty string for no audio file. (Default is ‘’.)
- audioDelay
- Optional. An integer value indicating the delay to apply to the audio file, measured in frames. (Default is 0.)
- timecode
- Optional. A
Draft.Timecode
object used to set the timecode that will be embedded in the video. (Default is None.)
Named arguments:
- quality
- An integer in the range [0..100] indicating the video encoding quality to use. Greater values correspond to higher quality. Only one of quality or kbitRate can be specified.
Usage:
enc = Draft.VideoEncoder( "//path/to/video/save.mov" )
or, to specify the frame rate and frame size:
enc = Draft.VideoEncoder( "//path/to/video/save.mov", 24, 800, 600 )
or, to include an audio file:
enc = Draft.VideoEncoder( "//path/to/video/save.mov", audioFilename='//path/to/audio/load.wav' )
or, to use a specific quality and codec:
enc = Draft.VideoEncoder( "//path/to/video/save.mov", quality=80, codec='H264' )
or, to use a Fraction FPS:
from fractions import Fraction fps = Fraction(30000, 1001) enc = Draft.VideoEncoder( "//path/to/video.mov", fps, 800, 600, 5120, "MJPEG" )
-
EncodeNextFrame
((VideoEncoder)arg1, (Image)image) → None :¶ EncodeNextFrame( image )
Encodes a given
Draft.Image
as the next frame in the video.Arguments:
- image
- The image to encode into the next frame of the video.
Usage:
defaultEncoder = Draft.VideoEncoder( "//path/to/video/save.mov" ) defaultEncoder.EncodeNextFrame( Draft.Image.CreateImage( 800, 600 ) )
-
FinalizeEncoding
((VideoEncoder)arg1) → None :¶ Finalizes the encoding process, completing the video.Arguments: (none)
Usage:
enc = Draft.VideoEncoder( "//path/to/video.mov" ) # encode some frames here... enc.FinalizeEncoding()
VideoDecoder
¶
-
class
Draft.
VideoDecoder
((object)arg1, (unicode)filename) → None :¶ Create a VideoDecoder to decode the specified file.
Constructor Arguments:
- filename
- A string value indicating the path of the video to decode.
Usage:
decoder = Draft.VideoEncoder( "//path/to/video/load.mov" )
-
DecodeFrame
((VideoDecoder)arg1, (long)frameNumber, (Image)image) → bool :¶ Decodes a specified frame from the video and returns it by reference through the image argument. This function returns a boolean to indicate whether or not the decode succeeded.
Arguments:
- frameNumber
- An integer indicating which frame should be decoded.
- image
- A
Draft.Image
object used to return the decoded frame.
Usage:
decoder = Draft.VideoDecoder( "//path/to/video/file.mov" ) frameImage = Draft.Image.CreateImage( 800, 600 ) if decoder.DecodeFrame( 100, frameImage ): # process frameImage here...
-
DecodeNextFrame
((VideoDecoder)arg1, (Image)image) → bool :¶ Decodes a frame from the video and returns it by reference through the image argument. This function returns a boolean to indicate whether or not the decode succeeded.
Arguments:
- image
- A
Draft.Image
object used to return the decoded frame.
Usage:
decoder = Draft.VideoDecoder( "//path/to/video/file.mov" ) frameImage = Draft.Image.CreateImage( 800, 600 ) while( decoder.DecodeNextFrame( frameImage ) ): # process the decoded frames here...
-
fps
¶ The average frame rate of the video.
-
height
¶ The height of a video frame.
-
timecode
¶ The timecode embedded in the video.
-
width
¶ The width of a video frame.