The /audio-mixing endpoint allows you to combine an audio file with a video, with adjustable volume levels for each, providing a flexible way to add background music or sound effects.
- URL:
/audio-mixing - Method:
POST
- X-API-Key (string, required): The API key used for authentication.
- video_url (string, required): URL of the video to mix with the audio.
- audio_url (string, required): URL of the audio to be combined with the video.
- video_vol (float, optional): Volume level for the video’s audio track (1.0 is default).
- audio_vol (float, optional): Volume level for the added audio track (1.0 is default).
- output_length (integer, optional): Desired length of the output video in seconds. Defaults to the shorter of the two input files if not specified.
- webhook_url (string, optional): URL to receive the resulting video URL upon completion.
- id (string, optional): Unique identifier for tracking the job.
{
"video_url": "https://example.com/video.mp4",
"audio_url": "https://example.com/audio.mp3",
"video_vol": 0.8,
"audio_vol": 1.2,
"output_length": 60,
"webhook_url": "https://your-webhook-url.com/notify",
"id": "mix123"
}curl -X POST "https://your-api-domain.com/audio-mixing" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"video_url": "https://example.com/video.mp4",
"audio_url": "https://example.com/audio.mp3",
"video_vol": 0.8,
"audio_vol": 1.2,
"output_length": 60,
"webhook_url": "https://your-webhook-url.com/notify",
"id": "mix123"
}'If the audio mixing is successful and no webhook_url is provided:
- Status Code:
200 OK - Body:
{ "job_id": "mix123", "mixed_video_url": "https://cloud-storage-url.com/output_with_audio.mp4", "message": "success" }
If a webhook_url is provided, the request is queued, and this response is returned:
- Status Code:
202 Accepted - Body:
{ "job_id": "mix123", "message": "processing" }
- 400 Bad Request: Missing or invalid parameters (
video_urloraudio_url).{ "error": "Missing required video_url or audio_url" } - 500 Internal Server Error: Mixing process failed.
{ "error": "Error during audio mixing" }
- 400 Bad Request: Returned if
video_urloraudio_urlis missing or malformed. - 500 Internal Server Error: Returned if there’s an error during audio mixing.
- Adjust
video_volandaudio_volfor desired balance; values over1.0increase volume, while values under1.0decrease it. - The
output_lengthparameter can be set to the desired length, but defaults to the shorter duration between video and audio if not specified.
- Invalid URLs: Ensure
video_urlandaudio_urlare accessible and point directly to the media files. - Format Compatibility: Check that the video and audio formats are compatible for merging.
- Use Webhook for Large Files: For lengthy files, use
webhook_urlto receive the result asynchronously. - Volume Adjustment: Fine-tune
video_volandaudio_volto get the desired sound mix without distortion.