# FFMPEG API Examples

Replace `your_api_key_here` with an active key from your dashboard.

## Merge videos

```bash
curl -X POST "https://ffmpegapi.net/api/merge_videos" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "video_urls": [
    "https://example.com/intro.mp4",
    "https://example.com/main.mp4"
  ],
  "dimensions": "1920x1080"
}'
```

## Create a video from image and audio

```bash
curl -X POST "https://ffmpegapi.net/api/merge_image_audio" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "image": "https://example.com/cover.jpg",
  "audio": "https://example.com/audio.mp3"
}'
```

## Loop a video

```bash
curl -X POST "https://ffmpegapi.net/api/video_loop" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "video_url": "https://example.com/clip.mp4",
  "number_of_loops": 3
}'
```

## Add AI captions

```bash
curl -X POST "https://ffmpegapi.net/api/videos/add-tiktok-captions" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "video_url": "https://example.com/video.mp4",
  "subtitle_style": "yellow-bg",
  "aspect_ratio": "9:16"
}'
```

## Poll async job status

```bash
curl -X GET "https://ffmpegapi.net/api/job/job_123/status?api_key=your_api_key_here"
```

## Async Workflow

```python
import time
import requests

api_key = "your_api_key_here"
response = requests.post(
    "https://ffmpegapi.net/api/merge_videos",
    headers={"X-API-Key": api_key},
    json={"video_urls": ["https://example.com/a.mp4", "https://example.com/b.mp4"], "async": True},
)
job_id = response.json()["job_id"]

while True:
    status = requests.get(f"https://ffmpegapi.net/api/job/{job_id}/status", headers={"X-API-Key": api_key}).json()
    if status["status"] in ("completed", "failed"):
        print(status)
        break
    time.sleep(5)
```
