# Workflow Utilities Extract Nth Frame

> FFMPEG Untility for Extracting nth Frame


## Overview

- **Endpoint**: `https://fal.run/fal-ai/workflow-utilities/extract-nth-frame`
- **Model ID**: `fal-ai/workflow-utilities/extract-nth-frame`
- **Category**: image-to-image
- **Kind**: inference


## Pricing

- **Price**: $0.001 per compute seconds

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`video_url`** (`string`, _required_):
  URL of the video file to extract frames from
  - Examples: "https://storage.googleapis.com/falserverless/example_outputs/wan-25-i2v-output.mp4"

- **`frame_interval`** (`integer`, _optional_):
  Extract every Nth frame (e.g., 3 = every 3rd frame, 12 = every 12th frame) Default value: `12`
  - Default: `12`
  - Range: `1` to `300`

- **`output_format`** (`OutputFormatEnum`, _optional_):
  Output format for extracted frames Default value: `"png"`
  - Default: `"png"`
  - Options: `"png"`, `"jpg"`, `"jpeg"`, `"webp"`

- **`max_frames`** (`integer`, _optional_):
  Maximum number of frames to extract Default value: `100`
  - Default: `100`
  - Range: `1` to `500`

- **`quality`** (`integer`, _optional_):
  Quality for jpg/webp output (1-100) Default value: `95`
  - Default: `95`
  - Range: `1` to `100`



**Required Parameters Example**:

```json
{
  "video_url": "https://storage.googleapis.com/falserverless/example_outputs/wan-25-i2v-output.mp4"
}
```

**Full Example**:

```json
{
  "video_url": "https://storage.googleapis.com/falserverless/example_outputs/wan-25-i2v-output.mp4",
  "frame_interval": 12,
  "output_format": "png",
  "max_frames": 100,
  "quality": 95
}
```


### Output Schema

The API returns the following output format:

- **`images`** (`list<Image>`, _required_):
  Array of extracted frame images
  - Array of Image
  - Examples: [{"file_name":"frame_001.png","file_size":102400,"content_type":"image/png","url":"https://v3b.fal.media/files/b/tiger/frame_001.png"},{"file_name":"frame_002.png","file_size":102400,"content_type":"image/png","url":"https://v3b.fal.media/files/b/tiger/frame_002.png"}]

- **`frame_count`** (`integer`, _required_):
  Total number of frames extracted
  - Examples: 25



**Example Response**:

```json
{
  "images": [
    {
      "file_name": "frame_001.png",
      "file_size": 102400,
      "content_type": "image/png",
      "url": "https://v3b.fal.media/files/b/tiger/frame_001.png"
    },
    {
      "file_name": "frame_002.png",
      "file_size": 102400,
      "content_type": "image/png",
      "url": "https://v3b.fal.media/files/b/tiger/frame_002.png"
    }
  ],
  "frame_count": 25
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/workflow-utilities/extract-nth-frame \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "video_url": "https://storage.googleapis.com/falserverless/example_outputs/wan-25-i2v-output.mp4"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/workflow-utilities/extract-nth-frame",
    arguments={
        "video_url": "https://storage.googleapis.com/falserverless/example_outputs/wan-25-i2v-output.mp4"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/workflow-utilities/extract-nth-frame", {
  input: {
    video_url: "https://storage.googleapis.com/falserverless/example_outputs/wan-25-i2v-output.mp4"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/workflow-utilities/extract-nth-frame)
- [API Documentation](https://fal.ai/models/fal-ai/workflow-utilities/extract-nth-frame/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/workflow-utilities/extract-nth-frame)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
