Guide

Extract audio from a video with an API

How do I get the audio track out of a video over an API?

Drop the video stream with -vn and encode what's left. -c:a libmp3lame -q:a 2 gives a ~190 kbps VBR MP3, which is the usual choice when the file has to play everywhere.

The ffmpeg command

What you would run locally, for reference.

ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3

The API request

The same flags, sent as JSON. Authenticate with Authorization: Token <your-api-token>.

POST /api/ffmpeg/job/
{
  "global_options": [
    "-y"
  ],
  "inputs": [
    {
      "input_source": "https://example.com/input.mp4"
    }
  ],
  "outputs": [
    {
      "filename": "output.mp3",
      "options": [
        "-vn",
        "-c:a",
        "libmp3lame",
        "-q:a",
        "2"
      ]
    }
  ]
}

Worth knowing

  • To avoid re-encoding entirely, use -vn -c:a copy and name the output for whatever codec is already inside — usually .m4a for AAC. It is faster, cheaper and lossless, but you don't get to pick the format.
  • -q:a runs backwards from CRF: 0 is the best quality, 9 the worst.

What it costs

Jobs bill in processing seconds — the CPU time this one actually uses — with a floor of 25 seconds per GB pulled out of storage to run it, so a stream-copy still counts. Uploading the output and downloading it afterwards are free. See the plans.

Related guides

Start free API reference

Ask me for anything

QuickFFmpeg is early and plenty is still missing. Tell me what you need and it goes straight to the top of my list.

This arrives anonymously. Log in first if you'd like an answer.