transcoder

package
v0.0.0-...-77c78fe Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound = errors.New("Task with this name not found")
)

Functions

func HandleCheck

func HandleCheck(job Job)

HandleCheck handles the check if the provided file is already transcoded

func HandleStreamParams

func HandleStreamParams(job Job)

HandleStreamParams handles the retrieval of stream params

func HandleTranscode

func HandleTranscode(job Job)

HandleTranscode handles the transcoding

func HandleTranscodeParams

func HandleTranscodeParams(job Job)

HandleTranscodeParams handles the retrieval of transcoding params

Types

type Job

type Job struct {
	Work       string
	Transcoder *Transcoder
	Stream     Stream
	Params     []string
	Status     string
	Media      m.Media
}

type Probe

type Probe struct {
	Programs []interface{} `json:"programs"`
	Streams  []struct {
		CodecName    string `json:"codec_name"`
		Width        int    `json:"width"`
		Height       int    `json:"height"`
		AvgFrameRate string `json:"avg_frame_rate"`
	} `json:"streams"`
}

type Stream

type Stream struct {
	FPS    int
	Width  int
	Height int
}

type Transcoder

type Transcoder struct {
	Config            *m.Config
	Queue             chan Job
	ReadyQueue        chan chan Job
	Workers           []*Worker
	Tasks             map[string]func(Job)
	Jobs              map[string]string
	DispatcherStopped sync.WaitGroup
	WorkersStopped    sync.WaitGroup
	// contains filtered or unexported fields
}

func Instance

func Instance() *Transcoder

Instance returns a global Transcoder instance

func New

func New(config *m.Config) *Transcoder

New creates a new Transcoder interface

func (*Transcoder) Job

func (t *Transcoder) Job(work string, media m.Media) Job

func (*Transcoder) Probe

func (t *Transcoder) Probe(path string) (Stream, error)

Probe issues a single ffprobe on the provided media file path and returns framerate, width and height of the video

func (*Transcoder) RegisterTasks

func (t *Transcoder) RegisterTasks(tasks map[string]func(Job))

RegisterTasks registers tasks executed by the workers

func (*Transcoder) Start

func (t *Transcoder) Start()

Start starts the multithreaded Transcoder workers

func (*Transcoder) Status

func (t *Transcoder) Status(hash string) string

Status returns the status of the job with the provided hash

func (*Transcoder) Submit

func (t *Transcoder) Submit(job Job)

Submit add the job both to the job map and the queue

func (*Transcoder) Subtitles

func (t *Transcoder) Subtitles(path, hash string) error

Subtitles issues a single ffmpeg on the provided media file path and saves the subtitles in a srt file

func (*Transcoder) Transcoded

func (t *Transcoder) Transcoded(hash string) bool

Transcoded returns if the file / media with the hash is already transcoded

func (*Transcoder) UpdateStatus

func (t *Transcoder) UpdateStatus(hash, status string)

UpdateStatus updates the status of the job with the provided hash to status

type Worker

type Worker struct {
	Done          sync.WaitGroup
	ReadyQueue    chan chan Job
	AssignedQueue chan Job
	Transcoder    *Transcoder
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(rq chan chan Job, done sync.WaitGroup, transcoder *Transcoder) *Worker

func (*Worker) GetTask

func (w *Worker) GetTask(task string) (func(Job), error)

func (*Worker) Start

func (w *Worker) Start()

func (*Worker) Stop

func (w *Worker) Stop()

Jump to

Keyboard shortcuts

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