stauvise

command module
v0.0.0-...-e328feb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 1 Imported by: 0

README

STAUVISE

GO - An Audio/Video Streaming Service

This service implements these main features:

  1. Stream media files.
  2. Create and manage users.
  3. Create and manage categories.
  4. 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

1. Quick start

  • 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
    

2. Setup local development

Install tools
  • Migrate

    brew install golang-migrate
    
  • DB Docs

    npm install -g dbdocs
    dbdocs login
    
    
  • DBML CLI

    npm install -g @dbml/cli
    dbml2sql --version
    
  • ffmpeg

    brew install ffmpeg
    
  • Swagger

    go install github.com/swaggo/swag/cmd/swag@latest
    
Setup infrastructure
  • 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
    
Documentation
  • Generate DB documentation:

    make dbdocs
    
  • Access the DB documentation at THIS ADDRESS.

How to generate code
  • 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
    
How to run
  • 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

4. Notes

  • 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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL