def start_recording(self, output, format=None, resize=None, splitter_port=1, **options):
    '\n        Start recording video from the camera, storing it in *output*.\n\n        If *output* is a string, it will be treated as a filename for a new\n        file which the video will be written to. If *output* is not a string,\n        but is an object with a ``write`` method, it is assumed to be a\n        file-like object and the video data is appended to it (the\n        implementation only assumes the object has a ``write()`` method - no\n        other methods are required but ``flush`` will be called at the end of\n        recording if it is present). If *output* is not a string, and has no\n        ``write`` method it is assumed to be a writeable object implementing\n        the buffer protocol. In this case, the video frames will be written\n        sequentially to the underlying buffer (which must be large enough to\n        accept all frame data).\n\n        If *format* is ``None`` (the default), the method will attempt to guess\n        the required video format from the extension of *output* (if it\'s a\n        string), or from the *name* attribute of *output* (if it has one). In\n        the case that the format cannot be determined, a\n        :exc:`PiCameraValueError` will be raised.\n\n        If *format* is not ``None``, it must be a string specifying the format\n        that you want the video output in. The format can be a MIME-type or\n        one of the following strings:\n\n        * ``\'h264\'`` - Write an H.264 video stream\n        * ``\'mjpeg\'`` - Write an M-JPEG video stream\n        * ``\'yuv\'`` - Write the raw video data to a file in YUV420 format\n        * ``\'rgb\'`` - Write the raw video data to a file in 24-bit RGB format\n        * ``\'rgba\'`` - Write the raw video data to a file in 32-bit RGBA format\n        * ``\'bgr\'`` - Write the raw video data to a file in 24-bit BGR format\n        * ``\'bgra\'`` - Write the raw video data to a file in 32-bit BGRA format\n\n        If *resize* is not ``None`` (the default), it must be a two-element\n        tuple specifying the width and height that the video recording should\n        be resized to. This is particularly useful for recording video using\n        the full resolution of the camera sensor (which is not possible in\n        H.264 without down-sizing the output).\n\n        The *splitter_port* parameter specifies the port of the built-in\n        splitter that the video encoder will be attached to. This defaults to\n        ``1`` and most users will have no need to specify anything different.\n        If you wish to record multiple (presumably resized) streams\n        simultaneously, specify a value between ``0`` and ``3`` inclusive for\n        this parameter, ensuring that you do not specify a port that is\n        currently in use.\n\n        Certain formats accept additional options which can be specified\n        as keyword arguments. The ``\'h264\'`` format accepts the following\n        additional options:\n\n        * *profile* - The H.264 profile to use for encoding. Defaults to\n          \'high\', but can be one of \'baseline\', \'main\', \'extended\', \'high\', or\n          \'constrained\'.\n\n        * *level* - The `H.264 level`_ to use for encoding. Defaults to \'4\',\n          but can be any H.264 level up to \'4.2\'.\n\n        * *intra_period* - The key frame rate (the rate at which I-frames are\n          inserted in the output). Defaults to ``None``, but can be any 32-bit\n          integer value representing the number of frames between successive\n          I-frames. The special value 0 causes the encoder to produce a single\n          initial I-frame, and then only P-frames subsequently. Note that\n          :meth:`split_recording` will fail in this mode.\n\n        * *intra_refresh* - The key frame format (the way in which I-frames\n          will be inserted into the output stream). Defaults to ``None``, but\n          can be one of \'cyclic\', \'adaptive\', \'both\', or \'cyclicrows\'.\n\n        * *inline_headers* - When ``True``, specifies that the encoder should\n          output SPS/PPS headers within the stream to ensure GOPs (groups of\n          pictures) are self describing. This is important for streaming\n          applications where the client may wish to seek within the stream, and\n          enables the use of :meth:`split_recording`. Defaults to ``True`` if\n          not specified.\n\n        * *sei* - When ``True``, specifies the encoder should include\n          "Supplemental Enhancement Information" within the output stream.\n          Defaults to ``False`` if not specified.\n\n        * *sps_timing* - When ``True`` the encoder includes the camera\'s\n          framerate in the SPS header. Defaults to ``False`` if not specified.\n\n        * *motion_output* - Indicates the output destination for motion vector\n          estimation data. When ``None`` (the default), motion data is not\n          output. Otherwise, this can be a filename string, a file-like object,\n          or a writeable buffer object (as with the *output* parameter).\n\n        All encoded formats accept the following additional options:\n\n        * *bitrate* - The bitrate at which video will be encoded. Defaults to\n          17000000 (17Mbps) if not specified. The maximum value depends on the\n          selected `H.264 level`_ and profile. Bitrate 0 indicates the encoder\n          should not use bitrate control (the encoder is limited by the quality\n          only).\n\n        * *quality* - Specifies the quality that the encoder should attempt\n          to maintain. For the ``\'h264\'`` format, use values between 10 and 40\n          where 10 is extremely high quality, and 40 is extremely low (20-25 is\n          usually a reasonable range for H.264 encoding). For the ``mjpeg``\n          format, use JPEG quality values between 1 and 100 (where higher\n          values are higher quality). Quality 0 is special and seems to be\n          a "reasonable quality" default.\n\n        * *quantization* - Deprecated alias for *quality*.\n\n        .. versionchanged:: 1.0\n            The *resize* parameter was added, and ``\'mjpeg\'`` was added as a\n            recording format\n\n        .. versionchanged:: 1.3\n            The *splitter_port* parameter was added\n\n        .. versionchanged:: 1.5\n            The *quantization* parameter was deprecated in favor of *quality*,\n            and the *motion_output* parameter was added.\n\n        .. versionchanged:: 1.11\n            Support for buffer outputs was added.\n\n        .. _H.264 level: https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels\n        '
    if ('quantization' in options):
        warnings.warn(PiCameraDeprecated('The quantization option is deprecated; please use quality instead (same value)'))
    with self._encoders_lock:
        (camera_port, output_port) = self._get_ports(True, splitter_port)
        format = self._get_video_format(output, format)
        encoder = self._get_video_encoder(camera_port, output_port, format, resize, **options)
        self._encoders[splitter_port] = encoder
    try:
        encoder.start(output, options.get('motion_output'))
    except Exception as e:
        encoder.close()
        with self._encoders_lock:
            del self._encoders[splitter_port]
        raise
