Segments Guide
Overview
Segments let you sync different audio clips to different time ranges within a single video in one API call. This enables multi-speaker lip sync by letting you assign different audio inputs to different parts of your video. Using segments, you can:
- LipSync different audio clips to different parts of your video
- Use specific portion of audio input to lipsync a segment for precise timing
- Use both audio and text-to-speech inputs to lipsync multiple segments with different input types in a single generation
- Keep some parts of the video unlipsynced while one dubbed track plays over the whole result
Basic Concepts
To use segments feature, you need to provide a top-level segments array with each item defining a video time range/segment, each with its own audio configuration. A generation can have up to 100 segments and up to 102 inputs: one video, up to 100 audio or text inputs for the segments, and a separate audio input for outputAudio. Requests over these limits return 400.
Segment
Each segment item takes the following properties:
Segment start time in seconds
Segment end time in seconds
Audio configuration with refId and optional cropping. Required unless lipsync is false
Set to false to keep this part of the video as it is. See Keep segments unlipsynced
Override generation options for this specific segment
audioInput
Each lipsynced segment requires exactly one audioInput. audioInput takes the following properties:
Reference ID of the audio/text-to-speech input to use for this segment
Optional start time (in seconds) to crop the referenced audio. When specified, endTime must also be provided
Optional end time (in seconds) to crop the referenced audio. When specified, startTime must also be provided
The specified audioInput will be used to lipsync the video segment between startTime and endTime.
optionsOverride
Each segment can optionally override the top-level generation options. This allows you to apply different settings per segment, including targeting different speakers.
For multi-speaker videos, use active_speaker_detection to target a different person in each segment. See Speaker Selection — API for full details on speaker selection options.
Override the sync mode for this segment
Overrides expressiveness (0 to 1) for this segment on models that expose temperature. sync-3 manages expressiveness itself.
Overrides occlusion detection for this segment on models that expose the setting. sync-3 detects occlusions automatically.
Override active speaker detection for this segment. Useful when different segments have different speakers. Accepts the same options as the top-level active_speaker_detection:
auto_detect: automatically detect and target the active speakerv3: use ASD v3frame_number+coordinates: manually specify the speaker by frame and pointbounding_boxes: provide per-frame bounding boxes if you have detection databounding_boxes_url: point to an external JSON file containing bounding boxes (recommended for long videos to avoid large request payloads)
How segment timing & duration works
When a segment’s audio and its video window (endTime − startTime) are different lengths, sync_mode decides how the mismatch is resolved — and the mode you choose changes the effective duration of that segment in the output:
In short, a segment’s effective length is cut_off → min(audio, window), silence → max(audio, window), and loop / bounce / remap → the audio length.
The same rules apply to a single-segment (non-segments) generation, where the “window” is the whole video. A 30s audio on a 15s video with sync_mode: cut_off produces a 15s output (clipped to the video); silence / loop / bounce / remap produce a ~30s output.
Output can be longer than your source video
Each segment places its audio take into its own window on the timeline, and each window expands to fit its audio (per the sync_mode above). When there are gaps between segments, those expanded windows shift the rest of the timeline — so the output can be longer than the source video. For example, two segments [1s–3s] and [5s–8s] on a 10s video can produce a ~16.8s output: each window stretched to fit its full audio take. This is expected behavior, not a bug.
To keep the output the same length as the source video, crop each audio take to its window with audioInput.startTime/endTime, so the take is exactly as long as the window and the window doesn’t expand:
Here the 2-second audio slice exactly fills the 2-second window, so the timeline — and the output duration — stays aligned with the source.
Keep segments unlipsynced
In a dubbed video, some shots don’t need lipsync: the speaker is off camera, the listener is on screen, or the speaker faces away. You still want the dub to play over those shots. Set lipsync: false on those segments and the API plays one audio track over the whole finished output, so the sound has no cuts at segment edges.
A segment with lipsync: false:
- Keeps its part of the video exactly as it is.
- Needs no
audioInput. - Doesn’t count toward the generation’s billed duration or your plan’s per-generation limit.
- Still can’t overlap other segments.
The top-level outputAudio.refId names the audio input that plays over the whole output, replacing the original sound everywhere: lipsynced segments, kept segments and the gaps between them. It must name an audio input, not a text-to-speech input. When the request has exactly one audio input, you can omit outputAudio and that input is used. With several audio inputs, set outputAudio.refId.
The track plays from the start of the output. If it’s shorter than the output, the rest is silent; if it’s longer, it’s cut at the end of the video. To keep the dub aligned with the picture, crop each lipsynced segment’s audioInput to the matching slice of the same track. The output then stays the same length as the source; see Output can be longer than your source video.
- At least one segment must be lipsynced.
outputAudioandlipsync: falseare available inPOST /v2/generaterequests. In multipart requests, sendoutputAudioas a JSON string, likesegments. The output audio must be sent byurlorassetIdwith arefId: an uploaded audio file has norefId.- Organizations with zero data retention, a custom output bucket, or a retention override can’t use them yet.
This request dubs a 10-second video with one track. It lipsyncs only the shots where the speaker is on screen, from 0 to 4 seconds and 6 to 10 seconds. The listener’s shot from 4 to 6 seconds keeps its picture and plays the same track:
API Usage Examples
Single Segment with Single Audio
Multiple Segments with Single Audio
Multiple Segments with Single Audio Input
Multiple Segments with Multiple Audio
Multiple Segments with Multiple Audio Inputs
Segments with Options Override
Segments with Per-Segment Options
Use optionsOverride to apply different generation settings to each segment.
Multi-Speaker Segments with Active Speaker Detection
Target Different Speakers Per Segment
Use active_speaker_detection in optionsOverride to target different speakers in each segment. Its frame_number is zero-based and relative to the segment start. For a segment starting at 5 seconds in a 30 fps video, source frame 150 is segment frame 0. Capture coordinates from that frame. Top-level options.active_speaker_detection.frame_number is relative to the full input video.
See Speaker Selection — API for details on active_speaker_detection options.
Best Practices
Planning Your Segments
- Map your timeline: Identify video segments and corresponding audio needs
- Prepare audio files: Ensure audio quality and appropriate duration
- Test segment boundaries: Verify smooth transitions between segments
Audio Preparation
- Use consistent audio quality across all segments and the video’s audio.
- For best results, ensure proper timing alignment with video segments. If segment duration and corresponding audio duration don’t match, rely on sync_mode to determine how to handle the mismatch.
Troubleshooting
Common Errors
"Multiple audio inputs are only allowed when using multi-segments"
Provide a top-level segments array when using multiple audio or text inputs.
"Unable to resolve audio input URL"
Ensure all audio inputs have valid url or assetId values and that referenced refId values exist in your audio or text inputs.
"Segment at index X is missing a valid audioInput.refId"
This error occurs when a segment’s audio_input is missing a refId or the refId is empty. Each lipsynced segment must reference a valid audio or text input through its refId. Only a segment with lipsync: false can omit audioInput.
"Segment at index X references unknown refId"
This error occurs when a segment references a refId that doesn’t exist in your audio or text inputs. Ensure all referenced refId values match exactly with those defined in your inputs.
"Invalid segment time range: startTime must be <= endTime"
Each segment’s startTime must be less than or equal to its endTime. Zero-length segments (where startTime equals endTime) are allowed for use cases like zero-duration crop points.
"Invalid segment frame range: startFrame must be < endFrame"
When specifying segment boundaries using frames instead of seconds, startFrame must be strictly less than endFrame. Unlike time-based segments which allow equal start and end times, frame-based segments require at least one frame of difference.
"Invalid audioInput crop range"
When cropping audio within a segment, both startTime and endTime must be provided, and startTime must be less than or equal to endTime.
"Segments with lipsync: false play one audio track over the whole output, and this request has several audio inputs"
Returned with generation_input_segments_invalid (422) when a segment sets lipsync: false, outputAudio is missing, and the request doesn’t have exactly one audio input (it has several, or only text inputs). The API can’t tell which input covers the whole video. Add that audio input if it’s missing, and set outputAudio.refId to it:
"Give the audio input a refId: segments with lipsync: false play it over the whole output."
Returned with generation_input_segments_invalid (422) when a segment sets lipsync: false and the request’s only audio input has no refId. Give that audio input a refId.
"outputAudio.refId ... does not match an audio input"
Returned with generation_input_segments_invalid (422) when outputAudio.refId names no audio input in the request, or names a text-to-speech input. The message includes the refId you sent. Set it to the refId of an audio input that covers the whole video. An empty outputAudio.refId returns 400 outputAudio.refId is required.
"Every segment sets lipsync: false, so there is nothing to lipsync"
Returned with generation_input_segments_invalid (422) when no segment is lipsynced. Lipsync at least one segment. To keep the whole video unchanged, don’t create a generation.
"outputAudio needs segments"
Returned with generation_input_segments_invalid (422) when a request sets outputAudio without a segments array. To play one audio across the whole video, send it as the only audio input and omit both segments and outputAudio.
"outputAudio and lipsync: false segments are not available yet for organizations with ..."
Returned with generation_input_segments_invalid (422) when your organization uses zero data retention, a custom output bucket, or a retention override. Lipsync every segment, or leave gaps between segments, which keep the original sound.
"When using multi-segments, please provide at least one audio or text input"
Ensure you have at least one audio input or text input with a valid refId when using segments.
Related Resources
- Lipsync Model: learn about supported models for single and multi-segment generations
- Video Dubbing API Guide: use segments with dubbing workflows for multi-speaker video dubbing

