Skip to main content

Documentation Index

Fetch the complete documentation index at: https://rendi.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

Extract the audio track from a video and save it as MP3. Useful when you want to strip audio out for transcription, podcast generation, or separate audio processing.

Code

const API_KEY = process.env.RENDI_API_KEY;

// Submit the FFmpeg command
const submit = await fetch("https://api.rendi.dev/v1/run-ffmpeg-command", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-KEY": API_KEY,
  },
  body: JSON.stringify({
    input_files: {
      in_1: "https://storage.rendi.dev/sample/sample.avi",
    },
    output_files: {
      out_1: "audio.mp3",
    },
    ffmpeg_command: "-i {{in_1}} -vn -c:a libmp3lame -q:a 2 {{out_1}}",
  }),
});
const { command_id } = await submit.json();

// Poll until complete
while (true) {
  const res = await fetch(`https://api.rendi.dev/v1/commands/${command_id}`, {
    headers: { "X-API-KEY": API_KEY },
  });
  const data = await res.json();
  if (data.status === "SUCCESS") {
    console.log("Audio URL:", data.output_files.out_1.storage_url);
    break;
  }
  if (data.status === "FAILED") throw new Error("Command failed");
  await new Promise((r) => setTimeout(r, 2000));
}

How the FFmpeg command works

  • -i {{in_1}} — input video URL
  • -vn — discard the video stream (audio only)
  • -c:a libmp3lame — encode audio as MP3
  • -q:a 2 — variable-bitrate quality (0 = best, 9 = worst; 2 is a good balance)
  • {{out_1}} — output file (audio.mp3)
To export as WAV, rename out_1 to audio.wav and drop the -c:a libmp3lame -q:a 2 flags — FFmpeg picks the codec from the extension.

Response

{
  "output_files": {
    "out_1": {
      "file_id": "eba1a713-4631-4ccb-9ef8-b727a9f7f274",
      "size_mbytes": 4.62,
      "duration": 596.459,
      "file_type": "audio",
      "file_format": "mp3",
      "storage_url": "https://storage.rendi.dev/temp_files/.../audio.mp3",
      "bitrate_audio_kb": 128.0
    }
  },
  "status": "SUCCESS",
  "command_type": "FFMPEG_COMMAND"
}