services

package
v0.0.0-...-7336ba5 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Audio profile
	AudioMobileLow = QualityProfile{
		Name:         "audio_mobile_low",
		AudioCodec:   "aac",
		AudioBitrate: "64k",
		Preset:       "fast",
	}

	AudioMobileHigh = QualityProfile{
		Name:         "audio_mobile_high",
		AudioCodec:   "aac",
		AudioBitrate: "128k",
		Preset:       "fast",
	}

	// Video profile
	VideoMobileLow = QualityProfile{
		Name:         "video_mobile_low",
		VideoCodec:   "libx264",
		AudioCodec:   "aac",
		VideoBitrate: "500k",
		AudioBitrate: "64k",
		Resolution:   "480x360",
		Preset:       "fast",
		CRF:          20,
	}

	VideoMobileHigh = QualityProfile{
		Name:         "video_mobile_high",
		VideoCodec:   "libx264",
		AudioCodec:   "aac",
		VideoBitrate: "1000k",
		AudioBitrate: "128k",
		Resolution:   "720x480",
		Preset:       "medium",
		CRF:          23,
	}

	VideoMobileUltra = QualityProfile{
		Name:         "video_mobile_ultra",
		VideoCodec:   "libx264",
		AudioCodec:   "aac",
		VideoBitrate: "2000k",
		AudioBitrate: "128k",
		Resolution:   "1280x720",
		Preset:       "medium",
		CRF:          20,
	}
)

Functions

func BatchOptimize

func BatchOptimize(inputPaths []string, outputDir string, quality string) error

Optimizing multiple inputs files

func DownloadFromMagnetLink(magnetLink, downloadDir string) error

Download torrent file specified by the magnet link.

func DownloadFromTorrentFile

func DownloadFromTorrentFile(torrentFilePath, downloadDir string) error

Downloading a torrent file specified in a filepath directory.

func DownloadTorrentFile

func DownloadTorrentFile(url, destinationDir string) (string, error)

Downloading a torrent file from source based on the provided URL

func IsFFmpegAvailable

func IsFFmpegAvailable() bool

func IsMagnet

func IsMagnet(link string) bool

Util func to check if the provided link is a magnet link

func OptimizeAudioForMobile

func OptimizeAudioForMobile(inputPath, outputPath, quality string) error

func OptimizeVideoForMobile

func OptimizeVideoForMobile(inputPath, outputPath, quality string) error

func Transcode

func Transcode()

Compatibility func with the existed codebase

Types

type Event

type Event struct {
	Name string
}

type EventData

type EventData struct {
	Message string
}

type EventFactory

type EventFactory struct {
	Mu *sync.Mutex
	Wg *sync.WaitGroup
	// contains filtered or unexported fields
}
var (
	EventBus *EventFactory
)

func (*EventFactory) CreateEvent

func (bus *EventFactory) CreateEvent(eventName string) *Event

func (*EventFactory) Emit

func (bus *EventFactory) Emit(event *Event, data *EventData, args ...string)

func (*EventFactory) Off

func (bus *EventFactory) Off(event *Event, handler EventHandler)

func (*EventFactory) On

func (bus *EventFactory) On(event *Event, handler EventHandler)

func (*EventFactory) Wait

func (bus *EventFactory) Wait()

type EventHandler

type EventHandler func(event *EventData, args ...string)

type MediaOptimizer

type MediaOptimizer struct {
	InputPath  string
	OutputPath string
	MediaType  MediaType
	Profile    QualityProfile
	// contains filtered or unexported fields
}

Main media transcription struct

func NewMediaOptimizer

func NewMediaOptimizer(inputPath, outputPath string) (*MediaOptimizer, error)

Create a new instance of the media transcription service

func (*MediaOptimizer) GetCompressionRatio

func (m *MediaOptimizer) GetCompressionRatio() (float64, error)

Calculating Compression ration

func (*MediaOptimizer) GetOptimizedSize

func (m *MediaOptimizer) GetOptimizedSize() (int64, error)

Get the optimized file size

func (*MediaOptimizer) Optimize

func (m *MediaOptimizer) Optimize() error

Run the optimization

func (*MediaOptimizer) OptimizeForMobile

func (m *MediaOptimizer) OptimizeForMobile(quality string) error

Automatic optimization for mobile device depending on the provided quality The quality type can be `low` | `high` or `ultra` for video content

func (*MediaOptimizer) OptimizeWithCallback

func (m *MediaOptimizer) OptimizeWithCallback(progressCallback func(float64)) error

Running the optimization process with a callback func to take the progress

func (*MediaOptimizer) SetCustomProfile

func (m *MediaOptimizer) SetCustomProfile(name, videoCodec, audioCodec, videoBitrate, audioBitrate, resolution, preset string, crf int)

Setting a personalized quality profile

func (*MediaOptimizer) SetProfile

func (m *MediaOptimizer) SetProfile(profile QualityProfile)

Setting the quality profile

type MediaType

type MediaType int

MediaType representing the media type here

const (
	Audio MediaType = iota
	Video
)

type QualityProfile

type QualityProfile struct {
	Name         string
	VideoCodec   string
	AudioCodec   string
	VideoBitrate string
	AudioBitrate string
	Resolution   string
	Preset       string
	CRF          int    // Constant Rate Factor for the quality
	MaxSize      string // Max file size
}

QualityProfile define the media file quality

Jump to

Keyboard shortcuts

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