MediaBucket is a robust and scalable video transcoding server built with Go. It offers resumable file uploads, automatic video transcoding, and efficient media serving, including thumbnails for both videos and images. Additionally, MediaBucket provides an image upload bucket with automatic thumbnail generation, ensuring seamless media management for your applications.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- API Endpoints
- Directory Structure
- Contributing
- License
- Acknowledgements
- Resumable File Uploads: Supports TUS protocol for reliable and resumable uploads of large video and image files.
- Video Transcoding: Automatically transcodes uploaded videos into HLS format for adaptive streaming.
- Thumbnail Generation:
- Videos: Generates high quality thumbnails and 500px width thumbnails for each uploaded video.
- Images: Generates 500px width thumbnails for each uploaded image.
- Media Serving:
- Serves HLS video streams.
- Provides access to video and image thumbnails.
- Hosts an image upload bucket for serving image files.
- Demo Pages:
/video-demo
: Demonstrates video upload functionality./image-demo
: Demonstrates image upload functionality.
- CORS Middleware: Ensures secure and controlled access to media resources.
Before setting up MediaBucket, ensure you have the following installed on your system:
- Go: Version 1.16 or higher. Download Go
- FFmpeg: Required for video transcoding. Install FFmpeg
- Git: For cloning the repository. Download Git
MediaBucket uses environment variables for configuration. Below are the essential variables you need to set in your .env
file:
Variable | Description | Example Value |
---|---|---|
ServerURL |
Base URL of the server | http://example.com |
VideoUploadPath |
Endpoint path for video uploads | /video/ |
ImageUploadPath |
Endpoint path for image uploads | /image/ |
Example .env
File:
ServerURL=http://example.com
VideoUploadPath=/video/
ImageUploadPath=/image/
Once the service is up and running, you can interact with it through the following functionalities:
Use the /video/
endpoint to upload videos. The server supports resumable uploads, allowing you to pause and resume uploads as needed.
Use the /image/
endpoint to upload images. Similar to video uploads, image uploads are resumable.
Transcoded HLS video streams are available at the /hls/
endpoint. For example:
http://example.com/hls/{video_id}/master.m3u8
-
Video Thumbnails: Accessible via
/thumbnail/
.http://example.com/thumbnail/{video_id}-500w.webp
-
Image Thumbnails: Automatically generated with a width of 500px and accessible via the same endpoint.
http://example.com/thumbnail/{image_id}-500w.webp
- Video Upload Demo: http://example.com/video-demo
- Image Upload Demo: http://example.com/image-demo
These pages provide a user-friendly interface to test upload functionalities.
-
Video Upload
POST /video/
- Description: Upload video files using the TUS protocol.
- Headers:
Content-Type: application/offset+octet-stream
- Parameters: Handled by TUS protocol.
-
Image Upload
POST /image/
- Description: Upload image files using the TUS protocol.
- Headers:
Content-Type: application/offset+octet-stream
- Parameters: Handled by TUS protocol.
-
HLS Video Streams
GET /hls/{video_id}/master.m3u8
- Description: Access the HLS stream of the transcoded video.
-
Thumbnails
GET /thumbnail/{media_id}-500w.webp
- Description: Retrieve the thumbnail image for the specified media.
-
Video Upload Demo
GET /video-demo
- Description: Serves a web page demonstrating video upload functionality.
-
Image Upload Demo
GET /image-demo
- Description: Serves a web page demonstrating image upload functionality.
/
├── app/
│ ├── main.go # Main application entry point
│ ├── go.mod # Go module file
│ └ * # rest of the application code
├── storage/
│ ├── MediaBucket/
│ │ ├── videos/ # Original video uploads
│ │ ├── images/ # Original image uploads
│ │ ├── hls/ # Transcoded HLS streams
│ │ └── thumbnail/ # Generated thumbnails
└── templates/
├── video-demo.html # Video upload demo page
└── image-demo.html # Image upload demo page
We welcome contributions to enhance MediaBucket! Please follow these steps:
-
Fork the Repository
Click the "Fork" button at the top right of the repository page.
-
Create a Feature Branch
git checkout -b feature/YourFeature
-
Commit Your Changes
git commit -m "Add your message here"
-
Push to Your Fork
git push origin feature/YourFeature
-
Open a Pull Request
Navigate to the original repository and click "Compare & pull request."
Please ensure your code follows the project's coding standards and includes relevant tests.
This project is licensed under the MIT License.
- TUS Protocol for providing a reliable resumable upload protocol.
- FFmpeg for powerful multimedia processing capabilities.
- Go for being the programming language behind MediaBucket.
For any questions or support, please open an issue on the GitHub repository.