Change the Encoding of a Movie Clip¶
Problem¶
You want to change the encoding of a movie clip.
Solution¶
Use the VideoDecoder
to decode your existing clip and then use the VideoEncoder
to encode that clip into a different codec. For example, the following code converts an input QuickTime to h.264.
image = Draft.Image.CreateImage( 1, 1 )
decoder = Draft.VideoDecoder( "//path/to/existing/clip.mov" )
hasFrames = decoder.DecodeNextFrame( image )
if hasFrames:
encoder = Draft.VideoEncoder( "//path/to/video/save.mov", codec='H264' )
while hasFrames:
encoder.EncodeNextFrame( image )
hasFrames = decoder.DecodeNextFrame( image )
encoder.FinalizeEncoding()
Discussion¶
Taking a movie clip and encoding it with a new codec is just a matter of decoding the existing clip and encoding it into a new clip. An important thing to remember is that the paths for the decoder and the encoder must be different. You can’t decode and encode the same file at the same time.
Draft will detect which decoder to use automatically so you do not need to specify it when you are decoding.
Draft supports multiple codec options. You can consult the sections Video in Concepts for a complete list.