diff --git a/transcoder/src/audiostream.go b/transcoder/src/audiostream.go index 8e393501..ac746e32 100644 --- a/transcoder/src/audiostream.go +++ b/transcoder/src/audiostream.go @@ -22,6 +22,10 @@ func (as *AudioStream) getOutPath(encoder_id int) string { return fmt.Sprintf("%s/segment-a%d-%d-%%d.ts", as.file.Out, as.index, encoder_id) } +func (as *AudioStream) getFlags() Flags { + return AudioF +} + func (as *AudioStream) getTranscodeArgs(segments string) []string { return []string{ "-map", fmt.Sprintf("0:a:%d", as.index), diff --git a/transcoder/src/stream.go b/transcoder/src/stream.go index a90c2241..e061bee3 100644 --- a/transcoder/src/stream.go +++ b/transcoder/src/stream.go @@ -15,9 +15,17 @@ import ( "time" ) +type Flags int32 + +const ( + AudioF Flags = 1 << 0 + VideoF Flags = 1 << 1 +) + type StreamHandle interface { getTranscodeArgs(segments string) []string getOutPath(encoder_id int) string + getFlags() Flags } type Stream struct { @@ -154,12 +162,17 @@ func (ts *Stream) run(start int32) error { args := []string{ "-nostats", "-hide_banner", "-loglevel", "warning", + } + if ts.handle.getFlags()&VideoF != 0 { // This is the default behavior in transmux mode and needed to force pre/post segment to work - "-noaccurate_seek", + // This must be disabled when processing only audio because it creates gaps in audio + args = append(args, "-noaccurate_seek") + } + args = append(args, "-ss", fmt.Sprintf("%.6f", start_ref), "-i", ts.file.Path, - } + ) // do not include -to if we want the file to go to the end if end+1 < int32(len(ts.file.Keyframes)) { // sometimes, the duration is shorter than expected (only during transcode it seems) diff --git a/transcoder/src/videostream.go b/transcoder/src/videostream.go index bc5b3056..2c1f8a96 100644 --- a/transcoder/src/videostream.go +++ b/transcoder/src/videostream.go @@ -18,6 +18,10 @@ func NewVideoStream(file *FileStream, quality Quality) *VideoStream { return ret } +func (vs *VideoStream) getFlags() Flags { + return VideoF +} + func (vs *VideoStream) getOutPath(encoder_id int) string { return fmt.Sprintf("%s/segment-%s-%d-%%d.ts", vs.file.Out, vs.quality, encoder_id) }