Start recording video from the camera, storing it in *output*.

If *output* is a string, it will be treated as a filename for a new
file which the video will be written to. If *output* is not a string,
but is an object with a ``write`` method, it is assumed to be a
file-like object and the video data is appended to it (the
implementation only assumes the object has a ``write()`` method - no
other methods are required but ``flush`` will be called at the end of
recording if it is present). If *output* is not a string, and has no
``write`` method it is assumed to be a writeable object implementing
the buffer protocol. In this case, the video frames will be written
sequentially to the underlying buffer (which must be large enough to
accept all frame data).

If *format* is ``None`` (the default), the method will attempt to guess
the required video format from the extension of *output* (if it's a
string), or from the *name* attribute of *output* (if it has one). In
the case that the format cannot be determined, a
:exc:`PiCameraValueError` will be raised.

If *format* is not ``None``, it must be a string specifying the format
that you want the video output in. The format can be a MIME-type or
one of the following strings:

* ``'h264'`` - Write an H.264 video stream
* ``'mjpeg'`` - Write an M-JPEG video stream
* ``'yuv'`` - Write the raw video data to a file in YUV420 format
* ``'rgb'`` - Write the raw video data to a file in 24-bit RGB format
* ``'rgba'`` - Write the raw video data to a file in 32-bit RGBA format
* ``'bgr'`` - Write the raw video data to a file in 24-bit BGR format
* ``'bgra'`` - Write the raw video data to a file in 32-bit BGRA format

If *resize* is not ``None`` (the default), it must be a two-element
tuple specifying the width and height that the video recording should
be resized to. This is particularly useful for recording video using
the full resolution of the camera sensor (which is not possible in
H.264 without down-sizing the output).

The *splitter_port* parameter specifies the port of the built-in
splitter that the video encoder will be attached to. This defaults to
``1`` and most users will have no need to specify anything different.
If you wish to record multiple (presumably resized) streams
simultaneously, specify a value between ``0`` and ``3`` inclusive for
this parameter, ensuring that you do not specify a port that is
currently in use.

Certain formats accept additional options which can be specified
as keyword arguments. The ``'h264'`` format accepts the following
additional options:

* *profile* - The H.264 profile to use for encoding. Defaults to
  'high', but can be one of 'baseline', 'main', 'extended', 'high', or
  'constrained'.

* *level* - The `H.264 level`_ to use for encoding. Defaults to '4',
  but can be any H.264 level up to '4.2'.

