Video Output Types - The Sage Command Line

Skip to content
Back to top
View this page
Edit this page

# Video Output Types

This module defines the rich output types for video formats.

class sage.repl.rich_output.output_video.OutputVideoAvi(video, loop=True)

  Bases: `OutputVideoBase`

  AVI video.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoAvi
      sage: OutputVideoAvi.example()
      OutputVideoAvi container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoAvi
      >>> OutputVideoAvi.example()
      OutputVideoAvi container

  ext = '.avi'
  mimetype = 'video/x-msvideo'

class sage.repl.rich_output.output_video.OutputVideoBase(video, loop=True)

  Bases: `OutputBase`

  Abstract base class for rich video output.

  INPUT:

  - `video` – `OutputBuffer`; the video data

  - `loop` – boolean; whether to repeat the video in an endless loop

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoOgg
      sage: OutputVideoOgg.example()  # indirect doctest
      OutputVideoOgg container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoOgg
      >>> OutputVideoOgg.example()  # indirect doctest
      OutputVideoOgg container

  classmethod example()

    Construct a sample video output container.

    This static method is meant for doctests, so they can easily construct an example. The method is implemented in the abstract `OutputVideoBase` class, but should get invoked on a concrete subclass for which an actual example can exist.

    OUTPUT: an instance of the class on which this method is called

    EXAMPLES:

    Sage

        sage: from sage.repl.rich_output.output_catalog import OutputVideoOgg
        sage: OutputVideoOgg.example()
        OutputVideoOgg container
        sage: OutputVideoOgg.example().video
        buffer containing 5612 bytes
        sage: OutputVideoOgg.example().ext
        '.ogv'
        sage: OutputVideoOgg.example().mimetype
        'video/ogg'

    Python

        >>> from sage.all import *
        >>> from sage.repl.rich_output.output_catalog import OutputVideoOgg
        >>> OutputVideoOgg.example()
        OutputVideoOgg container
        >>> OutputVideoOgg.example().video
        buffer containing 5612 bytes
        >>> OutputVideoOgg.example().ext
        '.ogv'
        >>> OutputVideoOgg.example().mimetype
        'video/ogg'

  html_fragment(url, link_attrs='')

    Construct a HTML fragment for embedding this video.

    INPUT:

    - `url` – string; the URL where the data of this video can be found

    - `link_attrs` – string; can be used to style the fallback link which is presented to the user if the video is not supported

    EXAMPLES:

    Sage

        sage: from sage.repl.rich_output.output_catalog import OutputVideoOgg
        sage: print(OutputVideoOgg.example().html_fragment
        ....:       ('foo', 'class="bar"').replace('><','>\n<'))
        <video autoplay="autoplay" controls="controls" loop="loop">
        <source src="foo" type="video/ogg" />
        <p>
        <a target="_new" href="foo" class="bar">Download video/ogg video</a>
        </p>
        </video>

    Python

        >>> from sage.all import *
        >>> from sage.repl.rich_output.output_catalog import OutputVideoOgg
        >>> print(OutputVideoOgg.example().html_fragment
        ...       ('foo', 'class="bar"').replace('><','>\n<'))
        <video autoplay="autoplay" controls="controls" loop="loop">
        <source src="foo" type="video/ogg" />
        <p>
        <a target="_new" href="foo" class="bar">Download video/ogg video</a>
        </p>
        </video>

class sage.repl.rich_output.output_video.OutputVideoFlash(video, loop=True)

  Bases: `OutputVideoBase`

  Flash video.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoFlash
      sage: OutputVideoFlash.example()
      OutputVideoFlash container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoFlash
      >>> OutputVideoFlash.example()
      OutputVideoFlash container

  ext = '.flv'
  mimetype = 'video/x-flv'

class sage.repl.rich_output.output_video.OutputVideoMatroska(video, loop=True)

  Bases: `OutputVideoBase`

  Matroska Video.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoMatroska
      sage: OutputVideoMatroska.example()
      OutputVideoMatroska container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoMatroska
      >>> OutputVideoMatroska.example()
      OutputVideoMatroska container

  ext = '.mkv'
  mimetype = 'video/x-matroska'

class sage.repl.rich_output.output_video.OutputVideoMp4(video, loop=True)

  Bases: `OutputVideoBase`

  MPEG 4 video.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoMp4
      sage: OutputVideoMp4.example()
      OutputVideoMp4 container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoMp4
      >>> OutputVideoMp4.example()
      OutputVideoMp4 container

  ext = '.mp4'
  mimetype = 'video/mp4'

class sage.repl.rich_output.output_video.OutputVideoOgg(video, loop=True)

  Bases: `OutputVideoBase`

  Ogg video, Ogg Theora in particular.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoOgg
      sage: OutputVideoOgg.example()
      OutputVideoOgg container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoOgg
      >>> OutputVideoOgg.example()
      OutputVideoOgg container

  ext = '.ogv'
  mimetype = 'video/ogg'

class sage.repl.rich_output.output_video.OutputVideoQuicktime(video, loop=True)

  Bases: `OutputVideoBase`

  Quicktime video.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoQuicktime
      sage: OutputVideoQuicktime.example()
      OutputVideoQuicktime container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoQuicktime
      >>> OutputVideoQuicktime.example()
      OutputVideoQuicktime container

  ext = '.mov'
  mimetype = 'video/quicktime'

class sage.repl.rich_output.output_video.OutputVideoWebM(video, loop=True)

  Bases: `OutputVideoBase`

  WebM video.

  The video can be encoded using VP8, VP9 or an even more recent codec.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoWebM
      sage: OutputVideoWebM.example()
      OutputVideoWebM container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoWebM
      >>> OutputVideoWebM.example()
      OutputVideoWebM container

  ext = '.webm'
  mimetype = 'video/webm'

class sage.repl.rich_output.output_video.OutputVideoWmv(video, loop=True)

  Bases: `OutputVideoBase`

  Windows Media Video.

  EXAMPLES:

  Sage

      sage: from sage.repl.rich_output.output_catalog import OutputVideoWmv
      sage: OutputVideoWmv.example()
      OutputVideoWmv container

  Python

      >>> from sage.all import *
      >>> from sage.repl.rich_output.output_catalog import OutputVideoWmv
      >>> OutputVideoWmv.example()
      OutputVideoWmv container

  ext = '.wmv'
  mimetype = 'video/x-ms-wmv'