cmd

package
v0.0.0-...-a237d07 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StrippedSDH = iota
	Sub
	Dub
	CC
)

Variables

View Source
var AstisubSupportedExt = []string{".srt", ".ass", ".ssa", "vtt", ".stl", ".ttml"}
View Source
var CodecToExtension = map[string]string{
	"MP3":        ".mp3",
	"AAC":        ".aac",
	"WMA":        ".wma",
	"FLAC":       ".flac",
	"ALAC":       ".m4a",
	"Opus":       ".opus",
	"Vorbis":     ".ogg",
	"PCM":        ".wav",
	"WAV":        ".wav",
	"AIFF":       ".aiff",
	"RealAudio":  ".ra",
	"AMR":        ".amr",
	"MPEG-4 ALS": ".mp4",
	"MPEG Audio": ".mp3",
	"AC-3":       ".ac3",
	"DTS":        ".dts",
	"TrueHD":     ".thd",
	"E-AC-3":     ".eac3",
	"MKA":        ".mka",
	"WebM":       ".webm",
	"Speex":      ".spx",
	"Musepack":   ".mpc",
}
View Source
var MediainfoPath = "mediainfo"
View Source
var (
	STT string
)

Functions

func Base2Absolute

func Base2Absolute(s, dir string) string

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func IsZeroLengthTimespan

func IsZeroLengthTimespan(last, t time.Duration) (b bool)

func NoSub

func NoSub(s string) string

func SetPrefered

func SetPrefered(langs []Lang, l, atm Lang, name string, out *string) bool

Types

type AudioTrack

type AudioTrack struct {
	Type                     string `json:"@type"`
	StreamOrder              string `json:"StreamOrder"`
	ID                       string `json:"ID"`
	Format                   string `json:"Format"`
	FormatCommercialIfAny    string `json:"Format_Commercial_IfAny"`
	FormatSettingsSBR        string `json:"Format_Settings_SBR"`
	FormatAdditionalFeatures string `json:"Format_AdditionalFeatures"`
	CodecID                  string `json:"CodecID"`
	Duration                 string `json:"Duration"`
	BitRateMode              string `json:"BitRate_Mode"`
	BitRate                  string `json:"BitRate"`
	Channels                 string `json:"Channels"`
	ChannelPositions         string `json:"ChannelPositions"`
	ChannelLayout            string `json:"ChannelLayout"`
	SamplesPerFrame          string `json:"SamplesPerFrame"`
	SamplingRate             string `json:"SamplingRate"`
	SamplingCount            string `json:"SamplingCount"`
	FrameRate                string `json:"FrameRate"`
	FrameCount               string `json:"FrameCount"`
	CompressionMode          string `json:"Compression_Mode"`
	StreamSize               string `json:"StreamSize"`
	StreamSizeProportion     string `json:"StreamSize_Proportion"`
	Title                    string `json:"Title"`
	LangRaw                  string `json:"Language"`
	Language                 *iso.Language
	Default                  string `json:"Default"`
	AlternateGroup           string `json:"AlternateGroup"`
}

AudioTrack represents the information about the audio stream in the media file

type CreatingLibrary

type CreatingLibrary struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

CreatingLibrary represents the information about the library used to create the media information

type GeneralTrack

type GeneralTrack struct {
	Type                  string `json:"@type"`
	VideoCount            string `json:"VideoCount"`
	AudioCount            string `json:"AudioCount"`
	FileExtension         string `json:"FileExtension"`
	Format                string `json:"Format"`
	FormatProfile         string `json:"Format_Profile"`
	CodecID               string `json:"CodecID"`
	CodecIDCompatible     string `json:"CodecID_Compatible"`
	FileSize              string `json:"FileSize"`
	Duration              string `json:"Duration"`
	OverallBitRate        string `json:"OverallBitRate"`
	FrameRate             string `json:"FrameRate"`
	FrameCount            string `json:"FrameCount"`
	StreamSize            string `json:"StreamSize"`
	HeaderSize            string `json:"HeaderSize"`
	DataSize              string `json:"DataSize"`
	FooterSize            string `json:"FooterSize"`
	IsStreamable          string `json:"IsStreamable"`
	Title                 string `json:"Title"`
	Collection            string `json:"Collection"`
	Season                string `json:"Season"`
	Track                 string `json:"Track"`
	Description           string `json:"Description"`
	RecordedDate          string `json:"Recorded_Date"`
	FileModifiedDate      string `json:"File_Modified_Date"`
	FileModifiedDateLocal string `json:"File_Modified_Date_Local"`
	EncodedApplication    string `json:"Encoded_Application"`
	Cover                 string `json:"Cover"`
	Extra                 struct {
		PartID string `json:"Part_ID"`
	} `json:"extra"`
}

GeneralTrack represents the general information about the media file

type Lang

type Lang struct {
	*iso.Language
	// Typically a ISO 3166-1 region but can also be a ISO 15924 script
	Subtag string
}

func GuessLangFromFilename

func GuessLangFromFilename(name string) (lang Lang, err error)

