mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Cope with ffmpeg not reporting videos bitrates
This commit is contained in:
parent
40f02760ab
commit
7e3a1743c0
@ -1,6 +1,7 @@
|
|||||||
package src
|
package src
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -199,11 +200,11 @@ func GetInfo(path string, sha string) (*MediaInfo, error) {
|
|||||||
mi.ready.Add(1)
|
mi.ready.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
save_path := fmt.Sprintf("%s/%s/info.json", Settings.Metadata, sha)
|
save_path := fmt.Sprintf("%s/%s/info.json", Settings.Metadata, sha)
|
||||||
// if err := getSavedInfo(save_path, mi.info); err == nil {
|
if err := getSavedInfo(save_path, mi.info); err == nil {
|
||||||
log.Printf("Using mediainfo cache on filesystem for %s", path)
|
log.Printf("Using mediainfo cache on filesystem for %s", path)
|
||||||
// mi.ready.Done()
|
mi.ready.Done()
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
var val *MediaInfo
|
var val *MediaInfo
|
||||||
val, err = getInfo(path)
|
val, err = getInfo(path)
|
||||||
@ -271,7 +272,9 @@ func getInfo(path string) (*MediaInfo, error) {
|
|||||||
Quality: QualityFromHeight(uint32(stream.Height)),
|
Quality: QualityFromHeight(uint32(stream.Height)),
|
||||||
Width: uint32(stream.Width),
|
Width: uint32(stream.Width),
|
||||||
Height: uint32(stream.Height),
|
Height: uint32(stream.Height),
|
||||||
Bitrate: ParseUint(stream.BitRate),
|
// ffmpeg does not report bitrate in mkv files, fallback to bitrate of the whole container
|
||||||
|
// (bigger than the result since it contains audio and other videos but better than nothing).
|
||||||
|
Bitrate: ParseUint(cmp.Or(stream.BitRate, mi.Format.BitRate)),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Audios: MapStream(mi.Streams, ffprobe.StreamAudio, func(stream *ffprobe.Stream, i uint32) Audio {
|
Audios: MapStream(mi.Streams, ffprobe.StreamAudio, func(stream *ffprobe.Stream, i uint32) Audio {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user