mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix transcoder execution time prints
This commit is contained in:
parent
b33b428d3b
commit
6ba0786608
@ -3,14 +3,12 @@ package src
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type FileStream struct {
|
||||
@ -67,9 +65,8 @@ func NewFileStream(path string) (*FileStream, error) {
|
||||
}
|
||||
|
||||
func GetKeyframes(path string) ([]float64, bool, error) {
|
||||
log.Printf("Starting ffprobe for keyframes analysis for %s", path)
|
||||
defer printExecTime("ffprobe analysis for %s", path)()
|
||||
// run ffprobe to return all IFrames, IFrames are points where we can split the video in segments.
|
||||
start := time.Now()
|
||||
// We ask ffprobe to return the time of each frame and it's flags
|
||||
// We could ask it to return only i-frames (keyframes) with the -skip_frame nokey but using it is extremly slow
|
||||
// since ffmpeg parses every frames when this flag is set.
|
||||
@ -89,7 +86,6 @@ func GetKeyframes(path string) ([]float64, bool, error) {
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
log.Printf("%s ffprobe analysis finished in %s", path, time.Since(start))
|
||||
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
|
||||
@ -194,7 +190,9 @@ func (fs *FileStream) GetMaster() string {
|
||||
} else {
|
||||
master += fmt.Sprintf("NAME=\"Audio %d\",", audio.Index)
|
||||
}
|
||||
master += "DEFAULT=YES,"
|
||||
if audio.IsDefault {
|
||||
master += "DEFAULT=YES,"
|
||||
}
|
||||
master += fmt.Sprintf("URI=\"./audio/%d/index.m3u8\"\n", audio.Index)
|
||||
}
|
||||
return master
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -175,7 +174,7 @@ var SubtitleExtensions = map[string]string{
|
||||
}
|
||||
|
||||
func GetInfo(path string) (*MediaInfo, error) {
|
||||
log.Printf("Running mediainfo for %s", path)
|
||||
defer printExecTime("mediainfo for %s", path)()
|
||||
|
||||
mi, err := mediainfo.Open(path)
|
||||
if err != nil {
|
||||
|
17
transcoder/src/utils.go
Normal file
17
transcoder/src/utils.go
Normal file
@ -0,0 +1,17 @@
|
||||
package src
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func printExecTime(message string, args ...any) func() {
|
||||
msg := fmt.Sprintf(message, args...)
|
||||
start := time.Now()
|
||||
log.Printf("Running %s", msg)
|
||||
|
||||
return func() {
|
||||
log.Printf("%s finished in %s", msg, time.Since(start))
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user