mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Remove padding segment at the start
This commit is contained in:
parent
9531795066
commit
f5c629cb8a
@ -138,21 +138,21 @@ func (ts *Stream) run(start int32) error {
|
|||||||
// Having an extra segment allows us to cut precisely the segments we want with the
|
// Having an extra segment allows us to cut precisely the segments we want with the
|
||||||
// -f segment that does cut the begining and the end at the keyframe like asked
|
// -f segment that does cut the begining and the end at the keyframe like asked
|
||||||
start_ref := float64(0)
|
start_ref := float64(0)
|
||||||
start_padding := int32(0)
|
if start != 0 {
|
||||||
if start == 0 {
|
// the param for the -ss takes the keyframe before the specificed time
|
||||||
start_padding = 1
|
|
||||||
} else {
|
|
||||||
// the param for the -ss. This takes the keyframe before the specificed time
|
|
||||||
// (if the specified time is a keyframe, it either takes that keyframe or the one before)
|
// (if the specified time is a keyframe, it either takes that keyframe or the one before)
|
||||||
// to prevent this weird behavior, we specify a bit before the keyframe that interest us
|
// to prevent this weird behavior, we specify a bit after the keyframe that interest us
|
||||||
// and the first segment will contains the extra we do not want.
|
if start+1 == int32(len(ts.file.Keyframes)) {
|
||||||
start_ref = (ts.file.Keyframes[start-1] + ts.file.Keyframes[start]) / 2
|
start_ref = (ts.file.Keyframes[start] + float64(ts.file.Info.Duration)) / 2
|
||||||
|
} else {
|
||||||
|
start_ref = (ts.file.Keyframes[start] + ts.file.Keyframes[start+1]) / 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end_padding := int32(1)
|
end_padding := int32(1)
|
||||||
if end == int32(len(ts.file.Keyframes)) {
|
if end == int32(len(ts.file.Keyframes)) {
|
||||||
end_padding = 0
|
end_padding = 0
|
||||||
}
|
}
|
||||||
segments := ts.file.Keyframes[start+start_padding : end+end_padding]
|
segments := ts.file.Keyframes[start+1 : end+end_padding]
|
||||||
if len(segments) == 0 {
|
if len(segments) == 0 {
|
||||||
// we can't leave that empty else ffmpeg errors out.
|
// we can't leave that empty else ffmpeg errors out.
|
||||||
segments = []float64{9999999}
|
segments = []float64{9999999}
|
||||||
@ -189,13 +189,10 @@ func (ts *Stream) run(start int32) error {
|
|||||||
// sometimes, the duration is shorter than expected (only during transcode it seems)
|
// sometimes, the duration is shorter than expected (only during transcode it seems)
|
||||||
// always include more and use the -f segment to split the file where we want
|
// always include more and use the -f segment to split the file where we want
|
||||||
end_ref := ts.file.Keyframes[end+1]
|
end_ref := ts.file.Keyframes[end+1]
|
||||||
if start_ref != 0 {
|
// it seems that the -to is confused when -ss seek before the given time (because it searches for a keyframe)
|
||||||
// it seems that the -to is confused when -ss seek before the given time
|
// add back the time that would be lost otherwise
|
||||||
// (because it searches for a keyframe)
|
// this only appens when -to is before -i but having -to after -i gave a bug (not sure, don't remember)
|
||||||
// add back the time that would be lost otherwise
|
end_ref += start_ref - ts.file.Keyframes[start]
|
||||||
// this only appens when -to is before -i but having -to after -i gave a bug (not sure, don't remember)
|
|
||||||
end_ref += start_ref - ts.file.Keyframes[start-1]
|
|
||||||
}
|
|
||||||
args = append(args,
|
args = append(args,
|
||||||
"-to", fmt.Sprintf("%.6f", end_ref),
|
"-to", fmt.Sprintf("%.6f", end_ref),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user