* *intra_period* - The key frame rate (the rate at which I-frames are
  inserted in the output). Defaults to ``None``, but can be any 32-bit
  integer value representing the number of frames between successive
  I-frames. The special value 0 causes the encoder to produce a single
  initial I-frame, and then only P-frames subsequently. Note that
  :meth:`split_recording` will fail in this mode.

* *intra_refresh* - The key frame format (the way in which I-frames
  will be inserted into the output stream). Defaults to ``None``, but
  can be one of 'cyclic', 'adaptive', 'both', or 'cyclicrows'.

* *inline_headers* - When ``True``, specifies that the encoder should
  output SPS/PPS headers within the stream to ensure GOPs (groups of
  pictures) are self describing. This is important for streaming
  applications where the client may wish to seek within the stream, and
  enables the use of :meth:`split_recording`. Defaults to ``True`` if
  not specified.

* *sei* - When ``True``, specifies the encoder should include
  "Supplemental Enhancement Information" within the output stream.
  Defaults to ``False`` if not specified.

* *sps_timing* - When ``True`` the encoder includes the camera's
  framerate in the SPS header. Defaults to ``False`` if not specified.

* *motion_output* - Indicates the output destination for motion vector
  estimation data. When ``None`` (the default), motion data is not
  output. Otherwise, this can be a filename string, a file-like object,
  or a writeable buffer object (as with the *output* parameter).

All encoded formats accept the following additional options:

* *bitrate* - The bitrate at which video will be encoded. Defaults to
  17000000 (17Mbps) if not specified. The maximum value depends on the
  selected `H.264 level`_ and profile. Bitrate 0 indicates the encoder
  should not use bitrate control (the encoder is limited by the quality
  only).

* *quality* - Specifies the quality that the encoder should attempt
  to maintain. For the ``'h264'`` format, use values between 10 and 40
  where 10 is extremely high quality, and 40 is extremely low (20-25 is
  usually a reasonable range for H.264 encoding). For the ``mjpeg``
  format, use JPEG quality values between 1 and 100 (where higher
  values are higher quality). Quality 0 is special and seems to be
  a "reasonable quality" default.

* *quantization* - Deprecated alias for *quality*.

.. versionchanged:: 1.0
    The *resize* parameter was added, and ``'mjpeg'`` was added as a
    recording format

.. versionchanged:: 1.3
    The *splitter_port* parameter was added

.. versionchanged:: 1.5
    The *quantization* parameter was deprecated in favor of *quality*,
    and the *motion_output* parameter was added.

.. versionchanged:: 1.11
    Support for buffer outputs was added.

