def record_sequence(self, outputs, format='h264', resize=None, splitter_port=1, **options):
    "\n        Record a sequence of video clips from the camera.\n\n        This method accepts a sequence or iterator of *outputs* each of which\n        must either be a string specifying a filename for output, or a\n        file-like object with a ``write`` method.\n\n        The method acts as an iterator itself, yielding each item of the\n        sequence in turn. In this way, the caller can control how long to\n        record to each item by only permitting the loop to continue when ready\n        to switch to the next output.\n\n        The *format*, *splitter_port*, *resize*, and *options* parameters are\n        the same as in :meth:`start_recording`, but *format* defaults to\n        ``'h264'``.  The format is **not** derived from the filenames in\n        *outputs* by this method.\n\n        For example, to record 3 consecutive 10-second video clips, writing the\n        output to a series of H.264 files named clip01.h264, clip02.h264, and\n        clip03.h264 one could use the following::\n\n            import picamera\n            with picamera.PiCamera() as camera:\n                for filename in camera.record_sequence([\n                        'clip01.h264',\n                        'clip02.h264',\n                        'clip03.h264']):\n                    print('Recording to %s' % filename)\n                    camera.wait_recording(10)\n\n        Alternatively, a more flexible method of writing the previous example\n        (which is easier to expand to a large number of output files) is by\n        using a generator expression as the input sequence::\n\n            import picamera\n            with picamera.PiCamera() as camera:\n                for filename in camera.record_sequence(\n                        'clip%02d.h264' % i for i in range(3)):\n                    print('Recording to %s' % filename)\n                    camera.wait_recording(10)\n\n        More advanced techniques are also possible by utilising infinite\n        sequences, such as those generated by :func:`itertools.cycle`. In the\n        following example, recording is switched between two in-memory streams.\n        Whilst one stream is recording, the other is being analysed. The script\n        only stops recording when a video recording meets some criteria defined\n        by the ``process`` function::\n\n            import io\n            import itertools\n            import picamera\n            with picamera.PiCamera() as camera:\n                analyse = None\n                for stream in camera.record_sequence(\n                        itertools.cycle((io.BytesIO(), io.BytesIO()))):\n                    if analyse is not None:\n                        if process(analyse):\n                            break\n                        analyse.seek(0)\n                        analyse.truncate()\n                    camera.wait_recording(5)\n                    analyse = stream\n\n        .. versionadded:: 1.3\n        "
    with self._encoders_lock:
        (camera_port, output_port) = self._get_ports(True, splitter_port)
        format = self._get_video_format('', format)
        encoder = self._get_video_encoder(camera_port, output_port, format, resize, **options)
        self._encoders[splitter_port] = encoder
    try:
        start = True
        for output in outputs:
            if start:
                start = False
                encoder.start(output, options.get('motion_output'))
            else:
                encoder.split(output)
            (yield output)
    finally:
        try:
            encoder.wait(0)
        finally:
            encoder.close()
            with self._encoders_lock:
                del self._encoders[splitter_port]
Record a sequence of video clips from the camera.

This method accepts a sequence or iterator of *outputs* each of which
must either be a string specifying a filename for output, or a
file-like object with a ``write`` method.

The method acts as an iterator itself, yielding each item of the
sequence in turn. In this way, the caller can control how long to
record to each item by only permitting the loop to continue when ready
to switch to the next output.

The *format*, *splitter_port*, *resize*, and *options* parameters are
the same as in :meth:`start_recording`, but *format* defaults to
``'h264'``.  The format is **not** derived from the filenames in
*outputs* by this method.

For example, to record 3 consecutive 10-second video clips, writing the
output to a series of H.264 files named clip01.h264, clip02.h264, and
clip03.h264 one could use the following::

    import picamera
    with picamera.PiCamera() as camera:
        for filename in camera.record_sequence([
                'clip01.h264',
                'clip02.h264',
                'clip03.h264']):
            print('Recording to %s' % filename)
            camera.wait_recording(10)

