Skip to content

Commit

Permalink
Updates for subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
abates committed Mar 25, 2019
1 parent 126cc46 commit d97fd17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 12 additions & 2 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type output struct {
vCodec string
vCodecOptions []string

sCodec string

format string
formatOptions []string

Expand All @@ -49,8 +51,8 @@ func (out *output) process(job *transcodeJob) error {
job.proc.AppendArgs(out.aCodecOptions...)
}

if out.vCodec == "copy" || out.aCodec == "copy" {
job.proc.AppendArgs("-map", "0")
if out.sCodec != "" {
job.proc.AppendArgs("-c:s", out.sCodec)
}

if out.format != "" {
Expand Down Expand Up @@ -114,6 +116,14 @@ func CopyAudioOption() OutputOption {
}
}

// 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: 5 additions & 1 deletion transcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ func (job *transcodeJob) run(cancelCh chan struct{}, doneCh chan struct{}, stder

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

Expand Down

0 comments on commit d97fd17

Please sign in to comment.