This service implements these main features:
- Stream media files.
- Create and manage users.
- Create and manage categories.
- Create and manage videos.
Supported transport protocols
- HLS
- RTMP
- FLV
Supported file extensions
-
Video Formats:
- mp4 (MPEG-4 Part 14)
- mov (QuickTime Movie)
- avi (Audio Video Interleave)
- mkv (Matroska Video)
- flv (Flash Video)
- webm (WebM Video)
-
Audio Formats:
- mp3 (MPEG Audio Layer III)
- aac (Advanced Audio Coding)
- wav (Waveform Audio File Format)
- flac (Free Lossless Audio Codec)
- ogg (Ogg Vorbis Audio)
-
Other Formats:
- ts (Transport Stream)
- m2ts (Blu-ray BDAV MPEG-2 Transport Stream)
- 3gp (3GPP Multimedia File)
- wmv (Windows Media Video)
Infrastructure:
- App context: AppContext (library packages common components)
- ffmpeg:
ffmpeg
- Token authentication:
PASETO
- Database migrations:
golang-migrate
- Generate CRUD operations from SQL:
GORM
- Database:
PostgreSQL
- Database documentation:
dbdocs
- Generate SQL schema:
dbml2sql
- Web framework:
Gin
- Containerize:
docker
|docker compose
-
Setup ENV:
make build make outenv # Show ENV on terminal make outenvfile # Extract ENV into .env # Replace ENV variables in `.env` with your configuration
-
Run in background (all in one):
make up
-
Run on current terminal:
# Start PostgreSQL database make updb # Run server make server
-
brew install golang-migrate
-
npm install -g dbdocs dbdocs login
-
npm install -g @dbml/cli dbml2sql --version
-
brew install ffmpeg
-
go install github.com/swaggo/swag/cmd/swag@latest
-
Start PostgreSQL container:
make updb
-
Run DB migration up all versions:
make migrateup
-
Run DB migration up 1 version:
make migrateup1
-
Run DB migration down all versions:
make migratedown
-
Run DB migration down 1 version:
make migratedown1
-
Generate DB documentation:
make dbdocs
-
Access the DB documentation at THIS ADDRESS.
-
List ENV variables on terminal:
make outenv
-
Extract ENV variables into
.env
file:make outenvfile
-
Generate schema SQL file with DBML:
make dbschema
-
Create a new DB migration:
make new_migration name=<migration_name>
-
Generate swagger documents:
make swagger
-
Run server on terminal:
make server
-
Run containers (verbose mode):
make upv
-
Run containers (detach mode):
make up
-
Remove containers:
make down
3. API Docs - Swagger | Postman Collection
Method | Path | Description | Notes |
---|---|---|---|
POST | /api/v1/users/register |
Register a new user | Receives user details |
POST | /api/v1/auth/login |
Login to get access token | Receives username and password |
GET | /api/v1/users/me |
Retrieve user profile | Requires valid access token |
POST | /api/v1/categories |
Create a new category | Receives category details |
GET | /api/v1/categories |
Retrieve all categories | Requires valid access token |
GET | /api/v1/videos/streams/{id}/{id}.m3u8 |
Stream video segments | Requires valid video ID |
GET | /api/v1/videos |
Retrieve videos | Supports pagination |
GET | /api/v1/videos/{id} |
Retrieve video by ID | Requires valid video ID |
GET | /api/v1/videos/{id}/segments |
Retrieve video segments | Requires valid video ID, supports pagination |
POST | /api/v1/videos |
Create a new video | Receives video details and file |
- To test streaming media use: HLS Demo
- Input format:
{host}/api/v1/videos/streams/{video_path}
(video_path: "path" in getting video details response) - For example:
http://localhost:8080/api/v1/videos/streams/1692794790339777000/1692794790339777000.m3u8