VideoGenerator

VideoGenerator[model]

generates one second of video of a given model.

VideoGenerator[model,dur]

generates a video of duration dur.

Details and Options

  • VideoGenerator can be used to generate video objects algorithmically. It is typically used for creating video of a time-varying plot, a rotating 3D object, etc.
  • Possible settings for model include:
  • imagespecmodel to create images for the video track
    <|"Image"imagespec,"Audio"audiospec|>models to create images and audio samples for video and audio tracks
  • The imagespec can be any of the following:
  • imageuses image in the first track
    {image1,image2,}uses the sequence of imagei in the first track
    {{im11,im12,},{im21,im22,},}uses the sequence of {imi1,imi2,} in the ^(th) track
    imagefunca function imagefunc of time that creates one or multiple images
  • If imagefunc returns a list of images, the image at position i is assumed to be the frame for the ^(th) video track.
  • The audiospec can be any of the following:
  • audiouses audio in the first track
    {audio1,audio2,}uses the sequence of audioi in the first track
    {{a11,a12,},{a21,a22,},}uses the sequence of {ai1,ai2,} in the ^(th) track
    audiofunca function audiofunc of time that creates a list or matrix of audio samples
  • If audiofunc returns a matrix of audio values, the list at position i is assumed to be the data for the ^(th) audio track.
  • The duration specification dur can be any of the following:
  • durtime given in seconds
    Quantity[dur,"Seconds"]time given in seconds or any compatible unit
    Quantity[n,"Frames"]time given as a number of frames
  • To generate frames in parallel, use Parallelize[VideoGenerator[]]. »
  • By default, VideoGenerator places the new video under the "Video" directory in $WolframDocumentsDirectory.
  • The following options are supported:
  • AudioEncoding Automaticaudio encoding to use
    BitRateAutomaticapproximate bit rate to use
    CompressionLevel Automaticcompression level to use
    FrameRate 30the frame rate to use
    GeneratedAssetFormatAutomaticthe file format of the result
    GeneratedAssetLocation $GeneratedAssetLocationthe location of the result
    OverwriteTarget Falsewhether to overwrite an existing file
    RasterSize Automaticthe raster size used to rasterize expressions
    SampleRate Automaticthe audio sample rate to use
    VideoEncoding Automaticvideo encoding to use
    VideoTransparencyFalsewhether the output video should have a transparency channel

Examples

open allclose all

Basic Examples  (2)

Generate a video of a varying plot:

Generate video from rotating 3D graphics:

Scope  (8)

Video from Images  (3)

Create a two-second-long video from a single image:

Specify the number of frames to generate:

Verify the number of frames in the result:

Create a video from a list of images:

Show time series of frame color values:

Video from a Function  (3)

Create a video from a rotating image:

Show a few frames of the generated video:

Use a function to generate frames:

The function takes the time as input and rasterizes it to an Image:

Use a function to generate two video tracks:

The function generates blurred frames in the first track with increasing radius:

The function generates quantized images with increasing colors in the second track:

Video with Audio  (2)

Create a video with an audio track:

The image function takes the time as input and outputs an Image:

The audio function takes the time as input and uses it to control the frequency of a triangle wave:

Options  (10)

AudioEncoding  (1)

Use the AudioEncoding option to specify the audio encoding to be used:

CompressionLevel  (1)

Use the CompressionLevel option to control the file size of the result:

Compare file sizes using different compression levels:

FrameRate  (1)

The default frame rate is 30 frames per second:

Specify the frame rate to use:

GeneratedAssetLocation  (2)

Assets are automatically generated in the "Video" folder within $WolframDocumentsDirectory:

Specify the location of the asset created by VideoGenerator:

Use a LocalObject as the asset for the resulting Video object:

OverwriteTarget  (1)

By default, if a file already exists it is not overwritten:

Overwrite an existing file by specifying OverwriteTargetTrue:

RasterSize  (1)

By default, if the video tracks specification produces a Graphics object, the result is rasterized:

Use the RasterSize option to control the rasterization:

If the video tracks specification produces an Image, specifying the RasterSize option will resize the result:

SampleRate  (2)

By default, if the audio tracks specification is an Audio object, the sample rate will be preserved:

Use the SampleRate option to resample the audio input:

If the audio tracks specification is a function, the default sample is Hz:

Use the SampleRate option to control the sample rate of the result:

VideoEncoding  (1)

Use the VideoEncoding option to specify the video encoding to be used:

Applications  (6)

Create a video by adding a still image to an audio signal:

Generate a video of rotating 3D graphics:

Generate a video by moving the viewpoint around a 3D object:

Visualize the viewpoint trajectory:

Generate the Video:

Create a Video object displaying the evolution of a cellular automaton:

Create a Video object displaying a ball bouncing down steps.

First, solve the differential equation governing the motion of the ball:

Precompute a "staircase" background:

Display the evolution of the ball's position over the staircase:

Create a video showing the travel directions from Champaign to Chicago:

Extract the points forming the path:

Create the video:

Properties & Relations  (3)

Parallelize an expensive frame generation to speed up the computation:

Use Animate to create an animation in a notebook:

VideoGenerator can achieve the same results but without displaying any controls:

The result is also more easily shareable outside a notebook, since it creates a video file.

Separately generated video and audio objects can be combined using VideoCombine.

Generate a video with no audio:

Generate an audio sample:

Combine the two using VideoCombine:

Possible Issues  (1)

Parallelize an expensive frame generation to speed up the computation:

Parallelization does not benefit functions that are already fast and multi-threaded:

Wolfram Research (2020), VideoGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/VideoGenerator.html (updated 2022).

Text

Wolfram Research (2020), VideoGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/VideoGenerator.html (updated 2022).

CMS

Wolfram Language. 2020. "VideoGenerator." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/VideoGenerator.html.

APA

Wolfram Language. (2020). VideoGenerator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VideoGenerator.html

BibTeX

@misc{reference.wolfram_2023_videogenerator, author="Wolfram Research", title="{VideoGenerator}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/VideoGenerator.html}", note=[Accessed: 19-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_videogenerator, organization={Wolfram Research}, title={VideoGenerator}, year={2022}, url={https://reference.wolfram.com/language/ref/VideoGenerator.html}, note=[Accessed: 19-April-2024 ]}