Ogg (.ogg, .ogv, .ogx, .ogm)

Background & Context

    • Registered MIME type: video/ogg
    • Multimedia container format.
    • Can contain multiple video and audio tracks.
    • Designed to be used for efficient streaming.
    • Supports a variety of video and audio codecs.
    • Developed and maintained by Xiph.Org Foundation.

Import & Export

  • Import["file.ogg"] imports an Ogg file and returns a Video object.
  • Import["file.ogg",elem] imports the specified elements.
  • The import format can be specified with Import["file","Ogg"] or Import["file",{"Ogg",elem,}].
  • Export["file.ogg",expr] exports a Video object, list of graphics or images, or a Manipulate expression to the Ogg format.
  • Export["file.ogg",expr,"Ogg"] can also be used to export to an Ogg file.
  • Export["file.ogg",{expr1,expr2,}] exports a list of arbitrary expressions to Ogg.
  • When exporting a list {expr1,expr2,}, the video is composed from still pictures corresponding to rasterized images of the expri.
  • The duration of the Ogg video is determined from the number of frames and the specified frame rate.
  • The exported Ogg video will play at the same speed and will have the same size as the Manipulate object.
  • If bookmarks are set in the Manipulate object, Export will create an Ogg file by interpolating between the bookmarks while preserving the speed and duration of the Manipulate.
  • Export["file.ogg",{elem1expr1,elem2expr2,}],"Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the Ogg format.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Video representation elements:
  • "ImageList"frames represented as a list of images
    "Video"video file represented as a Video object
    "VideoData"array of raw bitmap data for each frame
    "VideoStream"a handle to the video file as a VideoStream object
  • Import by default uses the "Video" element for the Ogg format.
  • A video file may contain multiple video, audio or subtitle tracks. Elements that return the number of tracks:
  • "AudioTrackCount"number of audio tracks
    "VideoTrackCount"number of video tracks
  • Video metadata elements:
  • "BitDepth"bits used to represent each color channel in the file
    "ColorSpace"color encoding used in the file
    "FrameCount"number of frames in the file
    "FrameDurations"list of display durations given for each frame
    "FrameRate"number of frames to be displayed per second
    "RasterSize"raster dimensions
    "VideoEncoding"video codec used in the file
  • Audio-related elements:
  • "Audio"in-core Audio object
    "AudioChannels"number of audio channels
    "AudioData"array of audio samples
    "AudioEncoding"audio codec used in the file
    "AudioFile"out-of-core Audio object
    "BitRate"number of bits per second
    "SampleRate"number of audio samples per second
  • Additional metadata elements:
  • "ExactDurations"an association of exact durations for all video, audio and subtitle tracks
    "Duration"approximate duration of the video given in seconds
    "MetaInformation"metadata interpreted as quantities, locations, dates, numbers, etc.
    "RawMetaInformation"uninterpreted metadata as strings and numbers
  • $VideoDecoders and $AudioDecoders give a list of decoders available on your computer system.

Options

Examples

open allclose all

Basic Examples  (3)

Import an Ogg file as a Video object:

Import a video property such as duration:

Import a summary of a video file:

Export an animation to Ogg:

Get three frames from the video:

Scope  (3)

Import a list of video frames:

Import the first 10 seconds of audio data:

Export a Manipulate to Ogg:

Get some frames from the video:

Import Elements  (28)

Generate a Multitrack Ogg File  (1)

Generate a multitrack Ogg file:

Available Elements  (1)

List of available elements:

Video Elements  (3)

"Video"  (1)

Import as a Video object:

This is the default import element:

"VideoData"  (1)

Import video data corresponding to specified frames:

Convert video data stored in a NumericArray object to an image:

"VideoStream"  (1)

Import as a VideoStream object:

Play the video stream:

Get the current frame from the stream:

Number of Tracks  (2)

"AudioTrackCount"  (1)

Import the number of audio tracks:

"VideoTrackCount"  (1)

Import the number of video tracks:

Metadata Elements  (7)

"Duration"  (2)

Import approximate duration of the video:

To import exact track durations, use the "ExactDurations" element:

"ExactDurations"  (2)

Import exact track durations:

Import the approximate duration of the video:

Computing an approximate duration is typically much faster than exact durations:

"MetaInformation"  (1)

Import metadata from a video file:

"RawMetaInformation"  (1)

Import unprocessed metadata from a video file:

"Summary"  (1)

Import a summary of a video file:

Video Tracks  (7)

"BitDepth"  (1)

Import the bit depth:

"ColorSpace"  (1)

Import the color space:

"FrameCount"  (1)

Import the number of video frames:

"FrameDurations"  (1)

Import the duration of selected video frames:

"FrameRate"  (1)

Import a video frame rate:

"RasterSize"  (1)

Import the raster size of video frames:

"VideoEncoding"  (1)

Import video codec:

Supported decoders on each platform can be extracted using $VideoDecoders:

Audio Tracks  (7)

"Audio"  (1)

Import Audio from an Ogg file:

"AudioChannels"  (1)

Import the number of audio channels:

"AudioData"  (1)

Import audio data from an Ogg file as a NumericArray:

Convert audio data stored to an Audio object:

"AudioEncoding"  (1)

Import audio encoding:

Available audio decoders can be extracted from $AudioDecoders:

"AudioFile"  (1)

Import the out-of-core Audio object:

Note that out-of-core Audio does not hold data in memory. Compare with in-core Audio:

"BitRate"  (1)

Get the bit rate of an audio track:

"SampleRate"  (1)

Get the sample rate of an audio track:

Import Options  (7)

Generate a Multitrack Ogg File  (1)

Generate a multitrack Ogg file:

"AudioChannels"  (1)

By default, all audio channels are imported:

Import the second channel only:

AudioTracks  (1)

By default, Import extracts data only from the first audio track:

Use the AudioTracks option to extract data from specified audio tracks:

"ImageTopOrientation"  (1)

By default, video frames are imported with the native orientation stored in the file:

Specify the side that is supposed to be on the top:

RasterSize  (1)

By default, video frames are imported in their native size:

Specify the raster size of each video frame:

SampleRate  (1)

By default, video frames are imported in their native size:

Specify the sample rate of the imported sound:

VideoTracks  (1)

By default, Import extracts data only from the first video track:

Use the VideoTracks option to extract data from specified video tracks:

Export Options  (11)

"AnimationDuration"  (1)

Specify the duration of exported Manipulate expressions:

AudioEncoding  (1)

Specify the encoding of exported audio:

AudioTracks  (1)

By default, all audio tracks are exported:

Specify the audio tracks to export:

Export no audio track:

Background  (1)

By default, a white background is used for transparent graphics and images and also when images of different sizes are padded before export:

Specify a different padding:

CompresionLevel  (1)

Use the CompressionLevel option to control the file size and the quality of a generated video:

"ControlAppearance"  (1)

An animation exported with the default setting "ControlAppearance""Generic" will look the same regardless of the computer system on which it was created:

With "ControlAppearance"None, no user controls are included in the exported video:

FrameRate  (1)

By default, the frame rate is preserved when exporting Video or VideoStream objects:

Specify a different frame rate:

RasterSize  (1)

By default, the raster size is preserved when exporting Video or VideoStream objects:

Specify a different raster size:

SampleRate  (1)

By default, the sample rate is preserved when exporting Video, VideoStream or Audio objects:

Specify a different sample rate:

VideoEncoding  (1)

Specify the encoding of exported video:

VideoTracks  (1)

By default, all video tracks are exported:

Specify the video tracks to export:

Export no video tracks:

Introduced in 2020
 (12.1)