Alternatively, a more flexible method of writing the previous example
(which is easier to expand to a large number of output files) is by
using a generator expression as the input sequence::

    import picamera
    with picamera.PiCamera() as camera:
        for filename in camera.record_sequence(
                'clip%02d.h264' % i for i in range(3)):
            print('Recording to %s' % filename)
            camera.wait_recording(10)

More advanced techniques are also possible by utilising infinite
sequences, such as those generated by :func:`itertools.cycle`. In the
following example, recording is switched between two in-memory streams.
Whilst one stream is recording, the other is being analysed. The script
only stops recording when a video recording meets some criteria defined
by the ``process`` function::

    import io
    import itertools
    import picamera
    with picamera.PiCamera() as camera:
        analyse = None
        for stream in camera.record_sequence(
                itertools.cycle((io.BytesIO(), io.BytesIO()))):
            if analyse is not None:
                if process(analyse):
                    break
                analyse.seek(0)
                analyse.truncate()
            camera.wait_recording(5)
            analyse = stream

.. versionadded:: 1.3
def record_sequence(self, outputs, format='h264', resize=None, splitter_port=1, **options):
    "\n        Record a sequence of video clips from the camera.\n\n        This method accepts a sequence or iterator of *outputs* each of which\n        must either be a string specifying a filename for output, or a\n        file-like object with a ``write`` method.\n\n        The method acts as an iterator itself, yielding each item of the\n        sequence in turn. In this way, the caller can control how long to\n        record to each item by only permitting the loop to continue when ready\n        to switch to the next output.\n\n        The *format*, *splitter_port*, *resize*, and *options* parameters are\n        the same as in :meth:`start_recording`, but *format* defaults to\n        ``'h264'``.  The format is **not** derived from the filenames in\n        *outputs* by this method.\n\n        For example, to record 3 consecutive 10-second video clips, writing the\n        output to a series of H.264 files named clip01.h264, clip02.h264, and\n        clip03.h264 one could use the following::\n\n            import picamera\n            with picamera.PiCamera() as camera:\n                for filename in camera.record_sequence([\n                        'clip01.h264',\n                        'clip02.h264',\n                        'clip03.h264']):\n                    print('Recording to %s' % filename)\n                    camera.wait_recording(10)\n\n        Alternatively, a more flexible method of writing the previous example\n        (which is easier to expand to a large number of output files) is by\n        using a generator expression as the input sequence::\n\n            import picamera\n            with picamera.PiCamera() as camera:\n                for filename in camera.record_sequence(\n                        'clip%02d.h264' % i for i in range(3)):\n                    print('Recording to %s' % filename)\n                    camera.wait_recording(10)\n\n        More advanced techniques are also possible by utilising infinite\n        sequences, such as those generated by :func:`itertools.cycle`. In the\n        following example, recording is switched between two in-memory streams.\n        Whilst one stream is recording, the other is being analysed. The script\n        only stops recording when a video recording meets some criteria defined\n        by the ``process`` function::\n\n            import io\n            import itertools\n            import picamera\n            with picamera.PiCamera() as camera:\n                analyse = None\n                for stream in camera.record_sequence(\n                        itertools.cycle((io.BytesIO(), io.BytesIO()))):\n                    if analyse is not None:\n                        if process(analyse):\n                            break\n                        analyse.seek(0)\n                        analyse.truncate()\n                    camera.wait_recording(5)\n                    analyse = stream\n\n        .. versionadded:: 1.3\n        "
    with self._encoders_lock:
        (camera_port, output_port) = self._get_ports(True, splitter_port)
        format = self._get_video_format(, format)
        encoder = self._get_video_encoder(camera_port, output_port, format, resize, **options)
        self._encoders[splitter_port] = encoder
    try:
        start = True
        for output in outputs:
            if start:
                start = False
                encoder.start(output, options.get('motion_output'))
            else:
                encoder.split(output)
            (yield output)
    finally:
        try:
            encoder.wait(0)
        finally:
            encoder.close()
            with self._encoders_lock:
                del self._encoders[splitter_port]