Disable noaccurate_seek on audio streams

This commit is contained in:
Zoe Roux 2024-02-11 16:08:02 +01:00
parent 4993d34835
commit 1e0ff4a950
3 changed files with 23 additions and 2 deletions

View File

@ -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),

View File

@ -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)

View File

@ -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)
}