Skip to main content

Split by File Size

File-size splitting breaks audio into segments that each fit within a target file size. This is useful when you need to meet upload limits (e.g., 25 MB email attachments, 8 MB Discord uploads).

How It Works

When you set splitMode to "fileSize", AudioSpliter estimates segment boundaries to keep each output file at or below your specified maxFileSize in bytes. The actual sizes depend on the audio bitrate and format.

Basic Example

curl -X POST https://api.audiospliter.com/api/v1/splits \
-H "X-API-Key: as_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"sourceUrl": "https://example.com/recording.mp3",
"splitMode": "fileSize",
"maxFileSize": 26214400,
"outputFormat": "mp3"
}'

Common size targets:

TargetBytesUse Case
8 MB8388608Discord file limit
10 MB10485760Slack file limit
25 MB26214400Email attachment limit
100 MB104857600Generic upload limit

Node.js Example

async function splitBySize(sourceUrl, maxMB) {
const response = await fetch('https://api.audiospliter.com/api/v1/splits', {
method: 'POST',
headers: {
'X-API-Key': process.env.AUDIOSPLITER_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
sourceUrl,
splitMode: 'fileSize',
maxFileSize: maxMB * 1024 * 1024,
outputFormat: 'mp3',
}),
});

const job = await response.json();
console.log(`Job ${job.id} queued`);
return job;
}

// Split into segments of max 25 MB
await splitBySize('https://example.com/recording.mp3', 25);

Python Example

import requests
import os

def split_by_size(source_url: str, max_mb: int):
response = requests.post(
'https://api.audiospliter.com/api/v1/splits',
headers={
'X-API-Key': os.environ['AUDIOSPLITER_API_KEY'],
'Content-Type': 'application/json',
},
json={
'sourceUrl': source_url,
'splitMode': 'fileSize',
'maxFileSize': max_mb * 1024 * 1024,
'outputFormat': 'mp3',
},
)
return response.json()

split_by_size('https://example.com/recording.mp3', 25)

Tips

  • Output format affects file size. WAV files are much larger than MP3 for the same duration. Consider using a compressed format if you need small files.
  • Minimum file size is 100 KB. Very small targets may produce errors for high-bitrate audio.
  • Actual segment size may be slightly under the target. AudioSpliter errs on the side of staying below the limit.