mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Fix dual keyframe extractions
This commit is contained in:
parent
45d17fdd2c
commit
b50501907c
@ -9,6 +9,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
@ -55,6 +56,9 @@ type MediaInfo struct {
|
|||||||
Fonts []string `json:"fonts"`
|
Fonts []string `json:"fonts"`
|
||||||
/// The list of chapters. See Chapter for more information.
|
/// The list of chapters. See Chapter for more information.
|
||||||
Chapters []Chapter `json:"chapters"`
|
Chapters []Chapter `json:"chapters"`
|
||||||
|
|
||||||
|
/// lock used to read/set keyframes of video/audio
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type Video struct {
|
type Video struct {
|
||||||
|
@ -89,11 +89,17 @@ type KeyframeKey struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *MetadataService) GetKeyframes(info *MediaInfo, isVideo bool, idx uint32) (*Keyframe, error) {
|
func (s *MetadataService) GetKeyframes(info *MediaInfo, isVideo bool, idx uint32) (*Keyframe, error) {
|
||||||
|
info.lock.Lock()
|
||||||
|
var ret *Keyframe
|
||||||
if isVideo && info.Videos[idx].Keyframes != nil {
|
if isVideo && info.Videos[idx].Keyframes != nil {
|
||||||
return info.Videos[idx].Keyframes, nil
|
ret = info.Videos[idx].Keyframes
|
||||||
}
|
}
|
||||||
if !isVideo && info.Audios[idx].Keyframes != nil {
|
if !isVideo && info.Audios[idx].Keyframes != nil {
|
||||||
return info.Audios[idx].Keyframes, nil
|
ret = info.Audios[idx].Keyframes
|
||||||
|
}
|
||||||
|
info.lock.Unlock()
|
||||||
|
if ret != nil {
|
||||||
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
get_running, set := s.keyframeLock.Start(KeyframeKey{
|
get_running, set := s.keyframeLock.Start(KeyframeKey{
|
||||||
@ -111,6 +117,14 @@ func (s *MetadataService) GetKeyframes(info *MediaInfo, isVideo bool, idx uint32
|
|||||||
}
|
}
|
||||||
kf.info.ready.Add(1)
|
kf.info.ready.Add(1)
|
||||||
|
|
||||||
|
info.lock.Lock()
|
||||||
|
if isVideo {
|
||||||
|
info.Videos[idx].Keyframes = kf
|
||||||
|
} else {
|
||||||
|
info.Audios[idx].Keyframes = kf
|
||||||
|
}
|
||||||
|
info.lock.Unlock()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
var table string
|
var table string
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user