@@ -23,7 +23,8 @@ type Transcoder struct {
2323 config * Config
2424 input string
2525 output []string
26- options [][]string
26+ inputOptions []string
27+ outputOptions [][]string
2728 metadata transcoder.Metadata
2829 inputPipeReader * io.ReadCloser
2930 outputPipeReader * io.ReadCloser
@@ -38,7 +39,7 @@ func New(cfg *Config) transcoder.Transcoder {
3839}
3940
4041// Start ...
41- func (t * Transcoder ) Start (opts transcoder. Options ) (<- chan transcoder.Progress , error ) {
42+ func (t * Transcoder ) Start () (<- chan transcoder.Progress , error ) {
4243
4344 var stderrIn io.ReadCloser
4445
@@ -58,24 +59,30 @@ func (t *Transcoder) Start(opts transcoder.Options) (<-chan transcoder.Progress,
5859 }
5960
6061 // Append input file and standard options
61- args := append ([]string {"-i" , t .input }, opts .GetStrArguments ()... )
62+ var args []string
63+
64+ if len (t .inputOptions ) > 0 {
65+ args = append (args , t .inputOptions ... )
66+ }
67+
68+ args = append (args , []string {"-i" , t .input }... )
6269 outputLength := len (t .output )
63- optionsLength := len (t .options )
70+ outputOptionsLength := len (t .outputOptions )
6471
65- if outputLength == 1 && optionsLength == 0 {
72+ if outputLength == 1 && outputOptionsLength == 0 {
6673 // Just append the 1 output file we've got
6774 args = append (args , t .output [0 ])
6875 } else {
6976 for index , out := range t .output {
7077 // Get executable flags
7178 // If we are at the last output file but still have several options, append them all at once
72- if index == outputLength - 1 && outputLength < optionsLength {
73- for i := index ; i < len (t .options ); i ++ {
74- args = append (args , t .options [i ]... )
79+ if index == outputLength - 1 && outputLength < outputOptionsLength {
80+ for i := index ; i < len (t .outputOptions ); i ++ {
81+ args = append (args , t .outputOptions [i ]... )
7582 }
7683 // Otherwise just append the current options
7784 } else {
78- args = append (args , t .options [index ]... )
85+ args = append (args , t .outputOptions [index ]... )
7986 }
8087
8188 // Append output flag
@@ -158,15 +165,27 @@ func (t *Transcoder) OutputPipe(w *io.WriteCloser, r *io.ReadCloser) transcoder.
158165 return t
159166}
160167
161- // WithOptions Sets the options object
162- func (t * Transcoder ) WithOptions (opts transcoder.Options ) transcoder.Transcoder {
163- t .options = [][]string {opts .GetStrArguments ()}
168+ // WithInputOptions Sets the options object
169+ func (t * Transcoder ) WithInputOptions (opts transcoder.Options ) transcoder.Transcoder {
170+ t .inputOptions = opts .GetStrArguments ()
171+ return t
172+ }
173+
174+ // WithAdditionalInputOptions Appends an additional options object
175+ func (t * Transcoder ) WithAdditionalInputOptions (opts transcoder.Options ) transcoder.Transcoder {
176+ t .inputOptions = append (t .inputOptions , opts .GetStrArguments ()... )
177+ return t
178+ }
179+
180+ // WithOutputOptions Sets the options object
181+ func (t * Transcoder ) WithOutputOptions (opts transcoder.Options ) transcoder.Transcoder {
182+ t .outputOptions = [][]string {opts .GetStrArguments ()}
164183 return t
165184}
166185
167- // WithAdditionalOptions Appends an additional options object
168- func (t * Transcoder ) WithAdditionalOptions (opts transcoder.Options ) transcoder.Transcoder {
169- t .options = append (t .options , opts .GetStrArguments ())
186+ // WithAdditionalOutputOptions Appends an additional options object
187+ func (t * Transcoder ) WithAdditionalOutputOptions (opts transcoder.Options ) transcoder.Transcoder {
188+ t .outputOptions = append (t .outputOptions , opts .GetStrArguments ())
170189 return t
171190}
172191
@@ -196,7 +215,7 @@ func (t *Transcoder) validate() error {
196215
197216 // length of output files being greater than length of options would produce an invalid ffmpeg command
198217 // unless there is only 1 output file, which obviously wouldn't be a problem
199- if outputLength > len (t .options ) && outputLength != 1 {
218+ if outputLength > len (t .outputOptions ) && outputLength != 1 {
200219 return errors .New ("number of options and output files does not match" )
201220 }
202221
0 commit comments