Skip to content

AuraReaper/Convertify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ₯➑️🎡 Video to Audio Converter

Python Flask MongoDB RabbitMQ Docker License: MIT

πŸ“‹ Overview

A scalable, microservice-based application that converts video files to MP3 audio format. Built with Python Flask, this system leverages asynchronous processing with RabbitMQ, MongoDB for file storage, and JWT-based authentication to provide a robust video-to-audio conversion service.

Perfect for: Content creators, podcasters, developers learning microservice architecture, or anyone needing reliable video-to-audio conversion at scale.

✨ Key Features

  • 🎬 Video Upload & Processing: Support for multiple video formats (MP4, AVI, MOV, etc.)
  • 🎡 High-Quality Audio Extraction: Converts videos to MP3 with customizable quality settings
  • πŸ” JWT Authentication: Secure user authentication and authorization
  • πŸ“§ Email Notifications: Automatic email alerts when conversion is complete
  • ⚑ Asynchronous Processing: Non-blocking video processing using RabbitMQ
  • πŸ—„οΈ GridFS Storage: Efficient handling of large video and audio files
  • 🐳 Containerized: Fully dockerized for easy deployment
  • πŸ“Š RESTful API: Clean, well-documented API endpoints
  • πŸ—οΈ Microservice Architecture: Scalable, maintainable service separation

πŸ›οΈ Architecture

The application follows a microservice architecture with four main components:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   API Gateway   β”‚    β”‚  Auth Service   β”‚    β”‚ Notification    β”‚
β”‚   (Flask API)   │────│   (JWT Auth)    β”‚    β”‚    Service      β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚  (Email Alerts) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                                              β”‚
          β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
          └──────────────│   RabbitMQ      β”‚β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ Message Broker  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Converter     β”‚
                         β”‚    Service      β”‚
                         │ (Video→Audio)   │
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚    MongoDB      β”‚
                         β”‚ (GridFS Storage)β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Backend

  • Python 3.9+ - Core programming language
  • Flask - Web framework for API services
  • MoviePy - Video processing and audio extraction
  • PyMongo - MongoDB integration
  • Pika - RabbitMQ client
  • PyJWT - JSON Web Token handling

Databases & Storage

  • MongoDB - Document database with GridFS for file storage
  • MySQL - Relational database for user management

Message Broker

  • RabbitMQ - Asynchronous message processing

DevOps & Deployment

  • Docker - Containerization
  • Docker Compose - Multi-container orchestration

External Services

  • Gmail SMTP - Email notification delivery

πŸš€ Installation & Setup

Prerequisites

  • Python 3.9+
  • Docker & Docker Compose
  • Git

1. Clone the Repository

git clone https://github.com/yourusername/video-to-audio-converter.git
cd video-to-audio-converter

2. Environment Configuration

Create .env files for each service:

Gateway Service (.env)

MONGO_HOST=mongodb://mongo:27017
MONGO_DB=videos
AUTH_SVC_ADDRESS=auth:5000
RABBIT_MQ_HOST=rabbitmq
RABBIT_MQ_PORT=5672
RABBIT_MQ_USER=guest
RABBIT_MQ_PASSWORD=guest

Auth Service (.env)

MYSQL_HOST=mysql
MYSQL_USER=auth_user
MYSQL_PASSWORD=your_password
MYSQL_DB=auth
JWT_SECRET=your_jwt_secret_key

Notification Service (.env)

GMAIL_ADDRESS=your_email@gmail.com
GMAIL_PASSWORD=your_app_password
RABBIT_MQ_HOST=rabbitmq
MP3_QUEUE=mp3

Converter Service (.env)

MONGO_HOST=mongodb://mongo:27017
MONGO_DB=videos
RABBIT_MQ_HOST=rabbitmq
MP3_QUEUE=mp3

3. Docker Deployment

# Build and start all services
docker-compose up --build

# Run in background
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

4. Local Development Setup

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Start individual services
python src/gateway/app.py
python src/auth/server.py
python src/converter/consumer.py
python src/notification/server.py

πŸ“– API Documentation

Authentication Endpoints

Login

POST /login
Authorization: Basic base64(username:password)

Response: JWT Token

Validate Token

POST /validate
Authorization: Bearer <jwt_token>

File Operations

Upload Video

POST /upload
Authorization: Bearer <jwt_token>
Content-Type: multipart/form-data

Form Data:
- file: video file (MP4, AVI, MOV, etc.)

Download Audio

GET /download?fid=<file_id>
Authorization: Bearer <jwt_token>

Response: MP3 file download

πŸ’» Usage Examples

1. User Authentication

# Login and get JWT token
curl -X POST http://localhost:5000/login \
  -H "Authorization: Basic $(echo -n 'username:password' | base64)"

# Response: JWT token

2. Upload Video for Conversion

# Upload video file
curl -X POST http://localhost:5000/upload \
  -H "Authorization: Bearer <your_jwt_token>" \
  -F "file=@/path/to/your/video.mp4"

# Response: Upload confirmation

3. Download Converted Audio

# Download MP3 file
curl -X GET "http://localhost:5000/download?fid=<file_id>" \
  -H "Authorization: Bearer <your_jwt_token>" \
  -o converted_audio.mp3

4. Processing Flow

  1. Upload: User uploads video via API Gateway
  2. Queue: Video processing job added to RabbitMQ
  3. Convert: Converter service extracts audio using MoviePy
  4. Store: MP3 file saved to MongoDB GridFS
  5. Notify: Email notification sent to user
  6. Download: User downloads MP3 via provided file ID

πŸ”§ Configuration

Supported Video Formats

  • MP4, AVI, MOV, WMV, FLV, MKV
  • Maximum file size: 500MB (configurable)

Audio Output Settings

  • Format: MP3
  • Quality: 128kbps (default, configurable)
  • Sample Rate: 44.1kHz

Queue Configuration

  • video: Input queue for video processing
  • mp3: Output queue for notification service

πŸ§ͺ Testing

# Run unit tests
python -m pytest tests/

# Run with coverage
python -m pytest --cov=src tests/

# Integration tests
python -m pytest tests/integration/

πŸ“Š Monitoring & Logging

  • RabbitMQ Management: http://localhost:15672
  • MongoDB Compass: mongodb://localhost:27017
  • Application Logs: Available via docker-compose logs

πŸš€ Deployment

Production Considerations

  • Use environment-specific configuration
  • Implement proper logging and monitoring
  • Set up SSL/TLS certificates
  • Configure load balancing for high availability
  • Use managed database services (MongoDB Atlas, AWS RDS)
  • Implement file size limits and validation

Scaling

  • Horizontal: Deploy multiple converter instances
  • Vertical: Increase container resources
  • Queue Management: Monitor RabbitMQ performance
  • Storage: Use cloud storage solutions (AWS S3, Google Cloud Storage)

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Write unit tests for new features
  • Update documentation as needed
  • Ensure Docker containers build successfully

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


⭐ If this project helped you, please consider giving it a star!

Built with ❀️ using Python, Flask, MongoDB, and RabbitMQ

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published