VideoGenerator[imagespec]
generates a video with frames generated from imagespec.
VideoGenerator[<|"Image"imagespec,"Audio"audiospec|>]
returns a video with audio data generated from audioexpr.
VideoGenerator[…,dur]
generates a video of duration dur.
VideoGenerator
VideoGenerator[imagespec]
generates a video with frames generated from imagespec.
VideoGenerator[<|"Image"imagespec,"Audio"audiospec|>]
returns a video with audio data generated from audioexpr.
VideoGenerator[…,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.
- The imagespec can be any of the following:
-
image uses image in the first track {image1,image2,…} uses the sequence of imagei in the first track manipulate a Manipulate or an AnimatedImage animation imagefunc a function imagefunc of time that creates one or multiple images - The audiospec can be any of the following:
-
audio uses audio in the first track {audio1,audio2,…} uses the sequence of audioi in the first track audiofunc a function audiofunc of time that creates a list or matrix of audio samples - The duration specification dur can be any of the following:
-
dur time 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[…]]. »
- The following options are supported:
-
AudioEncoding Automatic audio encoding to use BitRate Automatic approximate bit rate to use CompressionLevel Automatic compression level to use FrameRate 30 the frame rate to use GeneratedAssetFormat Automatic the file format of the result GeneratedAssetLocation $GeneratedAssetLocation the location of the result OverwriteTarget False whether to overwrite an existing file RasterSize Automatic the raster size used to rasterize expressions SampleRate Automatic the audio sample rate to use VideoEncoding Automatic video encoding to use VideoTransparency False whether the output video should have a transparency channel
Examples
open all close allBasic Examples (2)
Generate a video of a varying plot:
VideoGenerator[Plot[Sin[4 * # x], {x, 0, 10}]&]Generate video from rotating 3D graphics:
VideoGenerator[Graphics3D[GeometricTransformation[Icosahedron[], RotationTransform[2 π # / 10., {0, 0, 1}]], SphericalRegion -> True]&, 2π]Scope (8)
Video from Images (3)
Create a two-second-long video from a single image:
i = ResourceData["Sample Image: White Dog on a Beach"]v = VideoGenerator[i, Quantity[2, "Seconds"]]Specify the number of frames to generate:
i = ResourceData["Sample Image: White Dog on a Beach"];
v = VideoGenerator[i, Quantity[36, "Frames"]]Verify the number of frames in the result:
Import[Information[v, "ResourcePath"], "FrameCount"]Create a video from a list of images:
i = ResourceData["Sample Image: White Dog on a Beach"];
listOfImages = NestList[ImageApply[RotateLeft, #]&, i, 2]v = VideoGenerator[listOfImages]Show time series of frame color values:
VideoMapTimeSeries[Mean[#Image]&, v]//ListLinePlot[#, Rule[...]]&Video from a Function (3)
Create a video from a rotating image:
i = ResourceData["Sample Image: White Dog on a Beach"];dur = 3;
VideoGenerator[ImageRotate[i, 2π # / dur, Full, Masking -> Full, Padding -> "Fixed"]&, dur]Use a function that takes the time as input and rasterizes it to an image:
f[time_] := Rasterize[Round[time, .01], RasterSize -> 300];
VideoGenerator[f, 3]Use a function to generate two video tracks:
i = ResourceData["Sample Image: White Dog on a Beach"];
f[time_] := {Blur[i, 20 * time], ColorQuantize[i, Round[2 + 2 * time]]};
v = VideoGenerator[f]The function generates blurred frames in the first track with increasing radius:
VideoFrameList[Video[v, VideoTrackSelection -> 1], 3]The function generates quantized images with increasing colors in the second track:
VideoFrameList[Video[v, VideoTrackSelection -> 2], 3]Video with Audio (2)
Create a video with an audio track:
i = ResourceData["Sample Image: White Dog on a Beach"];
a = ExampleData[{"Audio", "PianoScale"}];v = VideoGenerator[<|"Image" -> i, "Audio" -> a|>, Duration[a]]Thumbnail /@ VideoFrameList[v, 2]AudioPlot[Audio[v]]Use functions to generate both the video and audio tracks:
i = ResourceData["Sample Image: White Dog on a Beach"];imageFunction[time_] := Blur[i, 20 * time];audioFunction[time_] := .5 * TriangleWave[300 time + 200 * time ^ 2];
v = VideoGenerator[<|"Image" -> imageFunction, "Audio" -> audioFunction|>]The image function takes the time as input and rasterizes it to an Image:
VideoFrameList[v, 3]The audio function takes the time as input and uses it to control the frequency of a triangle wave:
Spectrogram[Audio[v]]Options (13)
AudioEncoding (1)
Use the AudioEncoding option to specify the audio encoding to be used:
encoder = RandomChoice[$AudioEncoders["MP4"]]a = ExampleData[{"Audio", "PianoScale"}];v = VideoGenerator[<|"Image" -> ResourceData["Sample Image: White Dog on a Beach"], "Audio" -> a|>, Duration[a], AudioEncoding -> encoder[[1]]]Information[v, "AudioTracks"]BitRate (1)
CompressionLevel (1)
Use the CompressionLevel option to control the file size of the result:
i = ResourceData["Sample Image: White Dog on a Beach"];
videos = Table[VideoGenerator[i, CompressionLevel -> c], {c, 0, 1, .2}];Compare file sizes and the last frame quality for different compression levels:
Labeled[VideoExtractFrames[#, Quantity[-1, "Frames"]], FileSize[Information[#, "ResourcePath"]]]& /@ videosFrameRate (1)
The default frame rate is 30 frames per second:
Information[VideoGenerator[RandomImage[]], "VideoTracks"][[1, "FrameRate"]]Specify the frame rate to use:
i = ResourceData["Sample Image: White Dog on a Beach"];
video = VideoGenerator[i, FrameRate -> 15];Information[video, "VideoTracks"][[1, "FrameRate"]]GeneratedAssetFormat (1)
GeneratedAssetLocation (2)
Assets are automatically generated in the "Video" folder within $WolframDocumentsDirectory:
Information[VideoGenerator[RandomImage[]], "ResourcePath"]Specify the location of the asset created by VideoGenerator:
v = VideoGenerator[RandomImage[], GeneratedAssetLocation -> "file.mp4"];
Information[v, "ResourcePath"]Use a LocalObject as the asset for the resulting Video object:
v = VideoGenerator[RandomImage[], GeneratedAssetLocation -> LocalObject[]];
Information[v, "ResourcePath"]OverwriteTarget (1)
By default, if a file already exists it is not overwritten:
VideoGenerator[RandomImage[], GeneratedAssetLocation -> "file.mp4"]Overwrite an existing file by specifying OverwriteTargetTrue:
v = VideoGenerator[RandomImage[], GeneratedAssetLocation -> "file.mp4", OverwriteTarget -> True];
Information[v, "ResourcePath"]RasterSize (1)
By default, if the video tracks specification produces a Graphics object, the result is rasterized:
v = VideoGenerator[Graphics[Disk[]]];
Information[v, "VideoTracks"]Use the RasterSize option to control the rasterization:
v = VideoGenerator[Graphics[Disk[]], RasterSize -> {100, 100}];
Information[v, "VideoTracks"]If the video tracks specification produces an Image, specifying the RasterSize option will resize the result:
v = VideoGenerator[RandomImage[1, 400], RasterSize -> {100, 100}];
Information[v, "VideoTracks"]SampleRate (2)
By default, if the audio tracks specification is an Audio object, the sample rate will be preserved:
a = Audio["ExampleData/rule30.wav"];
AudioSampleRate[a]v = VideoGenerator[<|"Image" -> RandomImage[], "Audio" -> a|>];
Information[v, "AudioTracks"]Use the SampleRate option to resample the audio input:
v = VideoGenerator[<|"Image" -> RandomImage[], "Audio" -> a|>, SampleRate -> 16000];
Information[v, "AudioTracks"]If the audio tracks specification is a function, the default sample is
Hz:
v = VideoGenerator[<|"Image" -> RandomImage[], "Audio" -> (Sin[4000#]&)|>];
Information[v, "AudioTracks"]Use the SampleRate option to control the sample rate of the result:
v = VideoGenerator[<|"Image" -> RandomImage[], "Audio" -> (Sin[4000#]&)|>, SampleRate -> 16000];
Information[v, "AudioTracks"]VideoEncoding (1)
Use the VideoEncoding option to specify the video encoding to be used:
encoder = RandomChoice[$VideoEncoders["MP4"]]v = VideoGenerator[ResourceData["Sample Image: White Dog on a Beach"], VideoEncoding -> encoder[[1]]]Information[v, "VideoTracks"]VideoTransparency (1)
By default, an alpha channel in the generated frames is not preserved in the output:
v = VideoGenerator[Plot[Sin[4 * # x], {x, 0, 10}]&];Information[VideoExtractFrames[v, Quantity[1, "Frames"]], "Transparency"]Specify that an alpha channel in the generated frames should be preserved in the output:
v = VideoGenerator[Plot[Sin[4 * # x], {x, 0, 10}]&, VideoTransparency -> Automatic];Information[VideoExtractFrames[v, Quantity[1, "Frames"]], "Transparency"]Applications (6)
Create a video by adding a still image to an audio signal:
a = ExampleData[{"Audio", "Drums"}]v = VideoGenerator[<|"Image" -> ExampleData[{"TestImage", "Moon"}], "Audio" -> a|>, Duration[a]]Generate a video of rotating 3D graphics:
g = ExampleData[{"Geometry3D", "Cow"}][[1, 2]];VideoGenerator[Graphics3D[{EdgeForm[], GeometricTransformation[g, RotationTransform[360 / 5 # Degree, {0, 0, 1}]]}, SphericalRegion -> True, Boxed -> False]&, 5]Generate a video by moving the viewpoint around a 3D object:
bass = ExampleData[{"Geometry3D", "BassGuitar"}][[1]];Visualize the viewpoint trajectory:
trajectory[t_] := {1, 10Sin[2t], 4Cos[2t]}
ParametricPlot3D[trajectory[t], {t, 0, 5}]Generate the Video:
VideoGenerator[Rasterize@Graphics3D[bass, ViewPoint -> trajectory[#], PlotRange -> {{-25, 25}, {-25, 25}, {-20, 25}}]&, 5]//ParallelizeCreate a Video object displaying the evolution of a cellular automaton:
c = CellularAutomaton[30, {{1}, 0}, {{0, 200}}];
Image[c]VideoGenerator[Image@ArrayPad[c[[ ;; Round[1 + # * 100]]], {{0, 200 - Round[1 + # * 100]}, 0}]&, 2]Create a Video object displaying a ball bouncing down steps.
First, solve the differential equation governing the motion of the ball:
ballsteps = NDSolve[{x''[t] == 0, y''[t] == -9.8, y[0] == 6, y'[0] == 0, x[0] == 0, x'[0] == 1, a[0] == 5, WhenEvent[Mod[x[t], 1] == 0, If[a[t] > 0, a[t] -> a[t] - 1, "RemoveEvent"]], WhenEvent[y[t] == a[t], {x'[t], y'[t]} -> .9{x'[t], -y'[t]}]}, {x, y, a}, {t, 0, 15}, DiscreteVariables -> {a}];
trajectory = {x[t], y[t]} /. ballsteps[[1]]Precompute a "staircase" background:
staircase = Plot[Clip[Floor[6 - x], {0, Infinity}], {x, -1, 15}, Filling -> 0, Exclusions -> None]Display the evolution of the ball's position over the staircase:
VideoGenerator[Show[Graphics[{Red, Disk[trajectory /. t -> #, .2]}, PlotRange -> {{-1, 10}, {0, 7}}], staircase]&, 15, FrameRate -> 15]Create a video showing the travel directions from Champaign to Chicago:
td = TravelDirections[{Entity["City", {"Champaign", "Illinois", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}]}]Extract the points forming the path:
points = Join@@td["TravelPath"][[1]]["LatitudeLongitude"];
points//ShortVideoGenerator[
With[{i = Max[1, Round[# * Length[points] / 10]]}, GeoGraphics[{PointSize[Large], Red, Point@GeoPosition@points[[i]], Black, GeoPath[points[[Max[1, i - 400] ;; i]]]}, RasterSize -> {500, 500}]]&, 10, FrameRate -> 10]Properties & Relations (3)
Parallelize an expensive frame generation to speed up the computation:
disk[time_] := Graphics[Disk[{0, 0}, .1 + time], PlotRange -> {{-1, 1}, {-1, 1}}]VideoGenerator[disk];//AbsoluteTimingParallelize[VideoGenerator[disk]];//AbsoluteTimingUse Animate to create an animation in a notebook:
Animate[Plot[Sin[x + a], {x, 0, 10}], {a, 0, 5}, AnimationRunning -> False]VideoGenerator can achieve the same results but without displaying any controls:
VideoGenerator[Plot[Sin[x + #], {x, 0, 10}]&, 5]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:
v = VideoGenerator[Plot[Sin[x + #], {x, 0, 10}]&, 5]a = AudioGenerator[TriangleWave[200#]&, 5]Combine the two using VideoCombine:
VideoCombine[{v, a}]Possible Issues (1)
Parallelize an expensive frame generation to speed up the computation:
disk[time_] := Graphics[Disk[{0, 0}, time], ImageSize -> {700, 700}]VideoGenerator[disk];//AbsoluteTimingParallelize[VideoGenerator[disk]];//AbsoluteTimingParallelization does not benefit functions that are already fast and multi-threaded:
image[time_] := RandomImage[]VideoGenerator[image, 4];//AbsoluteTimingParallelize[VideoGenerator[image, 4]];//AbsoluteTimingRelated Guides
Text
Wolfram Research (2020), VideoGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/VideoGenerator.html (updated 2021).
CMS
Wolfram Language. 2020. "VideoGenerator." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. 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_2026_videogenerator, author="Wolfram Research", title="{VideoGenerator}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/VideoGenerator.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_videogenerator, organization={Wolfram Research}, title={VideoGenerator}, year={2021}, url={https://reference.wolfram.com/language/ref/VideoGenerator.html}, note=[Accessed: 13-June-2026]}