From 7fd97c9a844b8af7cab1c686b464fa92aa64b298 Mon Sep 17 00:00:00 2001 From: ZeroX-DG Date: Sat, 20 Jan 2024 23:45:06 +1300 Subject: [PATCH 1/2] Support global opts --- ffmpeg/ffmpeg.go | 2 +- ffmpeg/options.go | 14 ++++++++++++++ options.go | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ffmpeg/ffmpeg.go b/ffmpeg/ffmpeg.go index ef9755d..0ac3bf9 100644 --- a/ffmpeg/ffmpeg.go +++ b/ffmpeg/ffmpeg.go @@ -59,7 +59,7 @@ func (t *Transcoder) Start(opts transcoder.Options) (<-chan transcoder.Progress, } // Append input file and standard options - args := append([]string{"-i", t.input}, opts.GetStrArguments()...) + args := append(append(opts.GetGlobalStrArguments(), []string{"-i", t.input}...), opts.GetStrArguments()...) outputLength := len(t.output) optionsLength := len(t.options) diff --git a/ffmpeg/options.go b/ffmpeg/options.go index 323d4b3..84a3c53 100644 --- a/ffmpeg/options.go +++ b/ffmpeg/options.go @@ -66,6 +66,17 @@ type Options struct { WhiteListProtocols []string `flag:"-protocol_whitelist"` Overwrite *bool `flag:"-y"` ExtraArgs map[string]interface{} + GlobalArgs map[string]interface{} +} + +func (opts Options) GetGlobalStrArguments() []string { + values := []string{} + if opts.GlobalArgs != nil { + for k, v := range opts.GlobalArgs { + values = append(values, k, fmt.Sprintf("%v", v)) + } + } + return values } // GetStrArguments ... @@ -98,6 +109,9 @@ func (opts Options) GetStrArguments() []string { } if vm, ok := value.(map[string]interface{}); ok { + if f.Field(i).Name == "GlobalArgs" { + continue + } for k, v := range vm { values = append(values, k, fmt.Sprintf("%v", v)) } diff --git a/options.go b/options.go index 3813a9f..ecc3077 100644 --- a/options.go +++ b/options.go @@ -3,4 +3,5 @@ package transcoder // Options ... type Options interface { GetStrArguments() []string + GetGlobalStrArguments() []string } From f620483e303f377089395ef0c36e2709522f4fbd Mon Sep 17 00:00:00 2001 From: ZeroX-DG Date: Sun, 21 Jan 2024 12:13:16 +1300 Subject: [PATCH 2/2] Renamed to ZeroX-DG transcoder --- ffmpeg/ffmpeg.go | 4 +-- ffmpeg/metadata.go | 80 +++++++++++++++++++++++----------------------- go.mod | 2 +- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/ffmpeg/ffmpeg.go b/ffmpeg/ffmpeg.go index 0ac3bf9..f2ec041 100644 --- a/ffmpeg/ffmpeg.go +++ b/ffmpeg/ffmpeg.go @@ -14,8 +14,8 @@ import ( "strconv" "strings" - "github.com/floostack/transcoder" - "github.com/floostack/transcoder/utils" + "github.com/ZeroX-DG/transcoder" + "github.com/ZeroX-DG/transcoder/utils" ) // Transcoder ... diff --git a/ffmpeg/metadata.go b/ffmpeg/metadata.go index 4e81910..295169b 100644 --- a/ffmpeg/metadata.go +++ b/ffmpeg/metadata.go @@ -1,6 +1,6 @@ package ffmpeg -import "github.com/floostack/transcoder" +import "github.com/ZeroX-DG/transcoder" // Metadata ... type Metadata struct { @@ -142,197 +142,197 @@ func (t Tags) GetEncoder() string { return t.Encoder } -//GetIndex ... +// GetIndex ... func (s Streams) GetIndex() int { return s.Index } -//GetID ... +// GetID ... func (s Streams) GetID() string { return s.ID } -//GetCodecName ... +// GetCodecName ... func (s Streams) GetCodecName() string { return s.CodecName } -//GetCodecLongName ... +// GetCodecLongName ... func (s Streams) GetCodecLongName() string { return s.CodecLongName } -//GetProfile ... +// GetProfile ... func (s Streams) GetProfile() string { return s.Profile } -//GetCodecType ... +// GetCodecType ... func (s Streams) GetCodecType() string { return s.CodecType } -//GetCodecTimeBase ... +// GetCodecTimeBase ... func (s Streams) GetCodecTimeBase() string { return s.CodecTimeBase } -//GetCodecTagString ... +// GetCodecTagString ... func (s Streams) GetCodecTagString() string { return s.CodecTagString } -//GetCodecTag ... +// GetCodecTag ... func (s Streams) GetCodecTag() string { return s.CodecTag } -//GetWidth ... +// GetWidth ... func (s Streams) GetWidth() int { return s.Width } -//GetHeight ... +// GetHeight ... func (s Streams) GetHeight() int { return s.Height } -//GetCodedWidth ... +// GetCodedWidth ... func (s Streams) GetCodedWidth() int { return s.CodedWidth } -//GetCodedHeight ... +// GetCodedHeight ... func (s Streams) GetCodedHeight() int { return s.CodedHeight } -//GetHasBFrames ... +// GetHasBFrames ... func (s Streams) GetHasBFrames() int { return s.HasBFrames } -//GetSampleAspectRatio ... +// GetSampleAspectRatio ... func (s Streams) GetSampleAspectRatio() string { return s.SampleAspectRatio } -//GetDisplayAspectRatio ... +// GetDisplayAspectRatio ... func (s Streams) GetDisplayAspectRatio() string { return s.DisplayAspectRatio } -//GetPixFmt ... +// GetPixFmt ... func (s Streams) GetPixFmt() string { return s.PixFmt } -//GetLevel ... +// GetLevel ... func (s Streams) GetLevel() int { return s.Level } -//GetChromaLocation ... +// GetChromaLocation ... func (s Streams) GetChromaLocation() string { return s.ChromaLocation } -//GetRefs ... +// GetRefs ... func (s Streams) GetRefs() int { return s.Refs } -//GetQuarterSample ... +// GetQuarterSample ... func (s Streams) GetQuarterSample() string { return s.QuarterSample } -//GetDivxPacked ... +// GetDivxPacked ... func (s Streams) GetDivxPacked() string { return s.DivxPacked } -//GetRFrameRrate ... +// GetRFrameRrate ... func (s Streams) GetRFrameRrate() string { return s.RFrameRrate } -//GetAvgFrameRate ... +// GetAvgFrameRate ... func (s Streams) GetAvgFrameRate() string { return s.AvgFrameRate } -//GetTimeBase ... +// GetTimeBase ... func (s Streams) GetTimeBase() string { return s.TimeBase } -//GetDurationTs ... +// GetDurationTs ... func (s Streams) GetDurationTs() int { return s.DurationTs } -//GetDuration ... +// GetDuration ... func (s Streams) GetDuration() string { return s.Duration } -//GetDisposition ... +// GetDisposition ... func (s Streams) GetDisposition() transcoder.Disposition { return s.Disposition } -//GetBitRate ... +// GetBitRate ... func (s Streams) GetBitRate() string { return s.BitRate } -//GetDefault ... +// GetDefault ... func (d Disposition) GetDefault() int { return d.Default } -//GetDub ... +// GetDub ... func (d Disposition) GetDub() int { return d.Dub } -//GetOriginal ... +// GetOriginal ... func (d Disposition) GetOriginal() int { return d.Original } -//GetComment ... +// GetComment ... func (d Disposition) GetComment() int { return d.Comment } -//GetLyrics ... +// GetLyrics ... func (d Disposition) GetLyrics() int { return d.Lyrics } -//GetKaraoke ... +// GetKaraoke ... func (d Disposition) GetKaraoke() int { return d.Karaoke } -//GetForced ... +// GetForced ... func (d Disposition) GetForced() int { return d.Forced } -//GetHearingImpaired ... +// GetHearingImpaired ... func (d Disposition) GetHearingImpaired() int { return d.HearingImpaired } -//GetVisualImpaired ... +// GetVisualImpaired ... func (d Disposition) GetVisualImpaired() int { return d.VisualImpaired } -//GetCleanEffects ... +// GetCleanEffects ... func (d Disposition) GetCleanEffects() int { return d.CleanEffects } diff --git a/go.mod b/go.mod index 4c9ade4..f232c9a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/floostack/transcoder +module github.com/ZeroX-DG/transcoder go 1.13