Subclip
FFmpeg supports extracting a portion of a media file - a subclip - by seeking to a start time and optionally stopping at an duration. In ffmpeg-studio you can do the same from your high-level classes:
VideoFile("path/to/video.mp4").subclip(start, duration)
AudioFile("path/to/audio.mp3").subclip(start, duration)
Under The Hood
subclip set flags internally to be used at command generation to only requested time range of the original file. It does not modify the original file; it instructs FFmpeg to seek and only use the requested portion when you run the pipeline or export.
subclip
Defines a subclip from the video file by setting the start and duration. This will not make a new copy until exported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
float | str
|
The start time of the subclip. |
required |
duration
|
float | str
|
The duration of the subclip. |
required |
Returns:
| Type | Description |
|---|---|
VideoFile
|
The updated VideoFile object with the subclip flags set. |
Examples
Make a subclip starting from 5s and 15s duration after the starting point
from ffmpeg import VideoFile, export
sub = VideoFile("demo.mp4").subclip(5, 15)
export(sub, path="demo_subclip.mp4").run()
Make a subclip starting from 1 minute and keep 2min duration after the starting point