Only 1st subtag found is considered, the others are ignored

func ReadStdLangCode

func ReadStdLangCode(arr []string) (langs []Lang, err error)

type MediaInfo

type MediaInfo struct {
	CreatingLibrary CreatingLibrary
	GeneralTrack    GeneralTrack
	VideoTrack      VideoTrack
	AudioTracks     []AudioTrack
}

MediaInfo represents the media information including general, video, and audio tracks

type Meta

type Meta struct {
	FFmpeg    string
	MediaInfo MediaInfo
	Runtime   string
}

type ProcessedItem

type ProcessedItem struct {
	ID          time.Duration
	AlreadyDone bool
	Sound       string
	Time        string
	Source      string
	Image       string
	ForeignCurr string
	NativeCurr  string
	ForeignPrev string
	NativePrev  string
	ForeignNext string
	NativeNext  string
}

ProcessedItem represents the exported information of a single subtitle item, where Time is the primary field which identifies the item and ForeignCurr is the actual text of the item. The fields NativeCurr, NativePrev and NativeNext will be empty unless a second subtitle file was specified for the export and that second subtitle file is sufficiently aligned with the first.

type ProcessedItemWriter

type ProcessedItemWriter func(*os.File, *ProcessedItem)

ProcessedItemWriter should write an exported item in whatever format is // selected by the user.

type RawMedia

type RawMedia struct {
	Ref   string            `json:"@ref"`
	Track []json.RawMessage `json:"track"`
}

type RawMediaInfo

type RawMediaInfo struct {
	CreatingLibrary CreatingLibrary `json:"creatingLibrary"`
	Media           RawMedia        `json:"media"`
}

type Task

type Task struct {
	Log                 zerolog.Logger
	Meta                Meta
	OriginalLang        string // FIXME what for?
	Langs               []string
	RefLangs            []Lang
	Targ                Lang
	SeparationLib       string
	STT                 string
	TargetChan          int
	UseAudiotrack       int
	TimeoutSTT          int
	TimeoutSep          int
	Offset              time.Duration
	WantDubs            bool
	IsBulkProcess       bool
	DubsOnly            bool
	IsCCorDubs          bool
	TargSubFile         string
	NativeSubFile       string
	NativeSubs          *subs.Subtitles
	MediaPrefix         string
	MediaSourceFile     string
	FieldSep            string // defaults to "\t"
	OutputFileExtension string // defaults to ".tsv" for "\t" and ".csv", otherwise
}

func DefaultTask

func DefaultTask(cmd *cobra.Command) *Task

func (*Task) Autosub

func (tsk *Task) Autosub()

func (*Task) ChooseAudio

func (tsk *Task) ChooseAudio(f func(i int, track AudioTrack))

func (*Task) ConcatWAVstoOGG

func (tsk *Task) ConcatWAVstoOGG(suffix string)

func (*Task) Execute

func (tsk *Task) Execute()

func (*Task) PrepareLangs

func (tsk *Task) PrepareLangs()

func (*Task) ProcessItem

func (tsk *Task) ProcessItem(foreignItem *astisub.Item) (item ProcessedItem)

func (*Task) Supervisor

func (tsk *Task) Supervisor(foreignSubs *subs.Subtitles, outStream *os.File, write ProcessedItemWriter)

type VideoTrack

type VideoTrack struct {
	Type               string `json:"@type"`
	StreamOrder        string `json:"StreamOrder"`
	ID                 string `json:"ID"`
	Format             string `json:"Format"`
	FormatProfile      string `json:"Format_Profile"`
	FormatLevel        string `json:"Format_Level"`
	CodecID            string `json:"CodecID"`
	Duration           string `json:"Duration"`
	BitRate            string `json:"BitRate"`
	Width              string `json:"Width"`
	Height             string `json:"Height"`
	SampledWidth       string `json:"Sampled_Width"`
	SampledHeight      string `json:"Sampled_Height"`
	PixelAspectRatio   string `json:"PixelAspectRatio"`
	DisplayAspectRatio string `json:"DisplayAspectRatio"`
	Rotation           string `json:"Rotation"`
	FrameRateMode      string `json:"FrameRate_Mode"`
	FrameRate          string `json:"FrameRate"`
	FrameRateMinimum   string `json:"FrameRate_Minimum"`
	FrameRateMaximum   string `json:"FrameRate_Maximum"`
	FrameCount         string `json:"FrameCount"`
	ColorSpace         string `json:"ColorSpace"`
	ChromaSubsampling  string `json:"ChromaSubsampling"`
	BitDepth           string `json:"BitDepth"`
	StreamSize         string `json:"StreamSize"`
	Title              string `json:"Title"`
	ColourRange        string `json:"colour_range"`
	ColourRangeSource  string `json:"colour_range_Source"`
	Extra              struct {
		CodecConfigurationBox string `json:"CodecConfigurationBox"`
	} `json:"extra"`
}

VideoTrack represents the information about the video stream in the media file

Jump to

Keyboard shortcuts

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