Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mh-orange/ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
abates committed Jul 22, 2019
2 parents 99c952f + d97fd17 commit 046958f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type output struct {
vCodecOptions []string

pix_fmt string
sCodec string

format string
formatOptions []string
Expand Down Expand Up @@ -60,6 +61,10 @@ func (out *output) process(job *transcodeJob) error {
job.proc.AppendArgs("-map", "0")
}

if out.sCodec != "" {
job.proc.AppendArgs("-c:s", out.sCodec)
}

if out.format != "" {
job.proc.AppendArgs("-f", out.format)
job.proc.AppendArgs(out.formatOptions...)
Expand Down Expand Up @@ -136,6 +141,14 @@ func CopyAudioOption() OutputOption {
return AudioCodecOption("copy")
}

// CopySubtitlesOption will set the subtitle codec to copy
func CopySubtitlesOption() OutputOption {
return func(output *output) error {
output.sCodec = "copy"
return nil
}
}

// CopyOutput sets both the audio and video codecs to copy
func CopyOutput() OutputOption {
return func(output *output) error {
Expand Down
6 changes: 3 additions & 3 deletions transcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func (job *transcodeJob) run(cancelCh chan struct{}, doneCh chan struct{}, stder

job.err = job.proc.Wait()
if job.err != nil {
if len(job.log) > 2 {
if len(job.log) >= 2 {
job.err = errors.New(strings.Join(job.log[len(job.log)-2:], "\n"))
} else {
job.err = errors.New(strings.Join(job.log, "\n"))
} else if len(job.log) == 1 {
job.err = errors.New(job.log[0])
}
}
}
Expand Down

0 comments on commit 046958f

Please sign in to comment.