mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Fix video miss-cut because of start offset (#505)
This commit is contained in:
parent
c8cc2fc057
commit
9061b2e8d9
@ -119,6 +119,13 @@ func getKeyframes(path string, kf *Keyframe) error {
|
|||||||
ret := make([]float64, 0, 1000)
|
ret := make([]float64, 0, 1000)
|
||||||
max := 100
|
max := 100
|
||||||
done := 0
|
done := 0
|
||||||
|
// sometimes, videos can start at a timing greater than 0:00. We need to take that into account
|
||||||
|
// and only list keyframes that come after the start of the video (without that, our segments count
|
||||||
|
// mismatch and we can have the same segment twice on the stream).
|
||||||
|
//
|
||||||
|
// We can't hardcode the first keyframe at 0 because the transcoder needs to reference durations of segments
|
||||||
|
// To handle this edge case, when we fetch the segment n0, no seeking is done but duration is computed from the
|
||||||
|
// first keyframe (instead of 0)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
frame := scanner.Text()
|
frame := scanner.Text()
|
||||||
if frame == "" {
|
if frame == "" {
|
||||||
@ -143,16 +150,6 @@ func getKeyframes(path string, kf *Keyframe) error {
|
|||||||
// the segment time and decide to cut at a random keyframe. Having every keyframe
|
// the segment time and decide to cut at a random keyframe. Having every keyframe
|
||||||
// handled as a segment prevents that.
|
// handled as a segment prevents that.
|
||||||
|
|
||||||
if done == 0 && len(ret) == 0 {
|
|
||||||
// sometimes, videos can start at a timing greater than 0:00. We need to take that into account
|
|
||||||
// and only list keyframes that come after the start of the video (without that, our segments count
|
|
||||||
// mismatch and we can have the same segment twice on the stream).
|
|
||||||
|
|
||||||
// we hardcode 0 as the first keyframe (even if this is fake) because it makes the code way easier to follow.
|
|
||||||
// this value is actually never sent to ffmpeg anyways.
|
|
||||||
ret = append(ret, 0)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ret = append(ret, fpts)
|
ret = append(ret, fpts)
|
||||||
|
|
||||||
if len(ret) == max {
|
if len(ret) == max {
|
||||||
|
@ -19,7 +19,7 @@ var safe_path = src.GetEnvOr("GOCODER_SAFE_PATH", "/video")
|
|||||||
// Encode the version in the hash path to update cached values.
|
// Encode the version in the hash path to update cached values.
|
||||||
// Older versions won't be deleted (needed to allow multiples versions of the transcoder to run at the same time)
|
// Older versions won't be deleted (needed to allow multiples versions of the transcoder to run at the same time)
|
||||||
// If the version changes a lot, we might want to automatically delete older versions.
|
// If the version changes a lot, we might want to automatically delete older versions.
|
||||||
var version = "v2-"
|
var version = "v3-"
|
||||||
|
|
||||||
func GetPath(c echo.Context) (string, string, error) {
|
func GetPath(c echo.Context) (string, string, error) {
|
||||||
key := c.Param("path")
|
key := c.Param("path")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user