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.

Reduce video file size by re-encoding at a higher CRF value and lower audio bitrate. Useful for faster uploads, email-friendly sizes, or bandwidth-limited playback.

Code

const API_KEY = process.env.RENDI_API_KEY;

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: "compressed.mp4",
    },
    ffmpeg_command:
      "-i {{in_1}} -c:v libx264 -preset slow -crf 28 -c:a aac -b:a 96k {{out_1}}",
  }),
});
const { command_id } = await submit.json();

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("Compressed 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

  • -crf 28 — higher CRF = smaller file (23 is default, 28 is visibly compressed but acceptable; push to 30–32 for aggressive size reduction)
  • -preset slow — slower encoder uses more analysis and produces a smaller file at the same quality
  • -c:a aac -b:a 96k — AAC audio at 96 kbps (down from 192 kbps)
  • {{out_1}} — output file
Tune -crf first; only drop the audio bitrate further if size is still too high.

Response

{
  "output_files": {
    "out_1": {
      "file_id": "c1a4e3f7-...",
      "size_mbytes": 5.8,
      "duration": 596.459,
      "file_type": "video",
      "file_format": "mp4",
      "storage_url": "https://storage.rendi.dev/temp_files/.../compressed.mp4",
      "width": 854,
      "height": 480,
      "codec": "h264",
      "bitrate_video_kb": 72.3,
      "bitrate_audio_kb": 96.0
    }
  },
  "status": "SUCCESS",
  "command_type": "FFMPEG_COMMAND"
}