converter

package
v0.0.0-...-689375e Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ImageConversions map[string][]string

ImageConversions maps source image extension to list of target extensions.

View Source
var VideoContainers = []VideoContainerConfig{
	{
		Name:       "MP4",
		Codecs:     []string{"h264", "h265", "av1"},
		Extensions: []string{".mp4", ".m4a", ".m4p", ".m4b", ".m4r", ".m4v"},
	},
	{
		Name:       "Matroska",
		Codecs:     []string{"h264", "h265", "av1", "vp9"},
		Extensions: []string{".mkv", ".mk3d", ".mka", ".mks"},
	},
	{
		Name:       "WebM",
		Codecs:     []string{"vp8", "vp9", "av1"},
		Extensions: []string{".webm"},
	},
}

VideoContainers lists the three supported output video containers.

View Source
var VideoConversions map[string][]string

VideoConversions maps source video extension to list of all canonical video output extensions.

Functions

func ConvertFile

func ConvertFile(ctx context.Context, source, targetExt, codec, hwaccel, outputDir string, av1CRF int) (string, error)

ConvertFile is the high-level converter — routes to image or video handler.

func ConvertImage

func ConvertImage(ctx context.Context, source, targetExt, outputDir string) (string, error)

ConvertImage converts an image file using the imaging library or ffmpeg.

func ConvertVideo

func ConvertVideo(ctx context.Context, source, targetExt, codec, hwaccel, outputDir string, av1CRF int) (string, error)

ConvertVideo converts a video file using ffmpeg with optional GPU hardware acceleration.

func GetCompatibleTargets

func GetCompatibleTargets(sourcePath string) []string

GetCompatibleTargets returns the list of extensions a source can convert to.

func IsValidTargetExt

func IsValidTargetExt(ext string) bool

IsValidTargetExt reports whether ext is a recognised image or video output extension.

Types

type FileEntry

type FileEntry struct {
	Path          string   `json:"path"`
	Name          string   `json:"name"`
	Filename      string   `json:"filename"` // Alias for frontend compatibility
	Ext           string   `json:"ext"`
	Size          int64    `json:"size"`
	SizeFormatted string   `json:"size_formatted"`
	Type          string   `json:"type"`
	Targets       []string `json:"targets"`
}

FileEntry describes one file found during scanning.

type HWAccelProfile

type HWAccelProfile struct {
	Name     string   `json:"name"`
	Type     string   `json:"type"` // "nvenc", "qsv", "amf", "vaapi", "videotoolbox"
	Encoders []string `json:"encoders"`
}

HWAccelProfile defines a detected hardware acceleration encoder profile.

func DetectAvailableHWAccels

func DetectAvailableHWAccels(ctx context.Context) []HWAccelProfile

DetectAvailableHWAccels probes available GPU hardware encoders (cached via sync.Once).

type ScanResult

type ScanResult struct {
	Folder             string         `json:"folder"`
	Summary            map[string]int `json:"summary"`
	Files              []FileEntry    `json:"files"`
	Total              int            `json:"total"`
	TotalCount         int            `json:"total_count"`
	TotalSize          int64          `json:"total_size"`
	TotalSizeFormatted string         `json:"total_size_formatted"`
}

ScanResult holds the output of a folder scan.

func ScanFolder

func ScanFolder(folder string, includeSubfolders bool, filterType string, excludeFolders ...string) (*ScanResult, error)

ScanFolder walks folder and returns an inventory of convertible media files.

type VideoContainerConfig

type VideoContainerConfig struct {
	Name       string   `json:"name"`
	Codecs     []string `json:"codecs"`
	Extensions []string `json:"extensions"`
}

VideoContainerConfig describes a supported output video container.

Jump to

Keyboard shortcuts

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