VideoEncoder Class

[size=150]VideoEncoder Class[/size]

VideoEncoder
Type: Class
Constructor Arguments:
[list]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.
codec – Optional. A string value indicating the Codec to use. Default is ‘MJPEG’. Valid codec values are: ‘MPEG4’, ‘MJPEG’, ‘H264’, ‘DNXHD’, and ‘RAWVIDEO’.
audioFilename – Optional. A string value indicating the file 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.

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:

encoder = Draft.VideoEncoder( "//path/to/video/save.mov" )
  • or, to specify the frame rate and frame size -
encoder = Draft.VideoEncoder( "//path/to/video/save.mov", 24, 800, 600 )
  • or, to include an audio file -
encoder = Draft.VideoEncoder( "//path/to/video/save.mov", audioFilename='//path/to/audio/load.wav' )
  • or, to use a specific quality and codec -
encoder = 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) encoder = Draft.VideoEncoder( "//path/to/video.mov", fps, 800, 600, 5120, "MJPEG" )[/list:u]

[size=150]Member Functions[/size]
EncodeNextFrame
Description: Encodes a given Draft image as the next frame in the video.
Arguments:
[list]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 ) )[/list:u]

FinalizeEncoding
Description: Finalizes the encoding process, completing the video.
Arguments: (none)
Usage:
[list]encoder = Draft.VideoEncoder( "//path/to/video.mov", 29, 800, 600, 5120, "MJPEG" ) #encode some frames here... encoder.FinalizeEncoding()[/list:u]

Privacy | Site terms | Cookie preferences