Documentation
¶
Overview ¶
Package libtranscode converts the files of a library ahead of time, so they play without being converted later. That is a different job from live playback conversion (internal/hls): this one rewrites people's files, so everything about it leans towards keeping them safe. A file is only replaced after its new version has been checked.
The planning (policy.go, source.go, plan.go, args.go) is plain logic that any rule can be tested on without FFmpeg. engine.go runs the plans. docs/LIBRARY-TRANSCODING.md explains it for people, tdarr/ connects to a separately installed Tdarr server.
Index ¶
- Constants
- Variables
- func CoverArgs(src string, st Step, out string) []string
- func Detect(path string, p *ffmpeg.Probe) bool
- func Eligible(libType string) bool
- func HardwareFamily(name string) string
- func SaveRule(ctx context.Context, d *db.DB, r Rule) error
- func SaveSettings(ctx context.Context, d *db.DB, s Settings) error
- func ValidOutput(v string) bool
- func Verify(ctx context.Context, tools *ffmpeg.Tools, src *Source, pl *Plan, path string) error
- type Attachment
- type AudioPolicy
- type AudioStream
- type DriveRoom
- type Engine
- func (e *Engine) Blocked(ctx context.Context, lib *library.Library, r Rule) string
- func (e *Engine) Cancel(run int64) bool
- func (e *Engine) DeleteLeftover(ctx context.Context, fileID int64) error
- func (e *Engine) Env(ctx context.Context) Env
- func (e *Engine) GetFile(ctx context.Context, id int64) (*FileRow, error)
- func (e *Engine) GetRun(ctx context.Context, id int64) (*Run, error)
- func (e *Engine) KickAllAuto(ctx context.Context)
- func (e *Engine) Leftovers(ctx context.Context, library int64, limit int) ([]*FileRow, int64, error)
- func (e *Engine) ListFiles(ctx context.Context, run int64, state string, limit, offset int) ([]*FileRow, int, error)
- func (e *Engine) ListRuns(ctx context.Context, library int64, limit int) ([]*Run, error)
- func (e *Engine) LoadTdarr(ctx context.Context) TdarrSettings
- func (e *Engine) PreviewItem(ctx context.Context, lib *library.Library, id int64, p Policy) (*Preview, error)
- func (e *Engine) Recover(ctx context.Context)
- func (e *Engine) Retry(ctx context.Context, run int64, by tasks.By) (int64, error)
- func (e *Engine) Sample(ctx context.Context, lib *library.Library, id int64, p Policy, cacheDir string) (*SampleResult, error)
- func (e *Engine) SaveTdarr(ctx context.Context, s TdarrSettings, key string, clear bool) error
- func (e *Engine) ScanFinished(libraryID int64)
- func (e *Engine) SendToTdarr(ctx context.Context, libraryID int64, items []int64) (string, error)
- func (e *Engine) Start(ctx context.Context, q RunRequest) (int64, error)
- func (e *Engine) StopAuto()
- func (e *Engine) StopTdarr()
- func (e *Engine) TdarrLook(ctx context.Context, address, key string) TdarrReport
- func (e *Engine) Undo(ctx context.Context, fileID int64) error
- func (e *Engine) UseCopy(ctx context.Context, fileID int64) error
- func (e *Engine) WatchTdarr()
- type Env
- type FileRow
- type OtherStream
- type Output
- type Picture
- type Plan
- type PlanOptions
- type Policy
- type PresetInfo
- type Preview
- type PreviewPart
- type Rule
- type Run
- type RunRequest
- type SampleResult
- type Settings
- type Sidecar
- type Source
- type Step
- type SubStream
- type SubtitlePolicy
- type Summary
- type TdarrMapping
- type TdarrReport
- type TdarrSettings
- type VerifyProblem
- type VideoPolicy
- type VideoStream
Constants ¶
const ( VerdictConvert = "convert" // something is encoded again VerdictRemux = "remux" // only rewrapped or tidied: nothing can look or sound worse VerdictSkip = "skip" // already matches, or nothing here for this recipe to do VerdictRefuse = "refuse" // left alone on purpose, with a reason )
Verdicts: what happens to a file as a whole.
const ( ActKeep = "keep" ActConvert = "convert" ActDrop = "drop" ActAdd = "add" ActBurn = "burn" ActExport = "export" ActEmbed = "embed" ActLeave = "leave" )
What happens to one track.
const ( OutputKeep = "keep" // the new file takes the name; the old one moves to a hidden folder beside it OutputReplace = "replace" // the new file takes the name; the old one is deleted once it has been checked OutputBeside = "beside" // the old file stays in use; the new one is written next to it )
What a run does with the file it was given.
const ( KeepAll = "all" KeepLanguages = "languages" KeepNone = "none" )
Keep values for tracks.
const ( Keep = "keep" Drop = "drop" )
Yes-or-no choices about a kind of track.
const ( PresetCompatible = "compatible" PresetSaveSpace = "save-space" PresetBest = "best-quality" PresetCustom = "custom" )
Presets.
const ( FilePlanned = "planned" // a dry run looked at it FilePending = "pending" // waiting its turn FileRunning = "running" FileDone = "done" // converted, checked and in place FileSkipped = "skipped" // nothing to do FileRefused = "refused" // left alone on purpose FileFailed = "failed" // went wrong; the old file is untouched FileChanged = "changed" // the file changed while it was being converted FileNotWorth = "notworth" // came out no smaller FilePostponed = "postponed" // someone was playing it FileUndone = "undone" // the original was put back )
States of one file in a run.
const ProtectedReason = "" /* 130-byte string literal not displayed */
ProtectedReason is what a person is told about a protected file.
const TaskType = "convert"
TaskType is how conversions appear in the activity panel.
const TdarrKeySetting = "libtranscode.tdarrKey"
TdarrKeySetting is where the API key is kept.
const TdarrTaskType = "tdarr"
TdarrTaskType is how Tdarr's work appears in the activity panel.
Variables ¶
var ErrInUse = errors.New("someone is playing this right now. Try again when they've finished")
ErrInUse: someone is playing the item.
var ErrNoRun = errors.New("that conversion no longer exists")
ErrNoRun: there's no such run.
Functions ¶
func Detect ¶
Detect says whether a file is protected. It's cautious in one direction only: a mark that's really there refuses the file, and an unreadable file has nothing to say.
func HardwareFamily ¶
HardwareFamily is the part of a hardware encoder's name that says whose it is.
func SaveRule ¶
SaveRule stores a checked rule. Turning automatic runs on starts counting new files from now: what's already in the library is left to a person.
func SaveSettings ¶
SaveSettings stores the settings.
Types ¶
type Attachment ¶
Attachment is a file carried inside the file: usually a font for styled subtitles.
type AudioPolicy ¶
type AudioPolicy struct {
// Keep: all, or languages (those in Languages and, if asked, the original).
Keep string `json:"keep"`
// Languages, in the order wanted.
Languages []string `json:"languages"`
// KeepOriginal keeps the language the film was made in.
KeepOriginal bool `json:"keepOriginal"`
// Untagged: tracks with no language: keep | drop.
Untagged string `json:"untagged"`
// UntaggedAs labels those tracks with this language.
UntaggedAs string `json:"untaggedAs"`
// Commentary and Description (audio description): keep | drop.
Commentary string `json:"commentary"`
Description string `json:"description"`
// Default: the language that plays first. "" keeps what the file says.
Default string `json:"default"`
// Codec: "keep" copies every track. aac, ac3, eac3 or opus converts what isn't in
// Accept. A track is always converted if the container can't hold it.
Codec string `json:"codec"`
// Accept: codecs left as they are.
Accept []string `json:"accept"`
// Lossless (TrueHD, DTS-HD MA, FLAC, PCM...): keep | convert.
Lossless string `json:"lossless"`
// Objects (Atmos, DTS:X): keep | convert. Converting loses the objects.
Objects string `json:"objects"`
// MaxChannels: 0 keeps them. Otherwise wider tracks are converted down.
MaxChannels int `json:"maxChannels"`
// AddStereo adds a stereo track beside a surround one that has none. StereoFirst
// puts it ahead of the surround track, so plain devices start with it.
AddStereo bool `json:"addStereo"`
StereoFirst bool `json:"stereoFirst"`
}
AudioPolicy says which sound tracks stay, in what order, and in what form.
type AudioStream ¶
type AudioStream struct {
Index int
Codec string
Profile string
Channels int
Language string // short code, "" when untagged
Title string
Default bool
Commentary bool
Description bool
Original bool
Lossless bool
Objects bool // Atmos or DTS:X
Kbps int
}
AudioStream is one sound track.
type DriveRoom ¶
type DriveRoom struct {
Folder string `json:"folder"`
Free int64 `json:"free"`
Needs int64 `json:"needs"`
Enough bool `json:"enough"`
}
DriveRoom says whether a drive has room for a job.
type Engine ¶
type Engine struct {
DB *db.DB
Store *library.Store
Scanner *library.Scanner
Tools *ffmpeg.Tools
Tasks *tasks.Registry
Log *slog.Logger
// Busy counts people playing something right now. May be nil.
Busy func() int
// Playing says whether someone is playing this item right now. May be nil.
Playing func(itemID int64) bool
// SaveMeta: the server may write beside media (Settings, Metadata).
SaveMeta func() bool
// HardwareAllowed lists the hardware encoders ticked on the Transcoding page.
HardwareAllowed func() []string
// Now replaces the clock in tests.
Now func() time.Time
// HoldTick replaces how often a running conversion looks at its conditions, in tests.
HoldTick time.Duration
// TdarrPoll replaces how often a connected Tdarr is asked what it's doing, in tests.
TdarrPoll time.Duration
// AutoSettle replaces how long a new file must hold still, in tests.
AutoSettle time.Duration
// contains filtered or unexported fields
}
Engine runs conversions, one library at a time.
func (*Engine) Blocked ¶
Blocked says why a real run can't start here, "" when it can. A dry run reads only, so nothing stops it.
func (*Engine) DeleteLeftover ¶
DeleteLeftover deletes a kept original, or an unused converted copy, for good. It only ever touches a file in the hidden originals folder or one named as a converted copy.
func (*Engine) KickAllAuto ¶
KickAllAuto looks for new files in every library that wants them converted, for what was waiting when the server stopped.
func (*Engine) Leftovers ¶
func (e *Engine) Leftovers(ctx context.Context, library int64, limit int) ([]*FileRow, int64, error)
Leftovers lists kept originals and converted copies waiting for a decision.
func (*Engine) ListFiles ¶
func (e *Engine) ListFiles(ctx context.Context, run int64, state string, limit, offset int) ([]*FileRow, int, error)
ListFiles lists a run's files. state "" means all of them.
func (*Engine) LoadTdarr ¶
func (e *Engine) LoadTdarr(ctx context.Context) TdarrSettings
LoadTdarr reads the connection's settings.
func (*Engine) PreviewItem ¶
func (e *Engine) PreviewItem(ctx context.Context, lib *library.Library, id int64, p Policy) (*Preview, error)
PreviewItem plans one item, reading only.
func (*Engine) Recover ¶
Recover tidies up after a server that stopped during a conversion: temporary files go, and a swap caught half-way is finished or undone, whichever keeps the file safe.
func (*Engine) Retry ¶
Retry starts a run again, for the files that didn't get done. It works from what was recorded, so it works after a restart too.
func (*Engine) Sample ¶
func (e *Engine) Sample(ctx context.Context, lib *library.Library, id int64, p Policy, cacheDir string) (*SampleResult, error)
Sample really converts a short stretch from the middle of a file, into the server's own cache folder, and measures it. One at a time: it's real work for the processor.
func (*Engine) SaveTdarr ¶
SaveTdarr stores the connection. An empty key leaves the old one, and clear removes it.
func (*Engine) ScanFinished ¶
ScanFinished is told when a scan of a library has ended.
func (*Engine) SendToTdarr ¶
SendToTdarr hands a library's files to Tdarr, by the names Tdarr knows them by. Tdarr then does what its own plugins and flows say: nothing here chooses that.
func (*Engine) StopAuto ¶
func (e *Engine) StopAuto()
StopAuto ends every watcher, for shutting down. What they were waiting for is looked at again next time.
func (*Engine) TdarrLook ¶
func (e *Engine) TdarrLook(ctx context.Context, address, key string) TdarrReport
TdarrLook asks a Tdarr server about itself. An address or key passed here is tried without being saved, so someone can test before they save.
func (*Engine) UseCopy ¶
UseCopy puts a converted copy written beside its original into use, the original moving to the hidden folder as it would have if the run had kept it.
func (*Engine) WatchTdarr ¶
func (e *Engine) WatchTdarr()
WatchTdarr starts following Tdarr, or stops, according to the settings.
type Env ¶
type Env struct {
Encoders map[string]bool
HasFilter func(string) bool
// Hardware: hardware encoders the owner allows and a test encode has shown to work.
Hardware []string
// Sidecars: files may be written beside the video (Save next to media).
Sidecars bool
// Threads for an encoder. 0 lets FFmpeg decide.
Threads int
// ToneMap is the filter chain that makes this kind of HDR ordinary, "" when this
// FFmpeg can't. May be nil, which means it can't.
ToneMap func(rng string) string
}
Env is what the machine offers.
type FileRow ¶
type FileRow struct {
ID int64 `json:"id"`
RunID int64 `json:"runId"`
ItemID int64 `json:"itemId"`
Part int `json:"part"`
Path string `json:"path"`
Verdict string `json:"verdict"`
Reason string `json:"reason"`
State string `json:"state"`
Message string `json:"message,omitempty"`
SizeBefore int64 `json:"sizeBefore"`
SizeAfter int64 `json:"sizeAfter"`
EstBytes int64 `json:"estBytes"`
EstSec float64 `json:"estSec"`
FinalPath string `json:"finalPath,omitempty"`
KeptPath string `json:"keptPath,omitempty"`
Plan *Plan `json:"plan,omitempty"`
}
FileRow is one file of a run.
type OtherStream ¶
OtherStream is a stream that isn't picture, sound or subtitles.
type Output ¶
type Output struct {
Path string // the new file (a temporary name)
// Exports are subtitle files to write as well, by step, in the plan's order.
Exports []string
// Covers are pictures already pulled out of the source, for an MKV to attach.
Covers []string
}
Output says where a run of FFmpeg writes.
type Picture ¶
type Picture struct {
Index int
Codec string
Title string
Name string // its file name, in a file that attaches it
// Number is its place among the video streams of the file, for pulling it out.
Number int
}
Picture is cover art: a still stored as a video stream.
type Plan ¶
type Plan struct {
Verdict string `json:"verdict"`
Reason string `json:"reason"`
Container string `json:"container"` // mkv, mp4
Ext string `json:"ext"` // of the new file, without the dot
Steps []Step `json:"steps"`
Warnings []string `json:"warnings"`
Notes []string `json:"notes"`
Encoder string `json:"encoder,omitempty"`
// Estimates, for this file. See estimate.go.
EstBytes int64 `json:"estBytes"`
EstSec float64 `json:"estSec"`
// contains filtered or unexported fields
}
Plan is a decision about one file.
type PlanOptions ¶
type PlanOptions struct {
// ForceVideo: the picture is converted even if it fits, because another part of the
// same split film has to be. They'll be joined when played.
ForceVideo bool
}
PlanOptions change how a file is decided on.
type Policy ¶
type Policy struct {
Preset string `json:"preset"`
// Container: mkv, mp4 or keep (a file already in MKV or MP4 stays so, others go to MKV).
Container string `json:"container"`
Video VideoPolicy `json:"video"`
Audio AudioPolicy `json:"audio"`
Subtitles SubtitlePolicy `json:"subtitles"`
}
Policy is a complete recipe for converting a file.
func PresetPolicy ¶
PresetPolicy returns a preset's recipe.
type PresetInfo ¶
type PresetInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Summary string `json:"summary"`
Details []string `json:"details"`
Cost string `json:"cost"`
Policy Policy `json:"policy"`
}
PresetInfo is what a person reads when choosing.
func Presets ¶
func Presets() []PresetInfo
Presets are the three plain choices. Their details are the place to see exactly what each does, and a person can change any of it, which makes it custom.
type Preview ¶
type Preview struct {
ItemID int64 `json:"itemId"`
Title string `json:"title"`
Parts []PreviewPart `json:"parts"`
}
Preview is what a chosen file would become.
type PreviewPart ¶
type PreviewPart struct {
Path string `json:"path"`
Size int64 `json:"size"`
Duration float64 `json:"duration"`
Plan *Plan `json:"plan"`
}
PreviewPart is one file of it.
type Rule ¶
type Rule struct {
LibraryID int64 `json:"libraryId"`
Policy Policy `json:"policy"`
Output string `json:"output"`
// AllowWrites: conversions may write here even though the server has been told to
// keep metadata out of media folders.
AllowWrites bool `json:"allowWrites"`
// Auto: new files are converted by themselves after a scan finds them, from AutoSince on.
Auto bool `json:"auto"`
AutoSince int64 `json:"autoSince"`
Saved bool `json:"saved"`
}
Rule is what a library's files should become.
type Run ¶
type Run struct {
ID int64 `json:"id"`
LibraryID int64 `json:"libraryId"`
Dry bool `json:"dry"`
Auto bool `json:"auto"` // a scan started it, not a person
Policy Policy `json:"policy"`
Output string `json:"output"`
State string `json:"state"` // queued, running, done, failed, cancelled, interrupted
By string `json:"by,omitempty"`
CreatedAt int64 `json:"createdAt"`
Finished *int64 `json:"finishedAt,omitempty"`
Summary Summary `json:"summary"`
}
Run is one go at a library.
type RunRequest ¶
type RunRequest struct {
Library int64
Policy Policy
Output string
Dry bool
// Items limits it to these items, when given.
Items []int64
// Auto: a scan found these, and nobody pressed anything.
Auto bool
By tasks.By
}
RunRequest asks for a run.
type SampleResult ¶
type SampleResult struct {
Seconds float64 `json:"seconds"` // how much of the film was tried
Took float64 `json:"took"` // how long that took here
Speed float64 `json:"speed"` // times real time
Bytes int64 `json:"bytes"` // what that much came to
EstFileBytes int64 `json:"estFileBytes"` // the whole film at that rate
EstFileSec float64 `json:"estFileSec"`
Note string `json:"note,omitempty"`
}
SampleResult is what a short test conversion measured.
type Settings ¶
type Settings struct {
Enabled bool `json:"enabled"`
// Acknowledged: the warning has been read.
Acknowledged bool `json:"acknowledged"`
// MaxJobs: files converted at the same time.
MaxJobs int `json:"maxJobs"`
// Threads for each conversion. 0 means half of this machine's cores.
Threads int `json:"threads"`
// LowPriority: other work gets the processor first.
LowPriority bool `json:"lowPriority"`
// PauseWhileStreaming holds conversions while anyone is playing something.
PauseWhileStreaming bool `json:"pauseWhileStreaming"`
// HoursOn limits work to between HoursFrom and HoursTo, on this server's clock.
HoursOn bool `json:"hoursOn"`
HoursFrom int `json:"hoursFrom"`
HoursTo int `json:"hoursTo"`
// UseHardware allows the hardware encoders ticked on the Transcoding page.
UseHardware bool `json:"useHardware"`
// MinFreeGB: stop before a drive has less room than this.
MinFreeGB int `json:"minFreeGb"`
// SettleSeconds: automatic runs leave a new file alone until it hasn't changed for this long.
SettleSeconds int `json:"settleSeconds"`
}
Settings is how conversions run on this server. Off until the owner has read what it does to streaming and turned it on.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings suit a modest machine that's mainly there for watching things.
func LoadSettings ¶
LoadSettings reads the settings.
type Source ¶
type Source struct {
Path string
Ext string // lower case, no dot
Duration float64
Size int64
Kbps int // the whole file's average
Video []VideoStream
Covers []Picture
Audio []AudioStream
Subs []SubStream
Attachments []Attachment
Other []OtherStream // data and anything else that isn't watched or heard
Chapters int
Sidecars []Sidecar
// Original is the language the film was made in, when something says so.
Original string
}
Source is a file as the planner sees it, read from a probe.
func (*Source) AddSidecars ¶
func (s *Source) AddSidecars(found []library.SubtitleFile)
AddSidecars lists the subtitle files beside the video.
func (*Source) Main ¶
Main picks the picture a film is: one marked default that isn't simply the first (tools mark the first by themselves, so that says nothing), else the largest, else the first.
func (*Source) OriginalLanguage ¶
OriginalLanguage says which language the film was made in, and how that's known.
type Step ¶
type Step struct {
Kind string `json:"kind"` // video, cover, audio, subtitle, attachment, data, file
Action string `json:"action"` // keep, convert, drop, add, burn, export, embed, leave
From string `json:"from"`
To string `json:"to,omitempty"`
Why string `json:"why,omitempty"`
// contains filtered or unexported fields
}
Step is what happens to one track, in words for the preview, plus what the command needs. Steps of kept tracks are in the order the new file will have them.
type SubStream ¶
type SubStream struct {
Index int
Codec string
Language string
Title string
Default bool
Forced bool
SDH bool
Text bool
}
SubStream is one subtitle track inside the file.
type SubtitlePolicy ¶
type SubtitlePolicy struct {
// Keep: all, languages or none.
Keep string `json:"keep"`
Languages []string `json:"languages"`
// Forced (only foreign dialogue) tracks: keep | drop | burn (into the picture, which
// means converting the picture) | burn-images (only those that are stored as pictures,
// which can't stay in every container; text ones stay text).
Forced string `json:"forced"`
// SDH (with sound descriptions for people who can't hear): keep | drop.
SDH string `json:"sdh"`
// Untagged: keep | drop.
Untagged string `json:"untagged"`
// Images are subtitles stored as pictures (Blu-ray PGS, DVD). They can't become text
// without character recognition, which this doesn't do. keep | drop | export (Blu-ray
// ones to a .sup file beside the video when the output can't hold them).
Images string `json:"images"`
// Text: keep as they are, or srt (plain text, losing styling). A container that can't
// hold a format gets its own, whatever this says.
Text string `json:"text"`
// Sidecars are subtitle files beside the video: leave | embed.
Sidecars string `json:"sidecars"`
}
SubtitlePolicy says which subtitles stay and how.
type Summary ¶
type Summary struct {
Files int `json:"files"`
Convert int `json:"convert"`
Remux int `json:"remux"`
Skip int `json:"skip"`
Refuse int `json:"refuse"`
Done int `json:"done"`
Failed int `json:"failed"`
NotWorth int `json:"notWorth"`
Postponed int `json:"postponed"`
Changed int `json:"changed"`
BytesBefore int64 `json:"bytesBefore"`
EstBytes int64 `json:"estBytes"`
EstSec float64 `json:"estSec"`
BytesAfter int64 `json:"bytesAfter"`
NeedsBytes int64 `json:"needsBytes"`
// Drives: room on each drive involved against what the job needs there.
Drives []DriveRoom `json:"drives,omitempty"`
}
Summary adds up a run, for the page and the estimate shown before starting.
type TdarrMapping ¶
type TdarrMapping struct {
LibraryID int64 `json:"libraryId"`
TdarrID string `json:"tdarrId"`
// Folder as it's called here, and as Tdarr calls it, for when they differ.
From string `json:"from"`
To string `json:"to"`
}
TdarrMapping says which of Tdarr's libraries one of this server's libraries goes to.
type TdarrReport ¶
type TdarrReport struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
Version string `json:"version,omitempty"`
Status string `json:"status,omitempty"`
Nodes []tdarr.Node `json:"nodes"`
Libraries []tdarr.Library `json:"libraries"`
}
TdarrReport is a look at a Tdarr server.
type TdarrSettings ¶
type TdarrSettings struct {
Enabled bool `json:"enabled"`
URL string `json:"url"`
KeySet bool `json:"keySet"`
Mappings []TdarrMapping `json:"mappings"`
}
TdarrSettings is the connection. The key is kept apart and never sent back.
type VerifyProblem ¶
type VerifyProblem struct{ Why string }
VerifyProblem is a plain sentence about why a new file was thrown away.
func (*VerifyProblem) Error ¶
func (v *VerifyProblem) Error() string
type VideoPolicy ¶
type VideoPolicy struct {
// Codec: "keep" never converts the picture. Otherwise h264, hevc or av1.
Codec string `json:"codec"`
// Accept: other codecs left as they are rather than converted to Codec.
Accept []string `json:"accept"`
// Quality is on the familiar constant-quality scale: 18 looks like the source, 23 is
// good, 28 is small. Each encoder is told its own equivalent.
Quality int `json:"quality"`
// Speed: faster | balanced | slower.
Speed string `json:"speed"`
// MaxHeight: taller pictures are scaled down. 0 keeps the size.
MaxHeight int `json:"maxHeight"`
// HDR: keep | tonemap (to an ordinary picture) | refuse (leave these files alone).
HDR string `json:"hdr"`
// DolbyVision: keep (only by leaving the picture untouched, else the file is left
// alone) | base (convert from the layer other players show, losing Dolby Vision).
DolbyVision string `json:"dolbyVision"`
// EightBit: 10-bit and deeper pictures become 8-bit.
EightBit bool `json:"eightBit"`
// Deinterlace: an interlaced picture is deinterlaced, which also means converted.
Deinterlace bool `json:"deinterlace"`
// ConstantRate: a variable frame rate becomes a constant one.
ConstantRate bool `json:"constantRate"`
// ThreeD: keep (as stored) | flatten (one eye) | refuse.
ThreeD string `json:"threeD"`
// ExtraVideo: other picture streams beside the main one: keep | drop.
ExtraVideo string `json:"extraVideo"`
// MinSavingPercent: the new file must be this much smaller or the old one stays.
MinSavingPercent int `json:"minSavingPercent"`
// SkipBelowKbps: 1080p pictures below this are left alone (scaled for other sizes),
// because converting them again would lose more than it saves.
SkipBelowKbps int `json:"skipBelowKbps"`
}
VideoPolicy says what becomes of the picture.
type VideoStream ¶
type VideoStream struct {
Index int // the stream's number in the file
Codec string
Profile string
Tag string
PixFmt string
Width int
Height int
Depth int
Range string // sdr, hdr10, hlg, dv5
Dynamic string // "HDR10+", "Dolby Vision profile 8.1"
DV bool
DVProfile int
Interlaced bool
Stereo string // sbs, tab, ""
MVC bool // a second eye stored in a way a conversion would lose
Variable bool // variable frame rate
FPS float64
Kbps int
Default bool
Language string
Title string
Captions bool // closed captions inside the picture
Mastering string
ContentLight string
}
VideoStream is a real picture stream.