.. _Concepts/Video:

Video
=====

Overview
--------

A :class:`Draft.VideoEncoder` is used to create videos and a :class:`Draft.VideoDecoder` is used to extract frames from videos. 

Implementation Details
----------------------

Video Encoder
~~~~~~~~~~~~~

When creating a :class:`Draft.VideoEncoder` you can specify many parameters including the video's framerate, kbit rate and codec. For a complete list, please consult the constructor :meth:`~Draft.VideoEncoder`. Once your :class:`Draft.VideoEncoder` is created, you can encode each frame using the method :meth:`~Draft.VideoEncoder.EncodeNextFrame`.

.. _Concepts/SupportedCodecReference:

Supported Codecs
""""""""""""""""

Draft supports multiple codec options. They include:

- MPEG4 (default)
- MJPEG
- DNxHD\ |reg| (**requires a "Draft Codec Pack" license**)
- H264
- RAWVIDEO

.. _Concepts/ValidDNxHDSettingsReference:

Valid Avid DNxHD\ |reg| Settings
""""""""""""""""""""""""""""""""

It's important to remember that when you're encoding with Avid DNxHD\ |reg| you must use a specific set of parameters. Here is a table of all the Avid DNxHD\ |reg| settings that work with Draft.

.. |reg|    unicode:: U+000AE .. REGISTERED SIGN

=====  ======  ======  ========
width  height  fps     kbitRate
=====  ======  ======  ========
1920   1080    59.94   440000
1920   1080    59.94   290000
1920   1080    59.94   90000
1920   1080    50      365000 *
1920   1080    50      240000 *
1920   1080    50      75000 *
1920   1080    29.97   220000
1920   1080    29.97   145000
1920   1080    29.97   45000
1920   1080    25      185000 *
1920   1080    25      120000 *
1920   1080    25      36000 *
1920   1080    24      175000 *
1920   1080    24      115000 *
1920   1080    24      36000 *
1920   1080    23.976  175000
1920   1080    23.976  115000
1920   1080    23.976  36000
1280   720     59.94   220000
1280   720     59.94   145000
1280   720     50      180000 
1280   720     50      120000 
1280   720     29.97   110000 
1280   720     29.97   75000
1280   720     25      90000
1280   720     25      60000
1280   720     23.976  90000
1280   720     23.976  60000
=====  ======  ======  ========

\* Draft supports writing MXF files for these combinations only 

Video Files Concatenation
~~~~~~~~~~~~~~~~~~~~~~~~~

It's possible to concatenate video files using the function :meth:`~Draft.ConcatenateVideoFiles` by providing a list of input files and an output file. Note that the input files must all share the same codec and all have the same file extension than the output file. 

Video Decoder
~~~~~~~~~~~~~

When creating a :class:`Draft.VideoDecoder` you must specify the filename of the video you want to decode. Once your :class:`Draft.VideoDecoder` is created, you can decode each frame using the method :meth:`~Draft.VideoDecoder.DecodeNextFrame`.

Relevant Cookbook Recipes
-------------------------

* :ref:`Basic/CreateAQuickTimeMovie`
* :ref:`Basic/ConcatenateVideoFiles`
* :ref:`Intermediate/ChangeTheEncodingOfVideo`
* :ref:`Intermediate/SplitMovieIntoSingleFrames`