Documentation
¶
Overview ¶
Package models defines the core data structures used throughout the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LogLevel = &slog.LevelVar{}
Functions ¶
func SetupLogging ¶
func SetupLogging(verbosity int)
SetupLogging configures logging level based on verbosity counter
Types ¶
type AudioConfig ¶
type AudioConfig struct {
TargetAudioBitrate int64
MinSavingsAudio float64
TranscodingAudioRate float64
SplitLongerThan float64 // Parsed from string (seconds)
MinSplitSegment float64 // Parsed from string (seconds)
AudioOnly bool
AlwaysSplit bool
}
AudioConfig contains configuration for audio processing
type CommonConfig ¶
type CommonConfig struct {
MoveBroken string
SourceAudioBitrate int64
SourceVideoBitrate int64
MaxWidthBuffer float64
MaxHeightBuffer float64
DeleteUnplayable bool
DeleteLarger bool
Valid bool
Invalid bool
ForceShrink bool
VerboseFFmpeg bool
IncludeTimecode bool
// Memory monitoring via systemd-run (Linux only)
MemoryLimit int64 // Memory limit in bytes (0 = no limit)
MemorySwapMax int64 // Swap limit in bytes (0 = auto, -1 = disable swap)
UseJournald bool // Use journald-compatible mode for systemd-run
DisableSystemd bool // Disable systemd-run wrapper even if available
// Archive processing timeouts
ArchiveAnalyzeTimeoutSec int64 // lsar analyze timeout in seconds
ArchiveGlobTimeoutSec int64 // glob operations timeout in seconds
ArchiveGlobPath string // path for glob timeout calculation
ArchiveExtractTimeoutSec int64 // unar extraction timeout in seconds
}
CommonConfig contains general configuration for all processors
type ImageConfig ¶
type ImageConfig struct {
TargetImageSize int64
MinSavingsImage float64
TranscodingImageTime float64
MaxImageWidth int
MaxImageHeight int
}
ImageConfig contains configuration for image processing
type MediaProcessor ¶
type MediaProcessor interface {
// CanProcess returns true if this processor can handle the given media
CanProcess(m *ShrinkMedia) bool
// EstimateSize calculates the future file size and processing time
EstimateSize(m *ShrinkMedia, cfg *ProcessorConfig) ProcessableInfo
// Process executes the transcoding/conversion
// Returns a single ProcessResult containing all outputs and cleanup tasks
Process(ctx context.Context, m *ShrinkMedia, cfg *ProcessorConfig, registry ProcessorRegistry) ProcessResult
// Category returns the type identifier for this processor
Category() string
// RequiredTool returns the name of the external tool required by this processor
RequiredTool() string
}
MediaProcessor defines the interface for processing different media types
type PlainHandler ¶
PlainHandler is a simple slog handler that outputs plain text
type ProcessOutputFile ¶
ProcessOutputFile represents a new file created by a processor
type ProcessResult ¶
type ProcessResult struct {
SourcePath string // Original file being processed
Outputs []ProcessOutputFile // New files created
PartFiles []string // Multi-part archive part files (for cleanup)
Success bool // Whether the overall operation succeeded
Error error // Error if the operation failed
Output string // Full command output (e.g. from ffmpeg)
StopAll bool // Whether to stop all processing (e.g. environment error)
}
ProcessResult contains the comprehensive result of processing a media file
type ProcessableInfo ¶ added in v0.0.4
type ProcessableInfo struct {
PartFiles []string // Associated files (e.g. multi-part archive volumes)
FutureSize int64
ActualSize int64 // Used if the actual size differs from the reported size (e.g. multi-part archives)
ProcessingTime int
IsProcessable bool
IsBroken bool // Whether the media item is broken/unreadable
IsTimeout bool // Whether the analysis timed out (don't cache this result)
}
ProcessableInfo contains information about whether and how a media item can be processed
type ProcessorConfig ¶
type ProcessorConfig struct {
Video VideoConfig
Audio AudioConfig
Image ImageConfig
Text TextConfig
Common CommonConfig
}
ProcessorConfig contains comprehensive configuration for all media processing
func (*ProcessorConfig) GetMinSavings ¶ added in v0.0.4
func (c *ProcessorConfig) GetMinSavings(category string) float64
GetMinSavings returns the minimum savings threshold for a media category
type ProcessorRegistry ¶
type ProcessorRegistry interface {
GetProcessor(m *ShrinkMedia) MediaProcessor
}
ProcessorRegistry interface defines how to retrieve a processor
type ShrinkMedia ¶
type ShrinkMedia struct {
PartFiles []string // For multi-part archives: list of all part files
Path string
MediaType string
Ext string
Category string
Size int64
Duration float64
FutureSize int64
Savings int64
CompressedSize int64
VideoCount int
AudioCount int
Width int
Height int
ProcessingTime int
IsBroken bool // For archives: lsar failed to read contents
}
ShrinkMedia represents a media file to be processed
func (*ShrinkMedia) DisplayCategory ¶
func (m *ShrinkMedia) DisplayCategory() string
DisplayCategory returns the category with the extension suffix (e.g. "Video: mp4")
func (*ShrinkMedia) ShouldShrink ¶ added in v0.0.4
func (m *ShrinkMedia) ShouldShrink(futureSize int64, cfg *ProcessorConfig) bool
ShouldShrink determines if a file should be shrinked based on savings threshold
type TextConfig ¶
TextConfig contains configuration for text/ebook processing