ffmpegapitutorialvideo-processinggetting-started

Getting Started with FFmpeg Micro: 5 API Examples

·Javid Jamae·6 min read
Getting Started with FFmpeg Micro: 5 API Examples

You signed up for FFmpeg Micro. You have an API key. Now what?

This tutorial walks through five real use cases with working code. Each example builds on the same upload-transcode-download workflow, so once you get the pattern down, you can adapt it to pretty much anything.

The Basic Workflow

Every FFmpeg Micro job follows the same five steps:

  1. Request a presigned upload URL
  2. Upload your video file
  3. Confirm the upload
  4. Create a transcode job
  5. Poll for completion and download

Steps 1 through 3 are identical for every example below. I'll show them once here, then focus on the transcode configuration for each use case.

# Step 1: Get a presigned upload URL
RESPONSE=$(curl -s -X POST https://api.ffmpeg-micro.com/v1/upload/presigned-url \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "filename": "input.mp4",
    "contentType": "video/mp4",
    "fileSize": 15728640
  }')

UPLOAD_URL=$(echo $RESPONSE | jq -r '.result.uploadUrl')
FILENAME=$(echo $RESPONSE | jq -r '.result.filename')

# Step 2: Upload the file
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: video/mp4" \
  --data-binary @input.mp4

# Step 3: Confirm upload
curl -s -X POST https://api.ffmpeg-micro.com/v1/upload/confirm \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d "{\"filename\": \"$FILENAME\", \"fileSize\": 15728640}"

One thing to watch out for: fileSize must be a JSON number, not a string. Sending "15728640" instead of 15728640 will get you a 400 error.

Example 1: Transcode MP4 to WebM

WebM is the go-to format for web video. Smaller files, better browser support, and VP9 encoding gives you solid quality at lower bitrates.

JOB=$(curl -s -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "inputs": [{"url": "gs://YOUR_BUCKET/'"$FILENAME"'"}],
    "outputFormat": "webm",
    "preset": {
      "quality": "medium",
      "resolution": "1080p"
    }
  }')

JOB_ID=$(echo $JOB | jq -r '.id')
echo "Job created: $JOB_ID"

The preset approach is the simplest way to transcode. You pick a quality level (low, medium, high) and a resolution, and FFmpeg Micro handles the codec settings.

For most web video, medium quality at 1080p hits the sweet spot between file size and visual quality.

Example 2: Resize Video to 720p

Maybe you're building a platform where users upload 4K footage but you only need to serve 720p. The preset system handles this cleanly.

JOB=$(curl -s -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "inputs": [{"url": "gs://YOUR_BUCKET/'"$FILENAME"'"}],
    "outputFormat": "mp4",
    "preset": {
      "quality": "high",
      "resolution": "720p"
    }
  }')

This re-encodes the video at 720p with high quality settings. The output file will be significantly smaller than the original 4K source, and for most screens, your users won't notice the difference.

Example 3: Extract Audio from Video

Need just the audio track? Maybe you're building a podcast clipper or pulling voiceovers from video content. Switch the output format to an audio container and use advanced mode to control the codec.

JOB=$(curl -s -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "inputs": [{"url": "gs://YOUR_BUCKET/'"$FILENAME"'"}],
    "outputFormat": "mp3",
    "options": [
      {"option": "-vn", "argument": ""},
      {"option": "-c:a", "argument": "libmp3lame"},
      {"option": "-b:a", "argument": "192k"}
    ]
  }')

The -vn flag strips the video stream. -c:a libmp3lame sets the audio codec to MP3, and -b:a 192k gives you good audio quality without bloating the file. If you want lossless audio, swap mp3 for flac and drop the bitrate flag.

Example 4: Add a Text Watermark

Branding your videos before distribution? FFmpeg Micro supports text overlays through the @text-overlay virtual option. No need to mess with raw FFmpeg filter syntax.

JOB=$(curl -s -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "inputs": [{"url": "gs://YOUR_BUCKET/'"$FILENAME"'"}],
    "outputFormat": "mp4",
    "options": [
      {"option": "-c:v", "argument": "libx264"},
      {"option": "-crf", "argument": "23"},
      {"option": "@text-overlay", "argument": {
        "text": "© My Company 2026",
        "style": {
          "fontSize": 24,
          "fontColor": "white",
          "x": "w-text_w-20",
          "y": "h-text_h-20"
        }
      }}
    ]
  }')

The x and y values use FFmpeg expression syntax. w-text_w-20 positions the text 20 pixels from the right edge. h-text_h-20 puts it 20 pixels from the bottom. You can place text anywhere on the frame using these expressions.

This is one of those things that takes 30 minutes to figure out in raw FFmpeg. With the @text-overlay virtual option, it's just a JSON object.

Example 5: Generate a Thumbnail

Every video platform needs thumbnails. You can grab a single frame from any point in the video by outputting to an image format.

JOB=$(curl -s -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "inputs": [{"url": "gs://YOUR_BUCKET/'"$FILENAME"'"}],
    "outputFormat": "jpg",
    "options": [
      {"option": "-ss", "argument": "00:00:05"},
      {"option": "-frames:v", "argument": "1"},
      {"option": "-q:v", "argument": "2"}
    ]
  }')

-ss 00:00:05 seeks to 5 seconds into the video. -frames:v 1 grabs exactly one frame. -q:v 2 sets JPEG quality (lower number means higher quality, range is 2 to 31).

If you don't know which frame will look best, you could create multiple jobs seeking to different timestamps and let your users pick.

Polling for Completion

After creating any transcode job, poll the status endpoint until it's done.

while true; do
  STATUS=$(curl -s https://api.ffmpeg-micro.com/v1/transcodes/$JOB_ID \
    -H "Authorization: Bearer $API_KEY" | jq -r '.status')
  
  if [ "$STATUS" = "completed" ]; then
    echo "Done! Downloading..."
    DOWNLOAD=$(curl -s https://api.ffmpeg-micro.com/v1/transcodes/$JOB_ID/download \
      -H "Authorization: Bearer $API_KEY" | jq -r '.url')
    curl -o output.mp4 "$DOWNLOAD"
    break
  elif [ "$STATUS" = "failed" ]; then
    echo "Job failed"
    break
  fi
  
  echo "Status: $STATUS. Waiting..."
  sleep 5
done

Most jobs finish within a couple of minutes depending on file size and the complexity of your transcode settings.

What to Build Next

These five examples cover the most common video processing tasks, but they're just the starting point. You can chain operations together, use custom FFmpeg flags for fine-grained control, or integrate these API calls into automation platforms like n8n or Make.

If you don't have an account yet, sign up for free and grab your API key from the dashboard. The free tier gives you enough processing minutes to test all five examples above.

Ready to process videos at scale?

Start using FFmpeg Micro's simple API today. No infrastructure required.

Get Started Free