Fast, lightweight API to convert audio and video files between different formats using FFmpeg.
- 🔄 Convert media files (audio & video) between multiple formats
- ⚡ FastAPI-powered REST API
- 🐳 Docker-ready
- 🌐 CORS enabled — easy to connect from any frontend or automation
- ✅ Supports a wide range of audio and video formats.
| Format | Input | Output |
|---|---|---|
| Audio | ||
| mp3 | ✅ | ✅ |
| wav | ✅ | ✅ |
| m4a | ✅ | ✅ |
| flac | ✅ | ✅ |
| ogg | ✅ | ✅ |
| aac | ✅ | ✅ |
| wma | ✅ | ✅ |
| ac3 | ✅ | ✅ |
| aiff | ✅ | ✅ |
| amr | ✅ | ✅ |
| Video | ||
| mp4 | ✅ | ✅ |
| avi | ✅ | ✅ |
| mkv | ✅ | ✅ |
| mov | ✅ | ✅ |
| webm | ✅ | ✅ |
| flv | ✅ | ✅ |
| wmv | ✅ | ✅ |
| mpeg | ✅ | ✅ |
| mpg | ✅ | ✅ |
| 3gp | ✅ | ✅ |
| ogv | ✅ | ✅ |
| vob | ✅ | ✅ |
| ts | ✅ | ✅ |
| m2ts | ✅ | ✅ |
| asf | ✅ | ✅ |
| swf | ✅ | ✅ |
# Build the Docker image
docker build -t media-converter .
# Run the container, mapping host port 3002 to container port 3002
docker run -p 3002:3002 media-converterNote: If you are using docker-compose.yml, you can simply run docker-compose up --build -d from the directory containing your docker-compose.yml file.
# Install Python dependencies
pip install -r requirements.txt
# Run the FastAPI application with Uvicorn
uvicorn main:app --reload --host 0.0.0.0 --port 3002POST /convert_media/?output_format=<format>multipart/form-data- Body:
file: Media file (audio or video) to upload
# Example converting a MOV video to MP4
curl -X POST "http://127.0.0.1:3002/convert_media/?output_format=mp4" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@video.mov" \
--output converted.mp4
# Example converting an audio file to MP3
curl -X POST "http://127.0.0.1:3002/convert_media/?output_format=mp3" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@audio.wav" \
--output converted.mp3GET /health.
├── convert_media.py # Core media conversion logic using FFmpeg
├── main.py # FastAPI application setup and endpoint
├── requirements.txt # Python dependencies
├── docker-compose.yml # (optional) Docker compose
└── Dockerfile # Docker build instructions for the container
- Python 3.11+
- FFmpeg (installed in your system or via Docker)
- Or just use Docker 🐳