mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-13 02:48:33 -04:00
Fix out of range end get (#1495)
This commit is contained in:
commit
7f9ccf9ffd
@ -196,6 +196,9 @@ func (ts *Stream) run(ctx context.Context, start int32) error {
|
||||
end_padding := int32(1)
|
||||
if end == length {
|
||||
end_padding = 0
|
||||
} else if copy_audio {
|
||||
// Copy-audio runs keep one extra overlap segment because we drop it
|
||||
end_padding += 1
|
||||
}
|
||||
segments := ts.keyframes.Slice(start_segment+1, end+end_padding)
|
||||
if len(segments) == 0 {
|
||||
@ -344,7 +347,7 @@ func (ts *Stream) run(ctx context.Context, start int32) error {
|
||||
cmd.Process.Signal(os.Interrupt)
|
||||
slog.InfoContext(ctx, "killing ffmpeg because segment already ready", "segment", segment, "encoderId", encoder_id)
|
||||
should_stop = true
|
||||
} else if copy_audio && end < length && segment == end-1 {
|
||||
} else if copy_audio && end < length-1 && segment == end {
|
||||
// Extra overlap segment for copied audio.
|
||||
// Delete the file immediately and stop without closing
|
||||
// the channel, so a real producer can close it later.
|
||||
|
||||
@ -178,8 +178,8 @@ func listHeadRanges(file *FileStream, stream *Stream, isVideo bool, index uint32
|
||||
|
||||
end := stream.file.Info.Duration
|
||||
length, _ := stream.keyframes.Length()
|
||||
if head.end <= length {
|
||||
end = stream.keyframes.Get(head.end)
|
||||
if head.end-1 < length {
|
||||
end = stream.keyframes.Get(head.end - 1)
|
||||
}
|
||||
|
||||
ret = append(ret, HeadRange{
|
||||
@ -204,7 +204,7 @@ func listHeadRanges(file *FileStream, stream *Stream, isVideo bool, index uint32
|
||||
|
||||
ret = append(ret, HeadRange{
|
||||
Start: stream.keyframes.Get(start),
|
||||
End: stream.keyframes.Get(end),
|
||||
End: stream.keyframes.Get(end - 1),
|
||||
StartHead: start,
|
||||
EndHead: end,
|
||||
IsRunning: false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user