mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(audio): expose sample rate setting in Convert Audio (#561)
The Convert Audio tool promised configurable bitrate, sample rate, and channel count, but only format and bitrate were exposed. Adds an optional sampleRate setting (8000 to 96000 Hz, omitted = preserve source) wired through the Zod schema, the FFmpeg -ar flag, the standalone settings panel, and the pipeline builder controls. Impossible combinations fail loudly instead of degrading silently: MP3 + 96000 Hz is rejected (libmp3lame caps at 48 kHz), and MP3 bitrates above the encoder ceiling at low rates (64 kbps at 8 kHz, 160 kbps at 16/22.05 kHz) are rejected rather than clamped. The UI offers only legal combinations and sanitizes stored pipeline settings on load. Docs updated in English plus all 20 localized pages with refreshed i18n_source_hash stamps; two new UI strings added to all 21 locales. Fixes #558
This commit is contained in:
@@ -3,10 +3,53 @@ import { z } from "zod";
|
||||
import { runMediaTool } from "../../lib/media-tool.js";
|
||||
import { createToolRoute } from "../tool-factory.js";
|
||||
|
||||
const settingsSchema = z.object({
|
||||
format: z.enum(["mp3", "wav", "ogg", "flac", "m4a"]).default("mp3"),
|
||||
bitrateKbps: z.number().int().min(32).max(320).default(192),
|
||||
});
|
||||
// libmp3lame clamps the bitrate silently above these: MPEG-2.5 (8 kHz) tops out
|
||||
// at 64 kbps, MPEG-2 (16/22.05 kHz) at 160 kbps. Reject instead of degrading.
|
||||
const MP3_BITRATE_CAPS: Record<number, number> = { 8000: 64, 16000: 160, 22050: 160 };
|
||||
|
||||
const settingsSchema = z
|
||||
.object({
|
||||
format: z.enum(["mp3", "wav", "ogg", "flac", "m4a"]).default("mp3"),
|
||||
bitrateKbps: z.number().int().min(32).max(320).default(192),
|
||||
// Omitted = preserve the source sample rate (no -ar flag).
|
||||
sampleRate: z
|
||||
.union(
|
||||
[
|
||||
z.literal(8000),
|
||||
z.literal(16000),
|
||||
z.literal(22050),
|
||||
z.literal(32000),
|
||||
z.literal(44100),
|
||||
z.literal(48000),
|
||||
z.literal(96000),
|
||||
],
|
||||
{
|
||||
errorMap: () => ({
|
||||
message: "must be one of 8000, 16000, 22050, 32000, 44100, 48000, 96000",
|
||||
}),
|
||||
},
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
.superRefine((val, ctx) => {
|
||||
if (val.format !== "mp3" || !val.sampleRate) return;
|
||||
if (val.sampleRate === 96000) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["sampleRate"],
|
||||
message: "MP3 output supports sample rates up to 48000 Hz",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const cap = MP3_BITRATE_CAPS[val.sampleRate];
|
||||
if (cap && val.bitrateKbps > cap) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["bitrateKbps"],
|
||||
message: `MP3 at ${val.sampleRate} Hz supports at most ${cap} kbps`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const CONTENT_TYPES: Record<string, string> = {
|
||||
mp3: "audio/mpeg",
|
||||
@@ -29,31 +72,31 @@ export function registerConvertAudio(app: FastifyInstance) {
|
||||
const outName = `${base}.${settings.format}`;
|
||||
|
||||
const { outPath } = await runMediaTool(ctx, outName, (inPath, out) => {
|
||||
const rate = settings.sampleRate ? ["-ar", String(settings.sampleRate)] : [];
|
||||
switch (settings.format) {
|
||||
case "mp3":
|
||||
return [
|
||||
"-i",
|
||||
inPath,
|
||||
"-vn",
|
||||
"-c:a",
|
||||
"libmp3lame",
|
||||
"-b:a",
|
||||
`${settings.bitrateKbps}k`,
|
||||
out,
|
||||
];
|
||||
case "wav":
|
||||
return ["-i", inPath, "-vn", "-c:a", "pcm_s16le", out];
|
||||
return ["-i", inPath, "-vn", "-c:a", "pcm_s16le", ...rate, out];
|
||||
case "ogg": {
|
||||
// libvorbis ABR (-b:a) fails with "encoder setup failed" when the bitrate is
|
||||
// too high for the source sample rate (e.g. 8 kHz). Use quality VBR (-q:a),
|
||||
// which adapts to the rate. Map bitrate -> quality (~bitrate/32: 192k -> q6).
|
||||
const quality = (settings.bitrateKbps / 32).toFixed(1);
|
||||
return ["-i", inPath, "-vn", "-c:a", "libvorbis", "-q:a", quality, out];
|
||||
return ["-i", inPath, "-vn", "-c:a", "libvorbis", "-q:a", quality, ...rate, out];
|
||||
}
|
||||
case "flac":
|
||||
return ["-i", inPath, "-vn", "-c:a", "flac", out];
|
||||
return ["-i", inPath, "-vn", "-c:a", "flac", ...rate, out];
|
||||
case "m4a":
|
||||
return ["-i", inPath, "-vn", "-c:a", "aac", "-b:a", `${settings.bitrateKbps}k`, out];
|
||||
return [
|
||||
"-i",
|
||||
inPath,
|
||||
"-vn",
|
||||
"-c:a",
|
||||
"aac",
|
||||
"-b:a",
|
||||
`${settings.bitrateKbps}k`,
|
||||
...rate,
|
||||
out,
|
||||
];
|
||||
default:
|
||||
return [
|
||||
"-i",
|
||||
@@ -63,6 +106,7 @@ export function registerConvertAudio(app: FastifyInstance) {
|
||||
"libmp3lame",
|
||||
"-b:a",
|
||||
`${settings.bitrateKbps}k`,
|
||||
...rate,
|
||||
out,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "تحويل الصوت بين تنسيقات MP3 وWAV وOGG وFLAC وM4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 37d17dd79052
|
||||
---
|
||||
|
||||
# تحويل الصوت {#convert-audio}
|
||||
|
||||
حوّل ملفات الصوت بين التنسيقات الشائعة بما فيها MP3 وWAV وOGG وFLAC وM4A، مع معدل بت إخراج قابل للتكوين.
|
||||
حوّل ملفات الصوت بين التنسيقات الشائعة بما فيها MP3 وWAV وOGG وFLAC وM4A، مع معدل بت إخراج ومعدل أخذ عينات قابلين للتكوين.
|
||||
|
||||
## نقطة نهاية API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ i18n_output_hash: 37d17dd79052
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | لا | `"mp3"` | تنسيق الإخراج: `mp3`، `wav`، `ogg`، `flac`، `m4a` |
|
||||
| bitrateKbps | integer | لا | `192` | معدل البت للإخراج بالكيلوبت في الثانية (32 إلى 320) |
|
||||
| sampleRate | integer | لا | معدل المصدر | معدل أخذ العينات للإخراج بوحدة Hz: `8000`، `16000`، `22050`، `32000`، `44100`، `48000`، أو `96000`. أغفله للاحتفاظ بمعدل المصدر |
|
||||
|
||||
## مثال طلب {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ i18n_output_hash: 37d17dd79052
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## مثال استجابة {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- تشمل تنسيقات الإدخال المدعومة MP3 وWAV وOGG وFLAC وAAC وM4A وWMA وAIFF وOPUS.
|
||||
- ينطبق معدل البت فقط على التنسيقات ذات الفقد (MP3 وOGG وM4A). التنسيقات عديمة الفقد مثل WAV وFLAC تتجاهل هذا الإعداد.
|
||||
- يدعم إخراج MP3 معدلات أخذ عينات تصل إلى 48000 Hz. ينطبق خيار 96000 Hz على WAV وOGG وFLAC وM4A فقط.
|
||||
- يتقيّد معدل البت في MP3 بمعدل أخذ العينات: بحد أقصى 64 kbps عند 8000 Hz و160 kbps عند 16000 أو 22050 Hz. تُرفض الطلبات التي تتجاوز الحد بدلاً من خفضها بصمت.
|
||||
- يبقي اسم ملف الإخراج الاسم الأصلي مع الامتداد الجديد.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Audio zwischen den Formaten MP3, WAV, OGG, FLAC und M4A konvertieren."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: bacd9e312553
|
||||
---
|
||||
|
||||
# Audio konvertieren {#convert-audio}
|
||||
|
||||
Konvertiere Audiodateien zwischen gängigen Formaten wie MP3, WAV, OGG, FLAC und M4A, mit konfigurierbarer Ausgabe-Bitrate.
|
||||
Konvertiere Audiodateien zwischen gängigen Formaten wie MP3, WAV, OGG, FLAC und M4A, mit konfigurierbarer Ausgabe-Bitrate und Abtastrate.
|
||||
|
||||
## API-Endpunkt {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Akzeptiert Multipart-Formulardaten mit einer Audiodatei und einem JSON-Feld `set
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Nein | `"mp3"` | Ausgabeformat: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Nein | `192` | Ausgabe-Bitrate in kbps (32 bis 320) |
|
||||
| sampleRate | integer | Nein | Quellrate | Ausgabe-Abtastrate in Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` oder `96000`. Weglassen, um die Quellrate beizubehalten |
|
||||
|
||||
## Beispielanfrage {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Akzeptiert Multipart-Formulardaten mit einer Audiodatei und einem JSON-Feld `set
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Beispielantwort {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Zu den unterstützten Eingabeformaten gehören MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF und OPUS.
|
||||
- Die Bitrate gilt nur für verlustbehaftete Formate (MP3, OGG, M4A). Verlustfreie Formate wie WAV und FLAC ignorieren diese Einstellung.
|
||||
- Die MP3-Ausgabe unterstützt Abtastraten bis zu 48000 Hz. Die Option 96000 Hz gilt nur für WAV, OGG, FLAC und M4A.
|
||||
- Die MP3-Bitrate ist durch die Abtastrate begrenzt: höchstens 64 kbps bei 8000 Hz und 160 kbps bei 16000 oder 22050 Hz. Anfragen über der Obergrenze werden abgelehnt, statt stillschweigend gesenkt zu werden.
|
||||
- Der Ausgabedateiname behält den ursprünglichen Namen mit der neuen Erweiterung bei.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Convierte audio entre los formatos MP3, WAV, OGG, FLAC y M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 762c2572e3e8
|
||||
---
|
||||
|
||||
# Convertir audio {#convert-audio}
|
||||
|
||||
Convierte archivos de audio entre formatos comunes como MP3, WAV, OGG, FLAC y M4A, con tasa de bits de salida configurable.
|
||||
Convierte archivos de audio entre formatos comunes como MP3, WAV, OGG, FLAC y M4A, con tasa de bits y frecuencia de muestreo de salida configurables.
|
||||
|
||||
## Endpoint de la API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Acepta datos de formulario multipart con un archivo de audio y un campo JSON `se
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | Formato de salida: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | No | `192` | Tasa de bits de salida en kbps (32 a 320) |
|
||||
| sampleRate | integer | No | frecuencia de origen | Frecuencia de muestreo de salida en Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` o `96000`. Omítelo para conservar la frecuencia de origen |
|
||||
|
||||
## Solicitud de ejemplo {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Acepta datos de formulario multipart con un archivo de audio y un campo JSON `se
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Respuesta de ejemplo {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Los formatos de entrada admitidos incluyen MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF y OPUS.
|
||||
- La tasa de bits solo se aplica a los formatos con pérdida (MP3, OGG, M4A). Los formatos sin pérdida como WAV y FLAC ignoran esta configuración.
|
||||
- La salida MP3 admite frecuencias de muestreo de hasta 48000 Hz. La opción de 96000 Hz solo se aplica a WAV, OGG, FLAC y M4A.
|
||||
- La tasa de bits de MP3 está limitada por la frecuencia de muestreo: como máximo 64 kbps a 8000 Hz y 160 kbps a 16000 o 22050 Hz. Las solicitudes por encima del límite se rechazan en lugar de reducirse silenciosamente.
|
||||
- El nombre del archivo de salida conserva el nombre original con la nueva extensión.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Convertir l'audio entre les formats MP3, WAV, OGG, FLAC et M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 9885ffa48ef0
|
||||
---
|
||||
|
||||
# Convertir l'audio {#convert-audio}
|
||||
|
||||
Convertir des fichiers audio entre les formats courants, dont MP3, WAV, OGG, FLAC et M4A, avec un débit de sortie configurable.
|
||||
Convertir des fichiers audio entre les formats courants, dont MP3, WAV, OGG, FLAC et M4A, avec un débit de sortie et une fréquence d'échantillonnage configurables.
|
||||
|
||||
## Point de terminaison de l'API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Accepte des données de formulaire multipart avec un fichier audio et un champ J
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Non | `"mp3"` | Format de sortie : `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Non | `192` | Débit de sortie en kbps (32 à 320) |
|
||||
| sampleRate | integer | Non | fréquence d'origine | Fréquence d'échantillonnage de sortie en Hz : `8000`, `16000`, `22050`, `32000`, `44100`, `48000` ou `96000`. Omettre pour conserver la fréquence d'origine |
|
||||
|
||||
## Exemple de requête {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Accepte des données de formulaire multipart avec un fichier audio et un champ J
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Exemple de réponse {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Les formats d'entrée pris en charge incluent MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF et OPUS.
|
||||
- Le débit ne s'applique qu'aux formats avec perte (MP3, OGG, M4A). Les formats sans perte comme WAV et FLAC ignorent ce paramètre.
|
||||
- La sortie MP3 prend en charge les fréquences d'échantillonnage jusqu'à 48000 Hz. L'option 96000 Hz ne s'applique qu'aux formats WAV, OGG, FLAC et M4A.
|
||||
- Le débit MP3 est plafonné par la fréquence d'échantillonnage : au maximum 64 kbps à 8000 Hz et 160 kbps à 16000 ou 22050 Hz. Les requêtes dépassant ce plafond sont rejetées au lieu d'être abaissées silencieusement.
|
||||
- Le nom du fichier de sortie conserve le nom d'origine avec la nouvelle extension.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "MP3, WAV, OGG, FLAC, और M4A फ़ॉर्मैट के बीच audio रूपांतरित करें।"
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 3e9d339fb4f6
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
MP3, WAV, OGG, FLAC, और M4A सहित सामान्य फ़ॉर्मैट के बीच audio फ़ाइलें रूपांतरित करें, कॉन्फ़िगर करने योग्य आउटपुट bitrate के साथ।
|
||||
MP3, WAV, OGG, FLAC, और M4A सहित सामान्य फ़ॉर्मैट के बीच audio फ़ाइलें रूपांतरित करें, कॉन्फ़िगर करने योग्य आउटपुट bitrate और सैंपल रेट के साथ।
|
||||
|
||||
## API Endpoint {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ MP3, WAV, OGG, FLAC, और M4A सहित सामान्य फ़ॉर
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | आउटपुट फ़ॉर्मैट: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | No | `192` | kbps में आउटपुट bitrate (32 से 320) |
|
||||
| sampleRate | integer | No | मूल रेट | Hz में आउटपुट सैंपल रेट: `8000`, `16000`, `22050`, `32000`, `44100`, `48000`, या `96000`। मूल रेट बनाए रखने के लिए छोड़ दें |
|
||||
|
||||
## Example Request {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ MP3, WAV, OGG, FLAC, और M4A सहित सामान्य फ़ॉर
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Example Response {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- समर्थित इनपुट फ़ॉर्मैट में MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF, और OPUS शामिल हैं।
|
||||
- Bitrate केवल lossy फ़ॉर्मैट (MP3, OGG, M4A) पर लागू होता है। WAV और FLAC जैसे lossless फ़ॉर्मैट इस सेटिंग को नज़रअंदाज़ करते हैं।
|
||||
- MP3 आउटपुट 48000 Hz तक के सैंपल रेट का समर्थन करता है। 96000 Hz विकल्प केवल WAV, OGG, FLAC, और M4A पर लागू होता है।
|
||||
- MP3 bitrate सैंपल रेट द्वारा सीमित होता है: 8000 Hz पर अधिकतम 64 kbps और 16000 या 22050 Hz पर 160 kbps। सीमा से ऊपर के अनुरोध चुपचाप कम किए जाने के बजाय अस्वीकार कर दिए जाते हैं।
|
||||
- आउटपुट फ़ाइल नाम मूल नाम को नए एक्सटेंशन के साथ रखता है।
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Konversi audio antara format MP3, WAV, OGG, FLAC, dan M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 06454316167e
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
Konversi file audio antara format umum termasuk MP3, WAV, OGG, FLAC, dan M4A, dengan bitrate output yang dapat dikonfigurasi.
|
||||
Konversi file audio antara format umum termasuk MP3, WAV, OGG, FLAC, dan M4A, dengan bitrate output dan laju sampel yang dapat dikonfigurasi.
|
||||
|
||||
## API Endpoint {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Menerima data formulir multipart dengan file audio dan bidang JSON `settings`.
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Tidak | `"mp3"` | Format output: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Tidak | `192` | Bitrate output dalam kbps (32 hingga 320) |
|
||||
| sampleRate | integer | Tidak | laju sumber | Laju sampel output dalam Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000`, atau `96000`. Kosongkan untuk mempertahankan laju sumber |
|
||||
|
||||
## Contoh Permintaan {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Menerima data formulir multipart dengan file audio dan bidang JSON `settings`.
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Contoh Respons {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Format input yang didukung meliputi MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF, dan OPUS.
|
||||
- Bitrate hanya berlaku untuk format lossy (MP3, OGG, M4A). Format lossless seperti WAV dan FLAC mengabaikan pengaturan ini.
|
||||
- Output MP3 mendukung laju sampel hingga 48000 Hz. Opsi 96000 Hz hanya berlaku untuk WAV, OGG, FLAC, dan M4A.
|
||||
- Bitrate MP3 dibatasi oleh laju sampel: maksimal 64 kbps pada 8000 Hz dan 160 kbps pada 16000 atau 22050 Hz. Permintaan di atas batas tersebut ditolak, bukan diturunkan secara diam-diam.
|
||||
- Nama file output mempertahankan nama asli dengan ekstensi baru.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Converti l'audio tra i formati MP3, WAV, OGG, FLAC e M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 6e412e45cdc2
|
||||
---
|
||||
|
||||
# Converti audio {#convert-audio}
|
||||
|
||||
Converti i file audio tra i formati comuni tra cui MP3, WAV, OGG, FLAC e M4A, con bitrate di output configurabile.
|
||||
Converti i file audio tra i formati comuni tra cui MP3, WAV, OGG, FLAC e M4A, con bitrate di output e frequenza di campionamento configurabili.
|
||||
|
||||
## Endpoint API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Accetta dati di form multipart con un file audio e un campo JSON `settings`.
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | Formato di output: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | No | `192` | Bitrate di output in kbps (da 32 a 320) |
|
||||
| sampleRate | integer | No | frequenza originale | Frequenza di campionamento di output in Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` o `96000`. Ometti per mantenere la frequenza originale |
|
||||
|
||||
## Esempio di richiesta {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Accetta dati di form multipart con un file audio e un campo JSON `settings`.
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Esempio di risposta {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- I formati di input supportati includono MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF e OPUS.
|
||||
- Il bitrate si applica solo ai formati con perdita (MP3, OGG, M4A). I formati senza perdita come WAV e FLAC ignorano questa impostazione.
|
||||
- L'output MP3 supporta frequenze di campionamento fino a 48000 Hz. L'opzione 96000 Hz si applica solo a WAV, OGG, FLAC e M4A.
|
||||
- Il bitrate MP3 è limitato dalla frequenza di campionamento: al massimo 64 kbps a 8000 Hz e 160 kbps a 16000 o 22050 Hz. Le richieste superiori al limite vengono rifiutate invece di essere ridotte silenziosamente.
|
||||
- Il nome del file di output mantiene il nome originale con la nuova estensione.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "MP3、WAV、OGG、FLAC、M4A 形式の間で音声を変換します。"
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 76c462fa171c
|
||||
---
|
||||
|
||||
# 音声を変換 {#convert-audio}
|
||||
|
||||
MP3、WAV、OGG、FLAC、M4A などの一般的な形式の間で音声ファイルを変換し、出力ビットレートを設定できます。
|
||||
MP3、WAV、OGG、FLAC、M4A などの一般的な形式の間で音声ファイルを変換し、出力ビットレートとサンプルレートを設定できます。
|
||||
|
||||
## API エンドポイント {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ MP3、WAV、OGG、FLAC、M4A などの一般的な形式の間で音声ファイ
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | 出力形式: `mp3`、`wav`、`ogg`、`flac`、`m4a` |
|
||||
| bitrateKbps | integer | No | `192` | 出力ビットレート(kbps、32〜320) |
|
||||
| sampleRate | integer | No | 元のレート | 出力サンプルレート(Hz): `8000`、`16000`、`22050`、`32000`、`44100`、`48000`、または `96000`。省略すると元のレートが維持されます |
|
||||
|
||||
## リクエスト例 {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ MP3、WAV、OGG、FLAC、M4A などの一般的な形式の間で音声ファイ
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## レスポンス例 {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- サポートされる入力形式には MP3、WAV、OGG、FLAC、AAC、M4A、WMA、AIFF、OPUS が含まれます。
|
||||
- ビットレートは非可逆形式(MP3、OGG、M4A)にのみ適用されます。WAV や FLAC などの可逆形式ではこの設定は無視されます。
|
||||
- MP3 出力でサポートされるサンプルレートは最大 48000 Hz です。96000 Hz のオプションは WAV、OGG、FLAC、M4A にのみ適用されます。
|
||||
- MP3 のビットレートはサンプルレートによって上限が設けられます。8000 Hz では最大 64 kbps、16000 Hz または 22050 Hz では最大 160 kbps です。上限を超えるリクエストは、暗黙的に引き下げられるのではなく拒否されます。
|
||||
- 出力ファイル名は元の名前を保持し、新しい拡張子が付きます。
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "MP3, WAV, OGG, FLAC, M4A 형식 간에 오디오를 변환합니다."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: fb55ca6c563e
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
MP3, WAV, OGG, FLAC, M4A를 포함한 일반적인 형식 간에 오디오 파일을 변환하며, 출력 비트레이트를 구성할 수 있습니다.
|
||||
MP3, WAV, OGG, FLAC, M4A를 포함한 일반적인 형식 간에 오디오 파일을 변환하며, 출력 비트레이트와 샘플 레이트를 구성할 수 있습니다.
|
||||
|
||||
## API 엔드포인트 {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ MP3, WAV, OGG, FLAC, M4A를 포함한 일반적인 형식 간에 오디오 파
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | 출력 형식: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | No | `192` | 출력 비트레이트(kbps 단위, 32 ~ 320) |
|
||||
| sampleRate | integer | No | 원본 레이트 | 출력 샘플 레이트(Hz 단위): `8000`, `16000`, `22050`, `32000`, `44100`, `48000` 또는 `96000`. 생략하면 원본 레이트 유지 |
|
||||
|
||||
## 요청 예시 {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ MP3, WAV, OGG, FLAC, M4A를 포함한 일반적인 형식 간에 오디오 파
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## 응답 예시 {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- 지원되는 입력 형식에는 MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF, OPUS가 포함됩니다.
|
||||
- 비트레이트는 손실 형식(MP3, OGG, M4A)에만 적용됩니다. WAV 및 FLAC 같은 무손실 형식은 이 설정을 무시합니다.
|
||||
- MP3 출력은 최대 48000 Hz의 샘플 레이트를 지원합니다. 96000 Hz 옵션은 WAV, OGG, FLAC, M4A에만 적용됩니다.
|
||||
- MP3 비트레이트는 샘플 레이트에 따라 상한이 정해집니다. 8000 Hz에서는 최대 64 kbps, 16000 또는 22050 Hz에서는 최대 160 kbps입니다. 상한을 초과하는 요청은 조용히 낮춰지는 대신 거부됩니다.
|
||||
- 출력 파일 이름은 원래 이름을 유지하고 새 확장자를 사용합니다.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Converteer audio tussen de formaten MP3, WAV, OGG, FLAC en M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 3a933cf08d88
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
Converteer audiobestanden tussen gangbare formaten waaronder MP3, WAV, OGG, FLAC en M4A, met configureerbare uitvoerbitrate.
|
||||
Converteer audiobestanden tussen gangbare formaten waaronder MP3, WAV, OGG, FLAC en M4A, met configureerbare uitvoerbitrate en samplefrequentie.
|
||||
|
||||
## API-endpoint {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Accepteert multipart-formuliergegevens met een audiobestand en een JSON `setting
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Nee | `"mp3"` | Uitvoerformaat: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Nee | `192` | Uitvoerbitrate in kbps (32 tot 320) |
|
||||
| sampleRate | integer | Nee | bronfrequentie | Uitvoersamplefrequentie in Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` of `96000`. Laat weg om de samplefrequentie van de bron te behouden |
|
||||
|
||||
## Voorbeeldverzoek {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Accepteert multipart-formuliergegevens met een audiobestand en een JSON `setting
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Voorbeeldrespons {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Ondersteunde invoerformaten zijn onder meer MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF en OPUS.
|
||||
- Bitrate is alleen van toepassing op lossy-formaten (MP3, OGG, M4A). Lossless-formaten zoals WAV en FLAC negeren deze instelling.
|
||||
- MP3-uitvoer ondersteunt samplefrequenties tot 48000 Hz. De optie 96000 Hz is alleen van toepassing op WAV, OGG, FLAC en M4A.
|
||||
- De MP3-bitrate wordt begrensd door de samplefrequentie: maximaal 64 kbps bij 8000 Hz en 160 kbps bij 16000 of 22050 Hz. Verzoeken boven deze limiet worden geweigerd in plaats van stilzwijgend verlaagd.
|
||||
- De uitvoerbestandsnaam behoudt de oorspronkelijke naam met de nieuwe extensie.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Konwertuj dźwięk między formatami MP3, WAV, OGG, FLAC i M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 43ae9e92f50c
|
||||
---
|
||||
|
||||
# Konwertuj audio {#convert-audio}
|
||||
|
||||
Konwertuj pliki audio między popularnymi formatami, w tym MP3, WAV, OGG, FLAC i M4A, z konfigurowalną przepływnością wyjściową.
|
||||
Konwertuj pliki audio między popularnymi formatami, w tym MP3, WAV, OGG, FLAC i M4A, z konfigurowalną przepływnością wyjściową i częstotliwością próbkowania.
|
||||
|
||||
## Punkt końcowy API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Przyjmuje dane formularza multipart z plikiem audio oraz polem JSON `settings`.
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Nie | `"mp3"` | Format wyjściowy: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Nie | `192` | Przepływność wyjściowa w kbps (32 do 320) |
|
||||
| sampleRate | integer | Nie | częstotliwość źródłowa | Wyjściowa częstotliwość próbkowania w Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` lub `96000`. Pomiń, aby zachować częstotliwość źródłową |
|
||||
|
||||
## Przykładowe żądanie {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Przyjmuje dane formularza multipart z plikiem audio oraz polem JSON `settings`.
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Przykładowa odpowiedź {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Obsługiwane formaty wejściowe obejmują MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF i OPUS.
|
||||
- Przepływność dotyczy tylko formatów stratnych (MP3, OGG, M4A). Formaty bezstratne, takie jak WAV i FLAC, ignorują to ustawienie.
|
||||
- Wyjście MP3 obsługuje częstotliwości próbkowania do 48000 Hz. Opcja 96000 Hz dotyczy tylko formatów WAV, OGG, FLAC i M4A.
|
||||
- Przepływność MP3 jest ograniczona przez częstotliwość próbkowania: maksymalnie 64 kbps przy 8000 Hz i 160 kbps przy 16000 lub 22050 Hz. Żądania przekraczające ten limit są odrzucane, a nie po cichu obniżane.
|
||||
- Nazwa pliku wyjściowego zachowuje oryginalną nazwę z nowym rozszerzeniem.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Converta áudio entre os formatos MP3, WAV, OGG, FLAC e M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 0a8a44ccc8ef
|
||||
---
|
||||
|
||||
# Converter Áudio {#convert-audio}
|
||||
|
||||
Converta arquivos de áudio entre formatos comuns, incluindo MP3, WAV, OGG, FLAC e M4A, com bitrate de saída configurável.
|
||||
Converta arquivos de áudio entre formatos comuns, incluindo MP3, WAV, OGG, FLAC e M4A, com bitrate de saída e taxa de amostragem configuráveis.
|
||||
|
||||
## Endpoint da API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Aceita dados de formulário multipart com um arquivo de áudio e um campo JSON `
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Não | `"mp3"` | Formato de saída: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Não | `192` | Bitrate de saída em kbps (32 a 320) |
|
||||
| sampleRate | integer | Não | taxa original | Taxa de amostragem de saída em Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` ou `96000`. Omita para manter a taxa original |
|
||||
|
||||
## Exemplo de Requisição {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Aceita dados de formulário multipart com um arquivo de áudio e um campo JSON `
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Exemplo de Resposta {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Os formatos de entrada suportados incluem MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF e OPUS.
|
||||
- O bitrate só se aplica a formatos com perda (MP3, OGG, M4A). Formatos sem perda como WAV e FLAC ignoram essa configuração.
|
||||
- A saída em MP3 suporta taxas de amostragem de até 48000 Hz. A opção de 96000 Hz só se aplica a WAV, OGG, FLAC e M4A.
|
||||
- O bitrate do MP3 é limitado pela taxa de amostragem: no máximo 64 kbps a 8000 Hz e 160 kbps a 16000 ou 22050 Hz. Requisições acima do limite são rejeitadas em vez de serem reduzidas silenciosamente.
|
||||
- O nome do arquivo de saída mantém o nome original com a nova extensão.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Преобразование аудио между форматами MP3, WAV, OGG, FLAC и M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 23fa00361fd5
|
||||
---
|
||||
|
||||
# Преобразование аудио {#convert-audio}
|
||||
|
||||
Преобразуйте аудиофайлы между распространёнными форматами, включая MP3, WAV, OGG, FLAC и M4A, с настраиваемым выходным битрейтом.
|
||||
Преобразуйте аудиофайлы между распространёнными форматами, включая MP3, WAV, OGG, FLAC и M4A, с настраиваемым выходным битрейтом и частотой дискретизации.
|
||||
|
||||
## Конечная точка API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ i18n_output_hash: 23fa00361fd5
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Нет | `"mp3"` | Выходной формат: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Нет | `192` | Выходной битрейт в кбит/с (от 32 до 320) |
|
||||
| sampleRate | integer | Нет | исходная частота | Выходная частота дискретизации в Гц: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` или `96000`. Не указывайте, чтобы сохранить исходную частоту |
|
||||
|
||||
## Пример запроса {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ i18n_output_hash: 23fa00361fd5
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Пример ответа {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Поддерживаемые входные форматы включают MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF и OPUS.
|
||||
- Битрейт применяется только к форматам с потерями (MP3, OGG, M4A). Форматы без потерь, такие как WAV и FLAC, игнорируют эту настройку.
|
||||
- Вывод в MP3 поддерживает частоту дискретизации до 48000 Гц. Значение 96000 Гц применяется только к WAV, OGG, FLAC и M4A.
|
||||
- Битрейт MP3 ограничен частотой дискретизации: не более 64 кбит/с при 8000 Гц и 160 кбит/с при 16000 или 22050 Гц. Запросы выше этого ограничения отклоняются, а не понижаются без предупреждения.
|
||||
- Имя выходного файла сохраняет исходное имя с новым расширением.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Konvertera ljud mellan formaten MP3, WAV, OGG, FLAC och M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: a3c8a930904d
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
Konvertera ljudfiler mellan vanliga format inklusive MP3, WAV, OGG, FLAC och M4A, med konfigurerbar utdatabithastighet.
|
||||
Konvertera ljudfiler mellan vanliga format inklusive MP3, WAV, OGG, FLAC och M4A, med konfigurerbar utdatabithastighet och samplingsfrekvens.
|
||||
|
||||
## API-slutpunkt {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Accepterar multipart-formulärdata med en ljudfil och ett JSON `settings`-fält.
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Nej | `"mp3"` | Utdataformat: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Nej | `192` | Utdatabithastighet i kbps (32 till 320) |
|
||||
| sampleRate | integer | Nej | källans frekvens | Utdatasamplingsfrekvens i Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` eller `96000`. Utelämna för att behålla källans frekvens |
|
||||
|
||||
## Exempelförfrågan {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Accepterar multipart-formulärdata med en ljudfil och ett JSON `settings`-fält.
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Exempelsvar {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Inmatningsformat som stöds inkluderar MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF och OPUS.
|
||||
- Bithastighet gäller endast förlustkomprimerade format (MP3, OGG, M4A). Förlustfria format som WAV och FLAC ignorerar den här inställningen.
|
||||
- MP3-utdata stöder samplingsfrekvenser upp till 48000 Hz. Alternativet 96000 Hz gäller endast WAV, OGG, FLAC och M4A.
|
||||
- MP3-bithastigheten begränsas av samplingsfrekvensen: högst 64 kbps vid 8000 Hz och 160 kbps vid 16000 eller 22050 Hz. Förfrågningar över gränsen avvisas i stället för att tyst sänkas.
|
||||
- Utdatafilnamnet behåller det ursprungliga namnet med den nya filändelsen.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "แปลงเสียงระหว่างรูปแบบ MP3, WAV, OGG, FLAC และ M4A"
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 1b7f2a6ace20
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
แปลงไฟล์เสียงระหว่างรูปแบบทั่วไปรวมถึง MP3, WAV, OGG, FLAC และ M4A พร้อมบิตเรตเอาต์พุตที่กำหนดค่าได้
|
||||
แปลงไฟล์เสียงระหว่างรูปแบบทั่วไปรวมถึง MP3, WAV, OGG, FLAC และ M4A พร้อมบิตเรตเอาต์พุตและอัตราสุ่มตัวอย่างที่กำหนดค่าได้
|
||||
|
||||
## API Endpoint {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ i18n_output_hash: 1b7f2a6ace20
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | ไม่ | `"mp3"` | รูปแบบเอาต์พุต: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | ไม่ | `192` | บิตเรตเอาต์พุตเป็น kbps (32 ถึง 320) |
|
||||
| sampleRate | integer | ไม่ | อัตราเดิม | อัตราสุ่มตัวอย่างเอาต์พุตเป็น Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` หรือ `96000` ละไว้เพื่อคงอัตราเดิม |
|
||||
|
||||
## ตัวอย่างคำขอ {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ i18n_output_hash: 1b7f2a6ace20
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## ตัวอย่างการตอบกลับ {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- รูปแบบอินพุตที่รองรับรวมถึง MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF และ OPUS
|
||||
- บิตเรตใช้ได้กับรูปแบบแบบสูญเสีย (MP3, OGG, M4A) เท่านั้น รูปแบบแบบไม่สูญเสียเช่น WAV และ FLAC จะเพิกเฉยการตั้งค่านี้
|
||||
- เอาต์พุต MP3 รองรับอัตราสุ่มตัวอย่างสูงสุด 48000 Hz ตัวเลือก 96000 Hz ใช้ได้กับ WAV, OGG, FLAC และ M4A เท่านั้น
|
||||
- บิตเรต MP3 ถูกจำกัดตามอัตราสุ่มตัวอย่าง: สูงสุด 64 kbps ที่ 8000 Hz และ 160 kbps ที่ 16000 หรือ 22050 Hz คำขอที่เกินขีดจำกัดจะถูกปฏิเสธแทนที่จะถูกปรับลดลงโดยไม่แจ้ง
|
||||
- ชื่อไฟล์เอาต์พุตคงชื่อเดิมไว้พร้อมนามสกุลใหม่
|
||||
|
||||
@@ -4,7 +4,7 @@ description: Convert audio between MP3, WAV, OGG, FLAC, and M4A formats.
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
Convert audio files between common formats including MP3, WAV, OGG, FLAC, and M4A, with configurable output bitrate.
|
||||
Convert audio files between common formats including MP3, WAV, OGG, FLAC, and M4A, with configurable output bitrate and sample rate.
|
||||
|
||||
## API Endpoint {#api-endpoint}
|
||||
|
||||
@@ -18,6 +18,7 @@ Accepts multipart form data with an audio file and a JSON `settings` field.
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | Output format: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | No | `192` | Output bitrate in kbps (32 to 320) |
|
||||
| sampleRate | integer | No | source rate | Output sample rate in Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000`, or `96000`. Omit to keep the source rate |
|
||||
|
||||
## Example Request {#example-request}
|
||||
|
||||
@@ -25,7 +26,7 @@ Accepts multipart form data with an audio file and a JSON `settings` field.
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Example Response {#example-response}
|
||||
@@ -33,9 +34,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -43,4 +44,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Supported input formats include MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF, and OPUS.
|
||||
- Bitrate only applies to lossy formats (MP3, OGG, M4A). Lossless formats like WAV and FLAC ignore this setting.
|
||||
- MP3 output supports sample rates up to 48000 Hz. The 96000 Hz option applies to WAV, OGG, FLAC, and M4A only.
|
||||
- MP3 bitrate is capped by the sample rate: at most 64 kbps at 8000 Hz and 160 kbps at 16000 or 22050 Hz. Requests above the cap are rejected instead of being silently lowered.
|
||||
- The output filename keeps the original name with the new extension.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Sesi MP3, WAV, OGG, FLAC ve M4A formatları arasında dönüştürün."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 90b93fea4b4c
|
||||
---
|
||||
|
||||
# Convert Audio {#convert-audio}
|
||||
|
||||
Ses dosyalarını MP3, WAV, OGG, FLAC ve M4A dahil yaygın formatlar arasında, yapılandırılabilir çıktı bit hızıyla dönüştürün.
|
||||
Ses dosyalarını MP3, WAV, OGG, FLAC ve M4A dahil yaygın formatlar arasında, yapılandırılabilir çıktı bit hızı ve örnekleme hızıyla dönüştürün.
|
||||
|
||||
## API Uç Noktası {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Bir ses dosyası ve bir JSON `settings` alanı içeren multipart form verisini k
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Hayır | `"mp3"` | Çıktı formatı: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Hayır | `192` | kbps cinsinden çıktı bit hızı (32 ile 320 arası) |
|
||||
| sampleRate | integer | Hayır | kaynak hızı | Hz cinsinden çıktı örnekleme hızı: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` veya `96000`. Kaynak hızını korumak için atlayın |
|
||||
|
||||
## Örnek İstek {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Bir ses dosyası ve bir JSON `settings` alanı içeren multipart form verisini k
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Örnek Yanıt {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Desteklenen girdi formatları arasında MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF ve OPUS bulunur.
|
||||
- Bit hızı yalnızca kayıplı formatlar (MP3, OGG, M4A) için geçerlidir. WAV ve FLAC gibi kayıpsız formatlar bu ayarı yok sayar.
|
||||
- MP3 çıktısı 48000 Hz'e kadar örnekleme hızlarını destekler. 96000 Hz seçeneği yalnızca WAV, OGG, FLAC ve M4A için geçerlidir.
|
||||
- MP3 bit hızı örnekleme hızına göre sınırlıdır: 8000 Hz'de en fazla 64 kbps, 16000 veya 22050 Hz'de ise en fazla 160 kbps. Sınırın üzerindeki istekler sessizce düşürülmek yerine reddedilir.
|
||||
- Çıktı dosya adı, orijinal adı yeni uzantıyla korur.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Конвертуйте аудіо між форматами MP3, WAV, OGG, FLAC та M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: 396aa87e0396
|
||||
---
|
||||
|
||||
# Конвертувати аудіо {#convert-audio}
|
||||
|
||||
Конвертуйте аудіофайли між поширеними форматами, зокрема MP3, WAV, OGG, FLAC та M4A, з налаштовуваним вихідним бітрейтом.
|
||||
Конвертуйте аудіофайли між поширеними форматами, зокрема MP3, WAV, OGG, FLAC та M4A, з налаштовуваним вихідним бітрейтом і частотою дискретизації.
|
||||
|
||||
## Кінцева точка API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ i18n_output_hash: 396aa87e0396
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Ні | `"mp3"` | Вихідний формат: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Ні | `192` | Вихідний бітрейт у kbps (32 до 320) |
|
||||
| sampleRate | integer | Ні | частота джерела | Вихідна частота дискретизації в Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` або `96000`. Пропустіть, щоб зберегти частоту джерела |
|
||||
|
||||
## Приклад запиту {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ i18n_output_hash: 396aa87e0396
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Приклад відповіді {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Підтримувані вхідні формати включають MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF та OPUS.
|
||||
- Бітрейт застосовується лише до форматів зі втратами (MP3, OGG, M4A). Формати без втрат, як-от WAV та FLAC, ігнорують це налаштування.
|
||||
- Вихідний MP3 підтримує частоти дискретизації до 48000 Hz. Опція 96000 Hz застосовується лише до WAV, OGG, FLAC та M4A.
|
||||
- Бітрейт MP3 обмежується частотою дискретизації: щонайбільше 64 kbps при 8000 Hz і 160 kbps при 16000 або 22050 Hz. Запити вище цього обмеження відхиляються, а не знижуються без попередження.
|
||||
- Ім'я вихідного файлу зберігає оригінальну назву з новим розширенням.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "Chuyển đổi âm thanh giữa các định dạng MP3, WAV, OGG, FLAC và M4A."
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: df9906d408e2
|
||||
---
|
||||
|
||||
# Chuyển đổi âm thanh {#convert-audio}
|
||||
|
||||
Chuyển đổi tệp âm thanh giữa các định dạng phổ biến gồm MP3, WAV, OGG, FLAC và M4A, với bitrate đầu ra có thể cấu hình.
|
||||
Chuyển đổi tệp âm thanh giữa các định dạng phổ biến gồm MP3, WAV, OGG, FLAC và M4A, với bitrate và tần số lấy mẫu đầu ra có thể cấu hình.
|
||||
|
||||
## Endpoint API {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ Chấp nhận dữ liệu form multipart với một tệp âm thanh và một t
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | Không | `"mp3"` | Định dạng đầu ra: `mp3`, `wav`, `ogg`, `flac`, `m4a` |
|
||||
| bitrateKbps | integer | Không | `192` | Bitrate đầu ra tính bằng kbps (32 đến 320) |
|
||||
| sampleRate | integer | Không | tần số gốc | Tần số lấy mẫu đầu ra tính bằng Hz: `8000`, `16000`, `22050`, `32000`, `44100`, `48000` hoặc `96000`. Bỏ qua để giữ nguyên tần số gốc |
|
||||
|
||||
## Yêu cầu ví dụ {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ Chấp nhận dữ liệu form multipart với một tệp âm thanh và một t
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## Phản hồi ví dụ {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- Các định dạng đầu vào được hỗ trợ gồm MP3, WAV, OGG, FLAC, AAC, M4A, WMA, AIFF và OPUS.
|
||||
- Bitrate chỉ áp dụng cho các định dạng mất dữ liệu (MP3, OGG, M4A). Các định dạng không mất dữ liệu như WAV và FLAC bỏ qua cài đặt này.
|
||||
- Đầu ra MP3 hỗ trợ tần số lấy mẫu tối đa 48000 Hz. Tùy chọn 96000 Hz chỉ áp dụng cho WAV, OGG, FLAC và M4A.
|
||||
- Bitrate MP3 bị giới hạn bởi tần số lấy mẫu: tối đa 64 kbps ở 8000 Hz và 160 kbps ở 16000 hoặc 22050 Hz. Các yêu cầu vượt quá giới hạn sẽ bị từ chối thay vì bị âm thầm hạ xuống.
|
||||
- Tên tệp đầu ra giữ tên gốc với phần mở rộng mới.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "在 MP3、WAV、OGG、FLAC 和 M4A 格式之间转换音频。"
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: b158d5872091
|
||||
---
|
||||
|
||||
# 转换音频 {#convert-audio}
|
||||
|
||||
在包括 MP3、WAV、OGG、FLAC 和 M4A 在内的常见格式之间转换音频文件,并可配置输出比特率。
|
||||
在包括 MP3、WAV、OGG、FLAC 和 M4A 在内的常见格式之间转换音频文件,并可配置输出比特率和采样率。
|
||||
|
||||
## API 端点 {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ i18n_output_hash: b158d5872091
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | 输出格式:`mp3`、`wav`、`ogg`、`flac`、`m4a` |
|
||||
| bitrateKbps | integer | No | `192` | 输出比特率,单位 kbps(32 到 320) |
|
||||
| sampleRate | integer | No | 源采样率 | 输出采样率,单位 Hz:`8000`、`16000`、`22050`、`32000`、`44100`、`48000` 或 `96000`。省略则保留源采样率 |
|
||||
|
||||
## 请求示例 {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ i18n_output_hash: b158d5872091
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## 响应示例 {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- 支持的输入格式包括 MP3、WAV、OGG、FLAC、AAC、M4A、WMA、AIFF 和 OPUS。
|
||||
- 比特率仅适用于有损格式(MP3、OGG、M4A)。像 WAV 和 FLAC 这样的无损格式会忽略此设置。
|
||||
- MP3 输出支持的采样率最高为 48000 Hz。96000 Hz 选项仅适用于 WAV、OGG、FLAC 和 M4A。
|
||||
- MP3 比特率受采样率限制:8000 Hz 时最高为 64 kbps,16000 或 22050 Hz 时最高为 160 kbps。超出上限的请求会被拒绝,而不会被静默降低。
|
||||
- 输出文件名保留原始名称,仅更换扩展名。
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
description: "在 MP3、WAV、OGG、FLAC 與 M4A 格式之間轉換音訊。"
|
||||
i18n_source_hash: fd02c059e6a9
|
||||
i18n_source_hash: 27fd2f49f472
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: b364a00de332
|
||||
---
|
||||
|
||||
# 轉換音訊 {#convert-audio}
|
||||
|
||||
在常見格式之間轉換音訊檔案,包含 MP3、WAV、OGG、FLAC 與 M4A,並可設定輸出位元率。
|
||||
在常見格式之間轉換音訊檔案,包含 MP3、WAV、OGG、FLAC 與 M4A,並可設定輸出位元率與取樣率。
|
||||
|
||||
## API 端點 {#api-endpoint}
|
||||
|
||||
@@ -21,6 +21,7 @@ i18n_output_hash: b364a00de332
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| format | string | No | `"mp3"` | 輸出格式:`mp3`、`wav`、`ogg`、`flac`、`m4a` |
|
||||
| bitrateKbps | integer | No | `192` | 輸出位元率(kbps)(32 至 320) |
|
||||
| sampleRate | integer | No | 原始取樣率 | 輸出取樣率(Hz):`8000`、`16000`、`22050`、`32000`、`44100`、`48000` 或 `96000`。省略則保留原始取樣率 |
|
||||
|
||||
## 範例請求 {#example-request}
|
||||
|
||||
@@ -28,7 +29,7 @@ i18n_output_hash: b364a00de332
|
||||
curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
-H "Authorization: Bearer si_your-api-key" \
|
||||
-F "file=@audio.mp3" \
|
||||
-F 'settings={"format": "flac", "bitrateKbps": 256}'
|
||||
-F 'settings={"format": "mp3", "bitrateKbps": 192, "sampleRate": 44100}'
|
||||
```
|
||||
|
||||
## 範例回應 {#example-response}
|
||||
@@ -36,9 +37,9 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
```json
|
||||
{
|
||||
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.flac",
|
||||
"downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/audio.mp3",
|
||||
"originalSize": 4500000,
|
||||
"processedSize": 8200000
|
||||
"processedSize": 2800000
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,4 +47,6 @@ curl -X POST http://localhost:1349/api/v1/tools/audio/convert-audio \
|
||||
|
||||
- 支援的輸入格式包含 MP3、WAV、OGG、FLAC、AAC、M4A、WMA、AIFF 與 OPUS。
|
||||
- 位元率只適用於有損格式(MP3、OGG、M4A)。像 WAV 與 FLAC 這類無損格式會忽略此設定。
|
||||
- MP3 輸出支援最高 48000 Hz 的取樣率。96000 Hz 選項只適用於 WAV、OGG、FLAC 與 M4A。
|
||||
- MP3 位元率的上限取決於取樣率:8000 Hz 時最高 64 kbps,16000 或 22050 Hz 時最高 160 kbps。超過上限的請求會被拒絕,而不會被默默調低。
|
||||
- 輸出檔名會保留原始名稱並換上新的副檔名。
|
||||
|
||||
@@ -9,6 +9,28 @@ type AudioFormat = "mp3" | "wav" | "ogg" | "flac" | "m4a";
|
||||
|
||||
const BITRATE_OPTIONS = [96, 128, 192, 256, 320] as const;
|
||||
|
||||
const SAMPLE_RATE_OPTIONS = [8000, 16000, 22050, 32000, 44100, 48000, 96000] as const;
|
||||
|
||||
// libmp3lame caps at 48 kHz, so MP3 output must not offer 96 kHz.
|
||||
function sampleRatesFor(format: AudioFormat): number[] {
|
||||
return format === "mp3"
|
||||
? SAMPLE_RATE_OPTIONS.filter((r) => r <= 48000)
|
||||
: [...SAMPLE_RATE_OPTIONS];
|
||||
}
|
||||
|
||||
// libmp3lame also caps the bitrate at low rates (64 kbps at 8 kHz, 160 kbps at
|
||||
// 16/22.05 kHz) and would clamp silently; offer only combinations it honors.
|
||||
function bitratesFor(format: AudioFormat, sampleRate: number): number[] {
|
||||
if (format !== "mp3" || !sampleRate || sampleRate >= 32000) return [...BITRATE_OPTIONS];
|
||||
if (sampleRate === 8000) return [32, 48, 64];
|
||||
return BITRATE_OPTIONS.filter((b) => b <= 160);
|
||||
}
|
||||
|
||||
function reconcileBitrate(bitrateKbps: number, options: number[]): number {
|
||||
if (options.includes(bitrateKbps)) return bitrateKbps;
|
||||
return options.includes(192) ? 192 : options[options.length - 1];
|
||||
}
|
||||
|
||||
export function ConvertAudioSettings() {
|
||||
const { t } = useTranslation();
|
||||
const s = t.toolSettings["convert-audio"];
|
||||
@@ -18,12 +40,30 @@ export function ConvertAudioSettings() {
|
||||
|
||||
const [outFormat, setOutFormat] = useState<AudioFormat>("mp3");
|
||||
const [bitrateKbps, setBitrateKbps] = useState(192);
|
||||
// 0 = preserve the source sample rate (omit the setting).
|
||||
const [sampleRate, setSampleRate] = useState(0);
|
||||
|
||||
const hasFile = files.length > 0;
|
||||
const hasMultiple = files.length > 1;
|
||||
|
||||
const handleFormatChange = (format: AudioFormat) => {
|
||||
setOutFormat(format);
|
||||
const rate = sampleRatesFor(format).includes(sampleRate) ? sampleRate : 0;
|
||||
if (rate !== sampleRate) setSampleRate(rate);
|
||||
setBitrateKbps((b) => reconcileBitrate(b, bitratesFor(format, rate)));
|
||||
};
|
||||
|
||||
const handleSampleRateChange = (rate: number) => {
|
||||
setSampleRate(rate);
|
||||
setBitrateKbps((b) => reconcileBitrate(b, bitratesFor(outFormat, rate)));
|
||||
};
|
||||
|
||||
const handleProcess = () => {
|
||||
const settings = { format: outFormat, bitrateKbps };
|
||||
const settings = {
|
||||
format: outFormat,
|
||||
bitrateKbps,
|
||||
...(sampleRate ? { sampleRate } : {}),
|
||||
};
|
||||
if (hasMultiple) {
|
||||
processAllFiles(files, settings);
|
||||
} else {
|
||||
@@ -40,7 +80,7 @@ export function ConvertAudioSettings() {
|
||||
<select
|
||||
id="ca-format"
|
||||
value={outFormat}
|
||||
onChange={(e) => setOutFormat(e.target.value as AudioFormat)}
|
||||
onChange={(e) => handleFormatChange(e.target.value as AudioFormat)}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
>
|
||||
<option value="mp3">MP3</option>
|
||||
@@ -61,7 +101,7 @@ export function ConvertAudioSettings() {
|
||||
onChange={(e) => setBitrateKbps(Number(e.target.value))}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
>
|
||||
{BITRATE_OPTIONS.map((br) => (
|
||||
{bitratesFor(outFormat, sampleRate).map((br) => (
|
||||
<option key={br} value={br}>
|
||||
{br} kbps
|
||||
</option>
|
||||
@@ -69,6 +109,25 @@ export function ConvertAudioSettings() {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="ca-samplerate" className="text-xs text-muted-foreground">
|
||||
{s.sampleRate}
|
||||
</label>
|
||||
<select
|
||||
id="ca-samplerate"
|
||||
value={sampleRate}
|
||||
onChange={(e) => handleSampleRateChange(Number(e.target.value))}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
>
|
||||
<option value={0}>{s.sampleRatePreserve}</option>
|
||||
{sampleRatesFor(outFormat).map((r) => (
|
||||
<option key={r} value={r}>
|
||||
{r} Hz
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{error && <p className="text-xs text-red-500">{error}</p>}
|
||||
|
||||
{processing ? (
|
||||
@@ -105,13 +164,23 @@ export function ConvertAudioControls({ settings: initial, onChange }: ConvertAud
|
||||
const s = t.toolSettings["convert-audio"];
|
||||
const [outFormat, setOutFormat] = useState<AudioFormat>("mp3");
|
||||
const [bitrateKbps, setBitrateKbps] = useState(192);
|
||||
// 0 = preserve the source sample rate (omit the setting).
|
||||
const [sampleRate, setSampleRate] = useState(0);
|
||||
|
||||
const initializedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!initial || initializedRef.current) return;
|
||||
initializedRef.current = true;
|
||||
if (initial.format != null) setOutFormat(initial.format as AudioFormat);
|
||||
if (initial.bitrateKbps != null) setBitrateKbps(Number(initial.bitrateKbps));
|
||||
const format = initial.format != null ? (initial.format as AudioFormat) : "mp3";
|
||||
if (initial.format != null) setOutFormat(format);
|
||||
// Sanitize stored values so the selects always show what will be emitted:
|
||||
// a rate the UI cannot represent falls back to preserve-original.
|
||||
const rawRate = initial.sampleRate != null ? Number(initial.sampleRate) : 0;
|
||||
const rate = sampleRatesFor(format).includes(rawRate) ? rawRate : 0;
|
||||
if (rate) setSampleRate(rate);
|
||||
if (initial.bitrateKbps != null) {
|
||||
setBitrateKbps(reconcileBitrate(Number(initial.bitrateKbps), bitratesFor(format, rate)));
|
||||
}
|
||||
}, [initial]);
|
||||
|
||||
const onChangeRef = useRef(onChange);
|
||||
@@ -119,8 +188,24 @@ export function ConvertAudioControls({ settings: initial, onChange }: ConvertAud
|
||||
onChangeRef.current = onChange;
|
||||
});
|
||||
useEffect(() => {
|
||||
onChangeRef.current?.({ format: outFormat, bitrateKbps });
|
||||
}, [outFormat, bitrateKbps]);
|
||||
onChangeRef.current?.({
|
||||
format: outFormat,
|
||||
bitrateKbps,
|
||||
...(sampleRate ? { sampleRate } : {}),
|
||||
});
|
||||
}, [outFormat, bitrateKbps, sampleRate]);
|
||||
|
||||
const handleFormatChange = (format: AudioFormat) => {
|
||||
setOutFormat(format);
|
||||
const rate = sampleRatesFor(format).includes(sampleRate) ? sampleRate : 0;
|
||||
if (rate !== sampleRate) setSampleRate(rate);
|
||||
setBitrateKbps((b) => reconcileBitrate(b, bitratesFor(format, rate)));
|
||||
};
|
||||
|
||||
const handleSampleRateChange = (rate: number) => {
|
||||
setSampleRate(rate);
|
||||
setBitrateKbps((b) => reconcileBitrate(b, bitratesFor(outFormat, rate)));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -131,7 +216,7 @@ export function ConvertAudioControls({ settings: initial, onChange }: ConvertAud
|
||||
<select
|
||||
id="ca-format"
|
||||
value={outFormat}
|
||||
onChange={(e) => setOutFormat(e.target.value as AudioFormat)}
|
||||
onChange={(e) => handleFormatChange(e.target.value as AudioFormat)}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
>
|
||||
<option value="mp3">MP3</option>
|
||||
@@ -151,13 +236,31 @@ export function ConvertAudioControls({ settings: initial, onChange }: ConvertAud
|
||||
onChange={(e) => setBitrateKbps(Number(e.target.value))}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
>
|
||||
{BITRATE_OPTIONS.map((br) => (
|
||||
{bitratesFor(outFormat, sampleRate).map((br) => (
|
||||
<option key={br} value={br}>
|
||||
{br} kbps
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="ca-samplerate" className="text-xs text-muted-foreground">
|
||||
{s.sampleRate}
|
||||
</label>
|
||||
<select
|
||||
id="ca-samplerate"
|
||||
value={sampleRate}
|
||||
onChange={(e) => handleSampleRateChange(Number(e.target.value))}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
>
|
||||
<option value={0}>{s.sampleRatePreserve}</option>
|
||||
{sampleRatesFor(outFormat).map((r) => (
|
||||
<option key={r} value={r}>
|
||||
{r} Hz
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2489,6 +2489,8 @@ export const ar: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "تنسيق الإخراج",
|
||||
bitrate: "معدل البت (kbps)",
|
||||
sampleRate: "معدل أخذ العينات (Hz)",
|
||||
sampleRatePreserve: "الاحتفاظ بالأصلي",
|
||||
submit: "تحويل",
|
||||
submitBatch: "تحويل ({count} ملفات)",
|
||||
progressLabel: "جارٍ التحويل",
|
||||
|
||||
@@ -2512,6 +2512,8 @@ export const de: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Ausgabeformat",
|
||||
bitrate: "Bitrate (kbps)",
|
||||
sampleRate: "Abtastrate (Hz)",
|
||||
sampleRatePreserve: "Original beibehalten",
|
||||
submit: "Konvertieren",
|
||||
submitBatch: "Konvertieren ({count} Dateien)",
|
||||
progressLabel: "Wird konvertiert",
|
||||
|
||||
@@ -2453,6 +2453,8 @@ export const en = {
|
||||
"convert-audio": {
|
||||
format: "Output format",
|
||||
bitrate: "Bitrate (kbps)",
|
||||
sampleRate: "Sample rate (Hz)",
|
||||
sampleRatePreserve: "Preserve original",
|
||||
submit: "Convert",
|
||||
submitBatch: "Convert ({count} files)",
|
||||
progressLabel: "Converting",
|
||||
|
||||
@@ -2493,6 +2493,8 @@ export const es: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Formato de salida",
|
||||
bitrate: "Tasa de bits (kbps)",
|
||||
sampleRate: "Frecuencia de muestreo (Hz)",
|
||||
sampleRatePreserve: "Mantener original",
|
||||
submit: "Convertir",
|
||||
submitBatch: "Convertir ({count} archivos)",
|
||||
progressLabel: "Convirtiendo",
|
||||
|
||||
@@ -2519,6 +2519,8 @@ export const fr: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Format de sortie",
|
||||
bitrate: "Débit (kbps)",
|
||||
sampleRate: "Fréquence d'échantillonnage (Hz)",
|
||||
sampleRatePreserve: "Conserver l'originale",
|
||||
submit: "Convertir",
|
||||
submitBatch: "Convertir ({count} fichiers)",
|
||||
progressLabel: "Conversion",
|
||||
|
||||
@@ -2319,6 +2319,8 @@ export const hi: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "आउटपुट फ़ॉर्मैट",
|
||||
bitrate: "बिटरेट (kbps)",
|
||||
sampleRate: "सैंपल रेट (Hz)",
|
||||
sampleRatePreserve: "मूल बनाए रखें",
|
||||
submit: "कन्वर्ट करें",
|
||||
submitBatch: "कन्वर्ट करें ({count} फ़ाइलें)",
|
||||
progressLabel: "कन्वर्ट हो रहा है",
|
||||
|
||||
@@ -2502,6 +2502,8 @@ export const id: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Format keluaran",
|
||||
bitrate: "Bitrate (kbps)",
|
||||
sampleRate: "Laju sampel (Hz)",
|
||||
sampleRatePreserve: "Pertahankan asli",
|
||||
submit: "Konversi",
|
||||
submitBatch: "Konversi ({count} file)",
|
||||
progressLabel: "Mengonversi",
|
||||
|
||||
@@ -2507,6 +2507,8 @@ export const it: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Formato di output",
|
||||
bitrate: "Bitrate (kbps)",
|
||||
sampleRate: "Frequenza di campionamento (Hz)",
|
||||
sampleRatePreserve: "Mantieni originale",
|
||||
submit: "Converti",
|
||||
submitBatch: "Converti ({count} file)",
|
||||
progressLabel: "Conversione",
|
||||
|
||||
@@ -2462,6 +2462,8 @@ export const ja: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "出力形式",
|
||||
bitrate: "ビットレート (kbps)",
|
||||
sampleRate: "サンプルレート (Hz)",
|
||||
sampleRatePreserve: "元のまま維持",
|
||||
submit: "変換",
|
||||
submitBatch: "変換 ({count} ファイル)",
|
||||
progressLabel: "変換中",
|
||||
|
||||
@@ -2442,6 +2442,8 @@ export const ko: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "출력 형식",
|
||||
bitrate: "비트레이트 (kbps)",
|
||||
sampleRate: "샘플 레이트 (Hz)",
|
||||
sampleRatePreserve: "원본 유지",
|
||||
submit: "변환",
|
||||
submitBatch: "변환 ({count}개 파일)",
|
||||
progressLabel: "변환 중",
|
||||
|
||||
@@ -2508,6 +2508,8 @@ export const nl: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Uitvoerformaat",
|
||||
bitrate: "Bitrate (kbps)",
|
||||
sampleRate: "Samplefrequentie (Hz)",
|
||||
sampleRatePreserve: "Origineel behouden",
|
||||
submit: "Converteren",
|
||||
submitBatch: "Converteren ({count} bestanden)",
|
||||
progressLabel: "Converteren",
|
||||
|
||||
@@ -2506,6 +2506,8 @@ export const pl: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Format wyjściowy",
|
||||
bitrate: "Przepływność (kbps)",
|
||||
sampleRate: "Częstotliwość próbkowania (Hz)",
|
||||
sampleRatePreserve: "Zachowaj oryginalną",
|
||||
submit: "Konwertuj",
|
||||
submitBatch: "Konwertuj ({count} plików)",
|
||||
progressLabel: "Konwertowanie",
|
||||
|
||||
@@ -2504,6 +2504,8 @@ export const ptBR: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Formato de saída",
|
||||
bitrate: "Taxa de bits (kbps)",
|
||||
sampleRate: "Taxa de amostragem (Hz)",
|
||||
sampleRatePreserve: "Manter original",
|
||||
submit: "Converter",
|
||||
submitBatch: "Converter ({count} arquivos)",
|
||||
progressLabel: "Convertendo",
|
||||
|
||||
@@ -2504,6 +2504,8 @@ export const ru: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Формат вывода",
|
||||
bitrate: "Битрейт (kbps)",
|
||||
sampleRate: "Частота дискретизации (Hz)",
|
||||
sampleRatePreserve: "Сохранить исходную",
|
||||
submit: "Конвертировать",
|
||||
submitBatch: "Конвертировать ({count} файлов)",
|
||||
progressLabel: "Конвертация",
|
||||
|
||||
@@ -2501,6 +2501,8 @@ export const sv: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Utdataformat",
|
||||
bitrate: "Bithastighet (kbps)",
|
||||
sampleRate: "Samplingsfrekvens (Hz)",
|
||||
sampleRatePreserve: "Behåll original",
|
||||
submit: "Konvertera",
|
||||
submitBatch: "Konvertera ({count} filer)",
|
||||
progressLabel: "Konverterar",
|
||||
|
||||
@@ -2473,6 +2473,8 @@ export const th: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "รูปแบบเอาต์พุต",
|
||||
bitrate: "บิตเรต (kbps)",
|
||||
sampleRate: "อัตราสุ่มตัวอย่าง (Hz)",
|
||||
sampleRatePreserve: "คงค่าเดิม",
|
||||
submit: "แปลง",
|
||||
submitBatch: "แปลง ({count} ไฟล์)",
|
||||
progressLabel: "กำลังแปลง",
|
||||
|
||||
@@ -2506,6 +2506,8 @@ export const tr: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Çıktı formatı",
|
||||
bitrate: "Bit hızı (kbps)",
|
||||
sampleRate: "Örnekleme hızı (Hz)",
|
||||
sampleRatePreserve: "Orijinali koru",
|
||||
submit: "Dönüştür",
|
||||
submitBatch: "Dönüştür ({count} dosya)",
|
||||
progressLabel: "Dönüştürülüyor",
|
||||
|
||||
@@ -2504,6 +2504,8 @@ export const uk: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Вихідний формат",
|
||||
bitrate: "Бітрейт (kbps)",
|
||||
sampleRate: "Частота дискретизації (Hz)",
|
||||
sampleRatePreserve: "Зберегти вихідну",
|
||||
submit: "Конвертувати",
|
||||
submitBatch: "Конвертувати ({count} файлів)",
|
||||
progressLabel: "Конвертація",
|
||||
|
||||
@@ -2503,6 +2503,8 @@ export const vi: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "Định dạng đầu ra",
|
||||
bitrate: "Tốc độ bit (kbps)",
|
||||
sampleRate: "Tần số lấy mẫu (Hz)",
|
||||
sampleRatePreserve: "Giữ nguyên gốc",
|
||||
submit: "Chuyển đổi",
|
||||
submitBatch: "Chuyển đổi ({count} tệp)",
|
||||
progressLabel: "Đang chuyển đổi",
|
||||
|
||||
@@ -2261,6 +2261,8 @@ export const zhCN: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "输出格式",
|
||||
bitrate: "比特率 (kbps)",
|
||||
sampleRate: "采样率 (Hz)",
|
||||
sampleRatePreserve: "保留原始",
|
||||
submit: "转换",
|
||||
submitBatch: "转换({count} 个文件)",
|
||||
progressLabel: "正在转换",
|
||||
|
||||
@@ -2261,6 +2261,8 @@ export const zhTW: TranslationKeys = {
|
||||
"convert-audio": {
|
||||
format: "輸出格式",
|
||||
bitrate: "位元率 (kbps)",
|
||||
sampleRate: "取樣率 (Hz)",
|
||||
sampleRatePreserve: "保留原始",
|
||||
submit: "轉換",
|
||||
submitBatch: "轉換({count} 個檔案)",
|
||||
progressLabel: "正在轉換",
|
||||
|
||||
@@ -795,6 +795,13 @@ const SETTINGS_VARIATIONS: Record<string, Variation[]> = {
|
||||
{ label: "bitrate min", settings: { format: "mp3", bitrateKbps: 32 } },
|
||||
{ label: "bitrate mid", settings: { format: "mp3", bitrateKbps: 128 } },
|
||||
{ label: "bitrate max", settings: { format: "mp3", bitrateKbps: 320 } },
|
||||
{ label: "sample rate min", settings: { format: "mp3", sampleRate: 8000, bitrateKbps: 64 } },
|
||||
{ label: "sample rate 44100", settings: { format: "mp3", sampleRate: 44100 } },
|
||||
{ label: "sample rate max mp3", settings: { format: "mp3", sampleRate: 48000 } },
|
||||
{ label: "sample rate max wav", settings: { format: "wav", sampleRate: 96000 } },
|
||||
{ label: "sample rate ogg", settings: { format: "ogg", sampleRate: 44100 } },
|
||||
{ label: "sample rate m4a", settings: { format: "m4a", sampleRate: 96000 } },
|
||||
{ label: "sample rate flac", settings: { format: "flac", sampleRate: 48000 } },
|
||||
],
|
||||
|
||||
"trim-audio": [
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { ffmpegAvailable } from "@snapotter/media-engine";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { fixtures, readFixture } from "../../../fixtures/index.js";
|
||||
@@ -36,6 +40,24 @@ async function runTool(settings: Record<string, unknown>, file = WAV, filename =
|
||||
});
|
||||
}
|
||||
|
||||
function probeSampleRate(payload: Buffer, filename: string): string {
|
||||
const tmpDir = mkdtempSync(join(tmpdir(), "convert-audio-test-"));
|
||||
const probeFile = join(tmpDir, filename);
|
||||
writeFileSync(probeFile, payload);
|
||||
const result = spawnSync("ffprobe", [
|
||||
"-v",
|
||||
"error",
|
||||
"-select_streams",
|
||||
"a:0",
|
||||
"-show_entries",
|
||||
"stream=sample_rate",
|
||||
"-of",
|
||||
"csv=p=0",
|
||||
probeFile,
|
||||
]);
|
||||
return result.stdout.toString().trim();
|
||||
}
|
||||
|
||||
describe.skipIf(!ffmpegAvailable())("convert-audio (requires ffmpeg)", () => {
|
||||
it("converts wav to mp3 and returns 200", async () => {
|
||||
const res = await runTool({ format: "mp3" });
|
||||
@@ -68,6 +90,66 @@ describe.skipIf(!ffmpegAvailable())("convert-audio (requires ffmpeg)", () => {
|
||||
expect(outName.endsWith(".ogg")).toBe(true);
|
||||
}, 60_000);
|
||||
|
||||
it("resamples to 44100 Hz when sampleRate is set", async () => {
|
||||
// tiny.wav is 8 kHz; the output must carry the requested rate.
|
||||
const res = await runTool({ format: "mp3", sampleRate: 44100 });
|
||||
expect(res.statusCode).toBe(200);
|
||||
const envelope = JSON.parse(res.body);
|
||||
const dl = await testApp.app.inject({ method: "GET", url: envelope.downloadUrl });
|
||||
expect(dl.statusCode).toBe(200);
|
||||
expect(probeSampleRate(dl.rawPayload, "out.mp3")).toBe("44100");
|
||||
}, 60_000);
|
||||
|
||||
it("preserves the source sample rate when sampleRate is omitted", async () => {
|
||||
const res = await runTool({ format: "mp3" });
|
||||
expect(res.statusCode).toBe(200);
|
||||
const envelope = JSON.parse(res.body);
|
||||
const dl = await testApp.app.inject({ method: "GET", url: envelope.downloadUrl });
|
||||
expect(dl.statusCode).toBe(200);
|
||||
expect(probeSampleRate(dl.rawPayload, "out.mp3")).toBe("8000");
|
||||
}, 60_000);
|
||||
|
||||
it("resamples to 96000 Hz for wav output", async () => {
|
||||
const res = await runTool({ format: "wav", sampleRate: 96000 });
|
||||
expect(res.statusCode).toBe(200);
|
||||
const envelope = JSON.parse(res.body);
|
||||
const dl = await testApp.app.inject({ method: "GET", url: envelope.downloadUrl });
|
||||
expect(dl.statusCode).toBe(200);
|
||||
expect(probeSampleRate(dl.rawPayload, "out.wav")).toBe("96000");
|
||||
}, 60_000);
|
||||
|
||||
it("rejects 96000 Hz for mp3 output (libmp3lame caps at 48000)", async () => {
|
||||
const res = await runTool({ format: "mp3", sampleRate: 96000 });
|
||||
expect(res.statusCode).toBe(400);
|
||||
expect(JSON.parse(res.body).error).toBe("Invalid settings");
|
||||
});
|
||||
|
||||
it("rejects a sample rate outside the supported set with an actionable message", async () => {
|
||||
const res = await runTool({ format: "wav", sampleRate: 12345 });
|
||||
expect(res.statusCode).toBe(400);
|
||||
const body = JSON.parse(res.body);
|
||||
expect(body.error).toBe("Invalid settings");
|
||||
// API users should see the accepted set, not zod's generic "Invalid input".
|
||||
expect(body.details).toContain("8000");
|
||||
expect(body.details).toContain("96000");
|
||||
});
|
||||
|
||||
it("rejects a bitrate above the MP3 ceiling for low sample rates", async () => {
|
||||
// libmp3lame would silently clamp 192 kbps to 64 kbps at 8 kHz.
|
||||
const res = await runTool({ format: "mp3", sampleRate: 8000 });
|
||||
expect(res.statusCode).toBe(400);
|
||||
expect(JSON.parse(res.body).error).toBe("Invalid settings");
|
||||
});
|
||||
|
||||
it("converts mp3 at 8000 Hz with a bitrate under the ceiling", async () => {
|
||||
const res = await runTool({ format: "mp3", sampleRate: 8000, bitrateKbps: 64 });
|
||||
expect(res.statusCode).toBe(200);
|
||||
const envelope = JSON.parse(res.body);
|
||||
const dl = await testApp.app.inject({ method: "GET", url: envelope.downloadUrl });
|
||||
expect(dl.statusCode).toBe(200);
|
||||
expect(probeSampleRate(dl.rawPayload, "out.mp3")).toBe("8000");
|
||||
}, 60_000);
|
||||
|
||||
it("converts 8 kHz wav to ogg (regression: libvorbis low samplerate)", async () => {
|
||||
// tiny.wav is 8 kHz; a fixed bitrate (-b:a) made libvorbis "encoder setup failed".
|
||||
// The ogg path now uses -q:a (quality VBR), which adapts to the sample rate.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { cleanup, render, screen } from "@testing-library/react";
|
||||
import { cleanup, render, screen, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { ConvertAudioControls } from "@/components/tools/convert-audio-settings";
|
||||
@@ -42,6 +42,73 @@ describe("ConvertAudioControls", () => {
|
||||
expect.objectContaining({ format: "wav", bitrateKbps: 256 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("omits sampleRate by default (preserve original)", () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ConvertAudioControls onChange={onChange} />);
|
||||
expect(onChange.mock.lastCall?.[0]).not.toHaveProperty("sampleRate");
|
||||
});
|
||||
|
||||
it("emits the chosen sample rate on change", async () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ConvertAudioControls onChange={onChange} />);
|
||||
await userEvent.selectOptions(screen.getByLabelText(/sample rate/i), "44100");
|
||||
expect(onChange).toHaveBeenLastCalledWith(expect.objectContaining({ sampleRate: 44100 }));
|
||||
});
|
||||
|
||||
it("initializes sampleRate from incoming settings", () => {
|
||||
const onChange = vi.fn();
|
||||
render(
|
||||
<ConvertAudioControls settings={{ format: "wav", sampleRate: 48000 }} onChange={onChange} />,
|
||||
);
|
||||
expect(onChange).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ format: "wav", sampleRate: 48000 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("caps bitrate options for low mp3 sample rates and resets the bitrate", async () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ConvertAudioControls onChange={onChange} />);
|
||||
await userEvent.selectOptions(screen.getByLabelText(/sample rate/i), "8000");
|
||||
// 192 kbps is illegal at 8 kHz (libmp3lame caps at 64); the control must
|
||||
// reset to a legal value rather than let ffmpeg clamp silently.
|
||||
expect(onChange).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ sampleRate: 8000, bitrateKbps: 64 }),
|
||||
);
|
||||
const bitrateSelect = screen.getByLabelText(/bitrate/i);
|
||||
const options = [...bitrateSelect.querySelectorAll("option")].map((o) => o.value);
|
||||
expect(options).toEqual(["32", "48", "64"]);
|
||||
|
||||
// Moving back to a full-range rate restores the regular options.
|
||||
await userEvent.selectOptions(screen.getByLabelText(/sample rate/i), "44100");
|
||||
expect(onChange).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ sampleRate: 44100, bitrateKbps: 192 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("sanitizes an out-of-range stored sampleRate to preserve-original", () => {
|
||||
const onChange = vi.fn();
|
||||
render(
|
||||
<ConvertAudioControls settings={{ format: "mp3", sampleRate: 96000 }} onChange={onChange} />,
|
||||
);
|
||||
// A stale or API-written value the UI cannot represent must not be emitted
|
||||
// behind a blank select.
|
||||
expect(onChange.mock.lastCall?.[0]).toMatchObject({ format: "mp3" });
|
||||
expect(onChange.mock.lastCall?.[0]).not.toHaveProperty("sampleRate");
|
||||
});
|
||||
|
||||
it("hides 96 kHz for mp3 and drops it when switching to mp3", async () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ConvertAudioControls settings={{ format: "wav" }} onChange={onChange} />);
|
||||
const rateSelect = screen.getByLabelText(/sample rate/i);
|
||||
await userEvent.selectOptions(rateSelect, "96000");
|
||||
expect(onChange).toHaveBeenLastCalledWith(expect.objectContaining({ sampleRate: 96000 }));
|
||||
|
||||
await userEvent.selectOptions(screen.getByLabelText(/output format/i), "mp3");
|
||||
expect(onChange.mock.lastCall?.[0]).toMatchObject({ format: "mp3" });
|
||||
expect(onChange.mock.lastCall?.[0]).not.toHaveProperty("sampleRate");
|
||||
expect(within(rateSelect).queryByRole("option", { name: /96000/ })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("TrimVideoControls", async () => {
|
||||
|
||||
Reference in New Issue
Block a user