Skip to content

DocsGuides

Compress and convert

Re-encode a video to a smaller file or another format with JSON: codec, quality, container and frame rate.

Re-encode a video to a smaller file, another codec or another container. You choose the codec and a quality; the API writes the encoder settings, keeps the shape and size of the picture, and puts an MP4's index at the front so it starts playing before the download ends.

The request#

bash
curl "$VIDEXO_API_URL/v1/transcode" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "https://example.com/talk.mp4",
  "filename": "talk-small.mp4",
  "video": {
    "codec": "h264",
    "crf": 28,
    "encoder_preset": "veryfast"
  },
  "audio": {
    "codec": "aac",
    "bitrate": "128k"
  }
}'

talk-small.mp4: H.264 video at CRF 28 with AAC audio at 128 kbit/s, its index at the front so it plays before the whole file has arrived.

Options that matter#

  • video.codec: h264 plays everywhere; h265 and av1 are smaller at the same quality, vp9 and av1 go in WebM. VP9 and AV1 take several times longer to encode, which counts against your plan's longest job.
  • video.quality (low, medium, high, lossless) or video.crf: constant quality. A lower CRF is a better picture and a larger file (Quality).
  • video.max_bitrate: a ceiling for players and networks that need one.
  • format, or the extension of filename: mp4, mov, webm, mkv or ts.

WebM for browsers#

bash
curl "$VIDEXO_API_URL/v1/transcode" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "https://example.com/talk.mp4",
  "filename": "talk.webm",
  "video": {
    "codec": "vp9",
    "crf": 32,
    "max_bitrate": "2M"
  },
  "audio": {
    "codec": "opus",
    "bitrate": "96k"
  }
}'

talk.webm: VP9 video at CRF 32 capped at 2 Mbit/s, with Opus audio at 96 kbit/s.

A constant frame rate#

bash
curl "$VIDEXO_API_URL/v1/transcode" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "https://example.com/talk.mp4",
  "filename": "talk-30fps.mp4",
  "fps": 30,
  "audio": {
    "codec": "copy"
  }
}'

talk-30fps.mp4: the video at a constant 30 frames a second, the audio copied as it was.

Only change the container#

"codec": "copy" passes the streams through without re-encoding, which takes seconds instead of minutes. Options that change the picture or the sound are rejected with it.

bash
curl "$VIDEXO_API_URL/v1/transcode" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "https://example.com/talk.mp4",
  "filename": "talk.mkv",
  "video": {
    "codec": "copy"
  },
  "audio": {
    "codec": "copy"
  }
}'