# V1.1

> Analyzes your video's pacing, mood, and timing to generate a frame-synced, commercial-ready soundtrack in seconds


## Overview

- **Endpoint**: `https://fal.run/sonilo/v1.1/video-to-music`
- **Model ID**: `sonilo/v1.1/video-to-music`
- **Category**: video-to-audio
- **Kind**: inference
**Tags**: stylized, transform, lipsync



## Pricing

Your request will cost **$0.009** per second of output and per sample.

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_):
  Public http(s) URL of the source video to score.
  - Examples: "https://fal.media/files/panda/Nb8mPYXAFWeFVjL36GXIE_snowboard_silent.mp4"

- **`num_samples`** (`integer`, _optional_):
  How many distinct music tracks to generate for the video. Default value: `1`
  - Default: `1`
  - Range: `1` to `3`

- **`prompt`** (`string`, _optional_):
  Optional text prompt steering the musical style. If omitted, a prompt is generated automatically from the video.

- **`start_offset`** (`float`, _optional_):
  Optional. Start scoring from this offset (seconds) into the video. Requires Start Offset + Duration <= Video Duration.
  - Range: `0` to `600`

- **`duration`** (`float`, _optional_):
  Optional. Length (seconds) of the video segment to score. When set, scores a segment of this length starting at Start Offset (or from the beginning if Start Offset is unset). Defaults (None) to the rest of the video: the whole video when Start Offset is unset, or from Start Offset to the end when it is set.
  - Range: `1` to `600`



**Required Parameters Example**:

```json
{
  "video_url": "https://fal.media/files/panda/Nb8mPYXAFWeFVjL36GXIE_snowboard_silent.mp4"
}
```

**Full Example**:

```json
{
  "video_url": "https://fal.media/files/panda/Nb8mPYXAFWeFVjL36GXIE_snowboard_silent.mp4",
  "num_samples": 1
}
```


### Output Schema

The API returns the following output format:

- **`audio`** (`Audio`, _required_):
  The first generated music track, for quick preview/playback.
  - Examples: {"file_size":380994,"content_type":"audio/mp4","file_name":"snowboard.m4a","url":"https://fal.media/files/zebra/868EM5xGpZKjwvq8kSnCP_snowboard.m4a"}

- **`audios`** (`list<Audio>`, _required_):
  All generated music tracks (AAC/m4a), one per sample.
  - Array of Audio
  - Examples: [{"file_size":380994,"content_type":"audio/mp4","file_name":"snowboard.m4a","url":"https://fal.media/files/zebra/868EM5xGpZKjwvq8kSnCP_snowboard.m4a"}]



**Example Response**:

```json
{
  "audio": {
    "file_size": 380994,
    "content_type": "audio/mp4",
    "file_name": "snowboard.m4a",
    "url": "https://fal.media/files/zebra/868EM5xGpZKjwvq8kSnCP_snowboard.m4a"
  },
  "audios": [
    {
      "file_size": 380994,
      "content_type": "audio/mp4",
      "file_name": "snowboard.m4a",
      "url": "https://fal.media/files/zebra/868EM5xGpZKjwvq8kSnCP_snowboard.m4a"
    }
  ]
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/sonilo/v1.1/video-to-music \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "video_url": "https://fal.media/files/panda/Nb8mPYXAFWeFVjL36GXIE_snowboard_silent.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(
    "sonilo/v1.1/video-to-music",
    arguments={
        "video_url": "https://fal.media/files/panda/Nb8mPYXAFWeFVjL36GXIE_snowboard_silent.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("sonilo/v1.1/video-to-music", {
  input: {
    video_url: "https://fal.media/files/panda/Nb8mPYXAFWeFVjL36GXIE_snowboard_silent.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/sonilo/v1.1/video-to-music)
- [API Documentation](https://fal.ai/models/sonilo/v1.1/video-to-music/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=sonilo/v1.1/video-to-music)

### 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)
