VideoTimeStretch[video,spec]
applies time stretching to video using the specified spec.
VideoTimeStretch
VideoTimeStretch[video,spec]
applies time stretching to video using the specified spec.
Details and Options
- VideoTimeStretch can be used to change the speed of a video or parts of a video to create slower or faster video.
- Time stretch specification spec can be any of the following:
-
r uniformly stretch with a ratio r {{t11,t12}r1,…} stretch ratio ri for the time interval {t11,t12} func an arbitrary function func - VideoTimeStretch processes only the video tracks, dropping all audio and subtitle tracks.
- By default, VideoTimeStretch places the new video under the "Video" directory in $WolframDocumentsDirectory.
- The following options are supported:
-
CompressionLevel Automatic compression level to use GeneratedAssetFormat Automatic the format of the result GeneratedAssetLocation $GeneratedAssetLocation the location of the result OverwriteTarget False whether to overwrite an existing file VideoEncoding Automatic video encoding to use VideoTransparency False whether the output video should have a transparency channel
Examples
open all close allBasic Examples (2)
Slow down a video by a factor of 2:
v = Video["ExampleData/fish.mp4"];
Duration[v]VideoTimeStretch[v, 2]
Duration[%]VideoTimeStretch[v, 1 / 2]
Duration[%]Slow down just a portion of a video:
v = Video["ExampleData/fish.mp4"];
VideoTimeStretch[v, {1, 2} -> 2]Scope (3)
(v = VideoGenerator[ConstantImage[Hue[#]]&])//IconizedObject[«plot»]VideoTimeStretch[v, 3]//IconizedObject[«plot»]Stretch only a specified time segment:
(v = VideoGenerator[ConstantImage[Hue[#]]&])//IconizedObject[«plot»]VideoTimeStretch[v, {.3, .7} -> 3]//IconizedObject[«plot»]Plot the stretch function over the duration of the input video:
Plot[Piecewise[{{3, 0.3 < x < 0.7}}, 1], {x, 0, 1}, PlotRange -> {0, 3}]Applications (1)
Properties & Relations (3)
Apart from duration, the video track properties of the input video are not changed by default:
v = VideoGenerator[ConstantImage];r = VideoTimeStretch[v, 1 / 2];Information[v, "VideoTracks"]Information[r, "VideoTracks"]VideoTimeStretch only operates on the video tracks:
v = Video["ExampleData/fish.mp4"];
Information[v, "AudioTrackCount"]r = VideoTimeStretch[v, 1 / 3];
Information[r, "AudioTrackCount"]Stretch the audio track using AudioTimeStretch:
a = AudioTimeStretch[Audio[v], 1 / 3]//NormalCombine the video and audio tracks:
VideoCombine[{r, a}];
Information[%, "AudioTrackCount"]Use VideoFrameMap to create a file from all original frames at a different frame rate:
v = AnimationVideo[ConstantImage[Hue[h]], {h, 0, 5, 1 / 30}];
Information[v, {"FrameRate", "FrameCount", "ExactDurations"}]This effectively only changes time stamps of all frames:
r = VideoFrameMap[Identity, v, FrameRate -> 15];
Information[r, {"FrameRate", "FrameCount", "ExactDurations"}]Compare with the result of VideoTimeStretch:
VideoTimeStretch[v, 2];
Information[%, {"FrameRate", "FrameCount", "ExactDurations"}]Possible Issues (2)
Time intervals should not overlap:
v = Video["ExampleData/rule30.mp4"];VideoTimeStretch[v, {{0, .5} -> 2, {.25, .75} -> 1 / 2}]//HeadThe stretch factor should not be zero:
v = Video["ExampleData/rule30.mp4"];VideoTimeStretch[v, 0]//HeadIf a function is provided, it should never evaluate to zero:
VideoTimeStretch[v, #&]//HeadRelated Guides
Text
Wolfram Research (2021), VideoTimeStretch, Wolfram Language function, https://reference.wolfram.com/language/ref/VideoTimeStretch.html (updated 2022).
CMS
Wolfram Language. 2021. "VideoTimeStretch." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/VideoTimeStretch.html.
APA
Wolfram Language. (2021). VideoTimeStretch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VideoTimeStretch.html
BibTeX
@misc{reference.wolfram_2026_videotimestretch, author="Wolfram Research", title="{VideoTimeStretch}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/VideoTimeStretch.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_videotimestretch, organization={Wolfram Research}, title={VideoTimeStretch}, year={2022}, url={https://reference.wolfram.com/language/ref/VideoTimeStretch.html}, note=[Accessed: 13-June-2026]}