.. _H.264 level: https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
def start_recording(self, output, format=None, resize=None, splitter_port=1, **options):
    '\n        Start recording video from the camera, storing it in *output*.\n\n        If *output* is a string, it will be treated as a filename for a new\n        file which the video will be written to. If *output* is not a string,\n        but is an object with a ``write`` method, it is assumed to be a\n        file-like object and the video data is appended to it (the\n        implementation only assumes the object has a ``write()`` method - no\n        other methods are required but ``flush`` will be called at the end of\n        recording if it is present). If *output* is not a string, and has no\n        ``write`` method it is assumed to be a writeable object implementing\n        the buffer protocol. In this case, the video frames will be written\n        sequentially to the underlying buffer (which must be large enough to\n        accept all frame data).\n\n        If *format* is ``None`` (the default), the method will attempt to guess\n        the required video format from the extension of *output* (if it\'s a\n        string), or from the *name* attribute of *output* (if it has one). In\n        the case that the format cannot be determined, a\n        :exc:`PiCameraValueError` will be raised.\n\n        If *format* is not ``None``, it must be a string specifying the format\n        that you want the video output in. The format can be a MIME-type or\n        one of the following strings:\n\n        * ``\'h264\'`` - Write an H.264 video stream\n        * ``\'mjpeg\'`` - Write an M-JPEG video stream\n        * ``\'yuv\'`` - Write the raw video data to a file in YUV420 format\n        * ``\'rgb\'`` - Write the raw video data to a file in 24-bit RGB format\n        * ``\'rgba\'`` - Write the raw video data to a file in 32-bit RGBA format\n        * ``\'bgr\'`` - Write the raw video data to a file in 24-bit BGR format\n        * ``\'bgra\'`` - Write the raw video data to a file in 32-bit BGRA format\n\n        If *resize* is not ``None`` (the default), it must be a two-element\n        tuple specifying the width and height that the video recording should\n        be resized to. This is particularly useful for recording video using\n        the full resolution of the camera sensor (which is not possible in\n        H.264 without down-sizing the output).\n\n        The *splitter_port* parameter specifies the port of the built-in\n        splitter that the video encoder will be attached to. This defaults to\n        ``1`` and most users will have no need to specify anything different.\n        If you wish to record multiple (presumably resized) streams\n        simultaneously, specify a value between ``0`` and ``3`` inclusive for\n        this parameter, ensuring that you do not specify a port that is\n        currently in use.\n\n        Certain formats accept additional options which can be specified\n        as keyword arguments. The ``\'h264\'`` format accepts the following\n        additional options:\n\n        * *profile* - The H.264 profile to use for encoding. Defaults to\n          \'high\', but can be one of \'baseline\', \'main\', \'extended\', \'high\', or\n          \'constrained\'.\n\n        * *level* - The `H.264 level`_ to use for encoding. Defaults to \'4\',\n          but can be any H.264 level up to \'4.2\'.\n\n        * *intra_period* - The key frame rate (the rate at which I-frames are\n          inserted in the output). Defaults to ``None``, but can be any 32-bit\n          integer value representing the number of frames between successive\n          I-frames. The special value 0 causes the encoder to produce a single\n          initial I-frame, and then only P-frames subsequently. Note that\n          :meth:`split_recording` will fail in this mode.\n\n        * *intra_refresh* - The key frame format (the way in which I-frames\n          will be inserted into the output stream). Defaults to ``None``, but\n          can be one of \'cyclic\', \'adaptive\', \'both\', or \'cyclicrows\'.\n\n        * *inline_headers* - When ``True``, specifies that the encoder should\n          output SPS/PPS headers within the stream to ensure GOPs (groups of\n          pictures) are self describing. This is important for streaming\n          applications where the client may wish to seek within the stream, and\n          enables the use of :meth:`split_recording`. Defaults to ``True`` if\n          not specified.\n\n        * *sei* - When ``True``, specifies the encoder should include\n          "Supplemental Enhancement Information" within the output stream.\n          Defaults to ``False`` if not specified.\n\n        * *sps_timing* - When ``True`` the encoder includes the camera\'s\n          framerate in the SPS header. Defaults to ``False`` if not specified.\n\n        * *motion_output* - Indicates the output destination for motion vector\n          estimation data. When ``None`` (the default), motion data is not\n          output. Otherwise, this can be a filename string, a file-like object,\n          or a writeable buffer object (as with the *output* parameter).\n\n        All encoded formats accept the following additional options:\n\n        * *bitrate* - The bitrate at which video will be encoded. Defaults to\n          17000000 (17Mbps) if not specified. The maximum value depends on the\n          selected `H.264 level`_ and profile. Bitrate 0 indicates the encoder\n          should not use bitrate control (the encoder is limited by the quality\n          only).\n\n        * *quality* - Specifies the quality that the encoder should attempt\n          to maintain. For the ``\'h264\'`` format, use values between 10 and 40\n          where 10 is extremely high quality, and 40 is extremely low (20-25 is\n          usually a reasonable range for H.264 encoding). For the ``mjpeg``\n          format, use JPEG quality values between 1 and 100 (where higher\n          values are higher quality). Quality 0 is special and seems to be\n          a "reasonable quality" default.\n\n        * *quantization* - Deprecated alias for *quality*.\n\n        .. versionchanged:: 1.0\n            The *resize* parameter was added, and ``\'mjpeg\'`` was added as a\n            recording format\n\n        .. versionchanged:: 1.3\n            The *splitter_port* parameter was added\n\n        .. versionchanged:: 1.5\n            The *quantization* parameter was deprecated in favor of *quality*,\n            and the *motion_output* parameter was added.\n\n        .. versionchanged:: 1.11\n            Support for buffer outputs was added.\n\n        .. _H.264 level: https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels\n        '
    if ('quantization' in options):
        warnings.warn(PiCameraDeprecated('The quantization option is deprecated; please use quality instead (same value)'))
    with self._encoders_lock:
        (camera_port, output_port) = self._get_ports(True, splitter_port)
        format = self._get_video_format(output, format)
        encoder = self._get_video_encoder(camera_port, output_port, format, resize, **options)
        self._encoders[splitter_port] = encoder
    try:
        encoder.start(output, options.get('motion_output'))
    except Exception as e:
        encoder.close()
        with self._encoders_lock:
            del self._encoders[splitter_port]
        raise